公司需要ntp时间同步的操作文档,在网上看到好多的文档都不行;捣鼓了好久终于弄好了,写出来希望给后来的人一些方便
环境server 192.168.2.50
client 192.168.2.52
在server上配置好yum
yum安装ntp
yum install ntp
修改ntp配置文件
vim /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap (不限制任何机器对其同步时间)
restrict 127.0.0.1
restrict -6 ::1
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
server 127.127.1.0(同步本地时间)
fudge 127.127.1.0 stratum 8
重启ntp服务
service ntpd restart
netstat -tulnp|grep ntp
udp 0 0 192.168.2.58:123 0.0.0.0:* 30234/ntpd
udp 0 0 192.168.2.54:123 0.0.0.0:* 30234/ntpd
udp 0 0 169.254.232.49:123 0.0.0.0:* 30234/ntpd
udp 0 0 169.254.30.234:123 0.0.0.0:* 30234/ntpd
udp 0 0 10.10.4.52:123 0.0.0.0:* 30234/ntpd
udp 0 0 10.10.3.52:123 0.0.0.0:* 30234/ntpd
udp 0 0 10.10.2.52:123 0.0.0.0:* 30234/ntpd
udp 0 0 10.10.1.52:123 0.0.0.0:* 30234/ntpd
udp 0 0 192.168.2.52:123 0.0.0.0:* 30234/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 30234/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 30234/ntpd
udp 0 0 fe80::26be:5ff:ff89:1b72:123 :::* 30234/ntpd
udp 0 0 fe80::26be:5ff:ff89:1b71:123 :::* 30234/ntpd
udp 0 0 fe80::202:c903:19:c011:123 :::* 30234/ntpd
udp 0 0 fe80::202:c903:19:c012:123 :::* 30234/ntpd
udp 0 0 fe80::ec4:7aff:fea8:b008:123 :::* 30234/ntpd
udp 0 0 ::1:123 :::* 30234/ntpd
udp 0 0 :::123 :::* 30234/ntpd
客户端配置
yum install ntp
vim /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict 127.0.0.1
restrict -6 ::1
server 192.168.2.52(选择ntp服务器)
restrict 192.168.2.52 nomodify notrap noquery
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
server 127.0.0.1
fudge 127.127.1.0 stratum 8
完成后在客户端 ntpdate -u 192.168.2.52验证是否成功或者等待2-3小时后两台机器自己就会同步(具体机制不太清楚)