ntp服务分server跟client,现场四台服务器,选择一台作为server端,其他三台做client端,例如18.2.4.4为ntpServer,其他服务器为ntpClient
ntpServer端
1.ssh登录服务器,进入/etc目录下,建议先将ntp.conf文件备份,再修改ntp.conf文件,只保留以下内容
server 127.127.1.0
fudge 127.127.1.0 stratum 8
restrict 18.2.4.0 mask 255.255.254.0 nomodify notrap #允许的网段
2.执行service ntpd restart重启ntp服务
3.执行chkconfig --level 345 ntpd on,让ntp服务可以随系统启动
ntpClient端
1.待ntpServer端重启完,大约5-10分钟后,执行ntpdate ntpServerIp(这里写ntpServer的ip地址),出现类似下面的情况说明同步成功
----------------------
[root@hscbu-tx39 ~]# ntpdate 18.2.4.4
31 Dec 11:14:50 ntpdate[16457]: step time server 18.2.4.4 offset 1622240.103462 sec
----------------------
2.在ntpClient端加入系统定时任务
[root@hscbu-tx39 ~]# crontab -e
1 * * * * /usr/sbin/ntpdate 18.2.4.4
3.其他ntpClient同样的操作
ntpServer端
1.ssh登录服务器,进入/etc目录下,建议先将ntp.conf文件备份,再修改ntp.conf文件,只保留以下内容
server 127.127.1.0
fudge 127.127.1.0 stratum 8
restrict 18.2.4.0 mask 255.255.254.0 nomodify notrap #允许的网段
2.执行service ntpd restart重启ntp服务
3.执行chkconfig --level 345 ntpd on,让ntp服务可以随系统启动
ntpClient端
1.待ntpServer端重启完,大约5-10分钟后,执行ntpdate ntpServerIp(这里写ntpServer的ip地址),出现类似下面的情况说明同步成功
----------------------
[root@hscbu-tx39 ~]# ntpdate 18.2.4.4
31 Dec 11:14:50 ntpdate[16457]: step time server 18.2.4.4 offset 1622240.103462 sec
----------------------
2.在ntpClient端加入系统定时任务
[root@hscbu-tx39 ~]# crontab -e
1 * * * * /usr/sbin/ntpdate 18.2.4.4
3.其他ntpClient同样的操作