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分钟再次查看;同步已恢复;

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在CentOS 7.6上设置NTP服务器,您可以按照以下步骤进行操作: 1. 编辑NTP配置文件:使用命令`vim /etc/ntp.conf`打开NTP配置文件。 2. 添加以下内容到配置文件中: ``` restrict 172.25.10.6 nomodify notrap nopeer noquery restrict 172.25.10.1 mask 255.255.255.0 nomodify notrap server 127.127.1.0 fudge 127.127.1.0 stratum 10 ``` 其中,172.25.10.6是本机IP地址,172.25.10.1是网关地址。 3. 保存并关闭文件。 4. 重启NTP服务并开启相关端口:使用命令`systemctl restart ntpd`重启NTP服务。由于NTP服务使用UDP协议,需要开启123端口,可以使用以下命令添加防火墙规则: ``` firewall-cmd --permanent --zone=public --add-port=123/udp firewall-cmd --reload ``` 5. 设置NTP服务自启动:使用命令`systemctl enable ntpd`设置NTP服务在系统启动时自动启动。 6. 进行NTP服务器测试:可以使用命令`ntpq -p`检查NTP服务器是否正常工作。您应该会看到一些关于时间同步的输出。 通过以上步骤,您就可以在CentOS 7.6上成功设置NTP服务器了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [CentOS7.6搭建NTP服务器](https://blog.csdn.net/weixin_38467835/article/details/106194413)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [如何在CentOS中设置NTP服务器](https://download.csdn.net/download/weixin_38619207/14065557)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值