Centos 7.6 做ntp 时钟源同步验证

在日常运维过程中会涉及ntp时钟源配置,准备三台虚机作为验证ntp时钟源同步做演示,分享给大家,希望可以再日常运维中提供帮助。

【准备】

服务器1:192.168.66.10 ntp时钟源

服务器2:192.168.66.20 ntp客户端

服务器3:192.168.66.30 ntp客户端

【操作】

1.分别部署ntp软件

此次我们是通过yum 源方式来安装ntp

# rpm -qa | grep ntp

# yum install -y ntp ntpdate

可以提前先把yum源配置好或者是通过rpm方式来安装

手动下载安装包地址
http://mirror.centos.org/centos/7/os/x86_64/Packages/ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm
http://mirror.centos.org/centos/7/os/x86_64/Packages/ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm

2.配置ntp.conf 文件

NTP服务端:服务器1 192.168.66.10

在/etc/ntp.conf 配置文件中

增加

restrict 192.168.66.0 mask 255.255.255.0 nomodify notrap  ###添加本次网络的地址段

server 127.127.1.0 prefer         ### 127.127.1.0 回环地址 作为时钟源 ,或者如果外部时钟源也可                                                              以添加
fudge  127.127.1.0 stratum  10      ### 填入127.127.1.0 回环地址,fudge设置时间服务器的层级 stratum 0~15  ,0:表示顶级 , 10:通常用于给局域网主机提供时间服务

注释掉如下四行

#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 客户端: 192.168.66.20 和192.168.66.21

在/etc/ntp.conf配置文件中增加:

server 192.168.66.10 prefer       ### 首选192.168.66.10 作为时钟源
fudge  192.168.66.10 stratum  10   ##填入时钟源地址

注释掉如下四行

#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 

3.配置完成后重启ntpd服务

# systemctl restart ntpd

NTP时钟源:

NTP客户端:

 4.检查NTP同步情况

# ntpstat

 # ntpq -p 检查

发现再重启ntpd后与是时钟源同步相差较大,需要等待5-10分钟再次查看;同步已恢复;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值