[ NTPD 服务设置 ]
FreeBSD 自带NTPD服务
1. 配置/etc/ntp.conf,网上很多用的是日本的NTP服务器,其实国内就有。如国内授时中心服务器210.72.145.44,就可以。
# cat /etc/ntp.conf
server 210.72.145.44 prefer
server clepsydra.dec.com prefer
server pool.ntp.org prefer
server 202.106.199.35
driftfile /var/db/ntp.drift
statistics cryptostats loopstats peerstats
statsdir /var/log/ntpdstatus/
filegen peerstats file peerstats type day enable
filegen loopstats file loopstats type day enable
2. 设置rc.conf
增加
ntpd_enable="YES"
3. 先校对服务器的时间
根据http://www.time.edu.cn/mem.htm 给出的ntp服务器做校对
# ntpdate 202.112.10.60
19 Mar 16:28:12 ntpdate[24062]: adjust time server 202.112.10.60 offset -0.305178 sec
4. 启动ntpd服务
# /etc/rc.d/ntpd start
/* 如果出现不稳定现象,如ntpd进程自动中断,或不能提供服务。则可以重新下载源码编译安装。 */
# tar xzf ntp-4.2.4p6.tar.gz -C /var/tmp/
# cd /var/tmp/ntp-4.2.4p6/
# ./configure --prefix=/usr/local/ntpd
# make && make install
配置文件用上面的即可
# /usr/local/ntpd/bin/ntpd -g -D 0 -p /var/run/ntpd.pid -c /etc/ntp.conf -l /var/log/ntpd.log -s /var/log/ntpdstats
一些测试命令
ntpq -p
ntpdc -c loopinfo
ntpdc -c sysstats
ntpdc -c sysinfo
ntpq -c as
ntpq -c pe
参考
http://www.time.edu.cn/doc.htm