CentOS 7.5搭建NTP时间同步服务

1.在内网每台服务器上都安装ntp时间同步软件
yum install ntp -y
CentOS 7.5搭建NTP时间同步服务

2.配置每台服务器NTP服务为自启动
CentOS 7.5搭建NTP时间同步服务
每台服务器使用ntpdate手动同步下时间,免得本机与外部时间服务器时间差距太大,让ntpd不能正常同步。
3.配置内网ntp-server(172.16.1.61)
为了简单,我只列出了配置项,注释和空行全部清理了
CentOS 7.5搭建NTP时间同步服务
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
配置文件修改完成,保存退出,启动服务。
CentOS 7.5搭建NTP时间同步服务
查看ntp-server(172.16.1.61)ntpd服务情况
CentOS 7.5搭建NTP时间同步服务
看红色加粗的地方,表示连接和监听已正确,采用UDP方式
netstat命令查看时间同步状态,这个一般需要5-10分钟后才能成功连接和同步
连接并同步后:
CentOS 7.5搭建NTP时间同步服务

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手动同步下时间
CentOS 7.5搭建NTP时间同步服务
这里有可能出现同步失败,一般情况下原因都是本地的NTPD服务器还没有正常启动起来,一般需要几分钟时间后才能开始同步。
启动客户端启动后,查看同步情况
CentOS 7.5搭建NTP时间同步服务

遇到此报错解决方法
CentOS 7.5搭建NTP时间同步服务

因为是内网,一般ntpstat很快就可以同步上,几分钟需要等下,如图所示ok
CentOS 7.5搭建NTP时间同步服务

转载于:https://blog.51cto.com/14256904/2406472

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值