1.在每台服务器安装ntp
# yum -y install ntp
2.配置ntp为开机启动
# chkconfig ntpd on
3.配置ntp服务器
修改配置文件ntp.conf
# vim /etc/ntp.conf
注释掉默认的ntp server
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
然后在下面添加中国的授权时间服务器,因为国外的时间服务器同步会有延迟,因此改为大陆的深圳服务器托管,深圳服务器租用
server cn.pool.ntp.org prefer
server 210.72.145.44
prefer代表优先采用此ntp服务器同步时间
restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap
5.启动ntp server
# service ntpd start
4.配置ntp客户端
编辑ntp.conf
# vim /etc/ntp.conf
注释掉默认的ntp server
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
然后在下面添加内部ntp服务器ip地址
server 192.168.1.4
5.测试时间是否可以同步深圳服务器托管
# ntpdate 192.168.1.4
6.启动ntp客户端
# service ntpd start