1.在内网每台服务器上都安装ntp时间同步软件
yum install ntp -y
2.配置每台服务器NTP服务为自启动
每台服务器使用ntpdate手动同步下时间,免得本机与外部时间服务器时间差距太大,让ntpd不能正常同步。
3.配置内网ntp-server(172.16.1.61)
为了简单,我只列出了配置项,注释和空行全部清理了
vim /etc/ntp.conf
在ntp-server(172.16.1.61) /etc/ntp.conf配置文件内删除
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-server(172.16.1.61) /etc/ntp.conf配置文件内添加
restrict 172.16.1.61 nomodify notrap nopeer noquery
restrict 172.16.1.2 mask 255.255.255.0 nomodify notrap
server 210.72.145.44
server 202.112.10.36
server 59.124.196.83
service 127.127.1.0
fudge 127.127.1.0 stratum 10
restrict 210.72.145.44 nomodify notrap noquery
restrict 202.112.10.36 nomodify notrap noquery
restrict 59.124.196.83 nomodify notrap noquery
配置文件修改完成,保存退出,启动服务。
查看ntp-server(172.16.1.61)ntpd服务情况
看红色加粗的地方,表示连接和监听已正确,采用UDP方式
netstat命令查看时间同步状态,这个一般需要5-10分钟后才能成功连接和同步
连接并同步后:
OK,内网server端的NTPD服务已经配置完成,如果所有正常后,开始配置内网的其他设备与这台服务器作为时间同步服务。
4. 配置内网NTP-Clients
在ntp-client(172.16.1.51)等其他全部客户端服务器 /etc/ntp.conf配置文件内删除
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-server(172.16.1.51)等客户端服务器 /etc/ntp.conf配置文件内添加
server 172.16.1.61
restrict 172.16.1.61 nomodify notrap nopeer noquery
restrict 172.16.1.2 mask 255.255.255.0 nomodify notrap
service 127.127.1.0
fudge 127.127.1.0 stratum 10
保存退出,请求服务器前,请先使用ntpdate手动同步下时间
这里有可能出现同步失败,一般情况下原因都是本地的NTPD服务器还没有正常启动起来,一般需要几分钟时间后才能开始同步。
启动客户端启动后,查看同步情况
遇到此报错解决方法
因为是内网,一般ntpstat很快就可以同步上,几分钟需要等下,如图所示ok
转载于:https://blog.51cto.com/14256904/2406472