linux配置ntp时间同步

一、安装ntf

yum –y ×××tall ntp

二、配置ntp服务
1)修改所有节点的/etc/ntp.conf

vi /etc/ntp.conf
restrict 172.18.74.59 nomodify notrap nopeer noquery //当前节点IP地址
restrict 172.18.74.253 mask 255.255.255.0 nomodify notrap //集群所在网段的网关(Gateway),子网掩码(Genmask)

2)修改主节点/etc/ntp.conf

vi /etc/ntp.conf

在server部分添加一下部分,并注释掉server 0 ~ n

server 127.127.1.0
fudge 127.127.1.0 stratum 10

3)主节点以外,继续修改/etc/ntp.conf

vi /etc/ntp.conf

在server部分添加如下语句,将server指向主节点。

server 172.18.74.39
Fudge 172.18.74.39 stratum 10

三、启动ntp服务、查看状态
1)启动ntp服务

service ntpd start

2)查看ntp服务器有无和上层ntp连通

ntpstat

3)查看ntp服务器与上层ntp的状态

ntpq -p

四、设置开机启动

chkconfig ntpd on

查看从ntp服务状态可能会有如下错误
inappropriate address 172.18.74.119 for the fudge command, line ignored
经测试改了fudge的首字母为F就可以修复上述错误,看网上也都是小写的,很奇怪。
几分钟后查看主从ntp主机的时间就同步了,同步较慢稍等即可。

猜你喜欢

转载自blog.51cto.com/13670314/2409692