自学内容网 自学内容网

Centos7 NTP客户端

1. NTP客户端

1.1 安装

如果chrony没有安装,可以使用以下命令安装

sudo yum install chrony

1.2 启动

启动并设置开机自启

sudo systemctl start chronyd
sudo systemctl enable chronyd

1.3 同步状态异常

本主机禁止访问互联网

[root@zabbix ~]# chronyc tracking
Reference ID    : 00000000 ()
Stratum         : 0
Ref time (UTC)  : Thu Jan 01 00:00:00 1970
System time     : 0.000000000 seconds slow of NTP time
Last offset     : +0.000000000 seconds
RMS offset      : 0.000000000 seconds
Frequency       : 12.533 ppm slow
Residual freq   : +0.000 ppm
Skew            : 0.000 ppm
Root delay      : 1.000000000 seconds
Root dispersion : 1.000000000 seconds
Update interval : 0.0 seconds
Leap status     : Not synchronised

[root@zabbix ~]# chronyc sources
210 Number of sources = 4
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^? ntp8.flashdance.cx            0   8     0     -     +0ns[   +0ns] +/-    0ns
^? ntp5.flashdance.cx            0   8     0     -     +0ns[   +0ns] +/-    0ns
^? ntp6.flashdance.cx            0   8     0     -     +0ns[   +0ns] +/-    0ns
^? ntp1.flashdance.cx            0   8     0     -     +0ns[   +0ns] +/-    0ns

查看 chronyc tracking 输出的 Leap status,它应该显示为 Normal。
查看 chronyc sources 中的 NTP 服务器前是否有 * 符号,表示已经同步。
在这里插入图片描述

1.4 更改/etc/chrony.conf配置文件

添加内网NTP服务器IP 地址

server 172.16.13.1 iburst

重启服务

[root@zabbix ~]# systemctl restart chronyd.service 

1.5 同步状态正常

[root@zabbix ~]# chronyc tracking
Reference ID    : AC100D01 (172.16.13.1)
Stratum         : 3
Ref time (UTC)  : Wed Sep 25 07:42:13 2024
System time     : 0.000018922 seconds slow of NTP time
Last offset     : -0.000028374 seconds
RMS offset      : 0.000028374 seconds
Frequency       : 12.533 ppm slow
Residual freq   : -9.672 ppm
Skew            : 0.120 ppm
Root delay      : 0.001319975 seconds
Root dispersion : 0.011807274 seconds
Update interval : 2.0 seconds
Leap status     : Normal
[root@zabbix ~]# chronyc sources
210 Number of sources = 5
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* 172.16.13.1                   2   6    17    12   -931us[ -959us] +/-   13ms
^? time.neu.edu.cn               0   7     0     -     +0ns[   +0ns] +/-    0ns
^? time.cloudflare.com           0   7     0     -     +0ns[   +0ns] +/-    0ns
^? electrode.felixc.at           0   7     0     -     +0ns[   +0ns] +/-    0ns
^? time.neu.edu.cn               0   7     0     -     +0ns[   +0ns] +/-    0ns

在这里插入图片描述


原文地址:https://blog.csdn.net/tladagio/article/details/142525052

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!