试验环境
第一步,以上所有的机器都安装ntp
[root@ltt1 ~]# yum install ntp ntpdate -y
第二步,设置开机自启动
[root@ltt1 conf]# chkconfig ntpd on
[root@ltt1 conf]# chkconfig --list ntpd
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
第一、第二,以上两步,在各机器上都要执行
第三步,配置内网NTP-server(192.168.11.11)
此步是在你要设置成NTP服务的机器上配置,它将给内网所有的机器进行授时,即内网所有机器都是以它的时间为准。
我这里选择的是192.168.11.11。
先使用ntpdate手动同步下内网中作为 NTPD 服务器的时间,免得本机与外部时间服务器时间差距太大,让ntpd不能正常同步。即在 192.168.11.11 上执行。
ntpdate -u 1.cn.pool.ntp.org
然后要找到可以正常提供时间服务的外部主机,执行以下命令。
[root@ltt1 ~]# ntpdate -q 1.cn.pool.ntp.org
server 51.15.41.135, stratum 3, offset -0.648578, delay 0.37547
server 193.228.143.12, stratum 2, offset -0.652907, delay 0.36064
server 202.118.1.130, stratum 2, offset -0.650668, delay 0.05075
server 120.25.115.20, stratum 2, offset -0.650029, delay 0.06900
29 Sep 17:51:21 ntpdate[1500]: step time server 202.118.1.130 offset -0.650668 sec
这里可以看到列出了四个外部主机,以及和本机时间的时间差异。
最后一行的末尾,time server 202.118.1.130 offset -0.650668 sec,这说明时间差异最小的一个外部主机为202.118.1.130
必要的信息已经获取,现在正是开始配置NTP。
[root@ltt1 ~]# vi /et