ntpd配置时间同步服务器

修改同步服务器的配置文件/etc/ntp.conf ,删除所有的内容,添加

restrict default nomodify
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 8

重启ntpd

/etc/init.d/ntpd restart

等待ntp服务器自身同步完成

watch ntpq -p

观察这个reach需要超过17
否则其他机器ntpdate同步的时候会报错

配置文件方式

服务器端配置

restrict default nomodify
server  127.127.1.0
fudge   127.127.1.0 stratum 8

客户端配置

driftfile /var/lib/ntp/drift
server 192.168.8.102
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys

/etc/sysconfig/ntpd

添加

SYNC_HWCLOCK=yes

多台ntp的情况

客户端配置

driftfile /var/lib/ntp/drift
server 192.168.8.102 prefer
server 192.168.8.101
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys

主ntp配置(可以改成上级ntp)

restrict default nomodify
server  127.127.1.0
fudge   127.127.1.0
stratum 5

备份ntp配置

driftfile /var/lib/ntp/drift
server 192.168.8.102
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
stratum 6

更新历史

why when
创建 2013年08月06日
更新 2019年12月9日
原文地址:https://www.cnblogs.com/zphj1987/p/13575263.html