参考:
https://www.thegeekdiary.com/centos-rhel-how-to-configure-ntp-server-and-client/
检查 NTP Server 是否工作正常
在linux CLI,在 NTP server 本机也可以, 10.2.0.11 是 ntp server 的 IP,这个命令就是在 10.2.0.11 上运行的。正常应该显示如下:
[nic@localhost ~]$ ntpdate -q 10.2.0.11server 10.2.0.11, stratum 3, offset -0.000017, delay 0.0257113 Oct 08:58:25 ntpdate[19475]: adjust time server 10.2.0.11 offset -0.000017 sec
如果上个命令显示不正常,查看 ntp service daemon 是否正常:sudo systemctl status ntpd
如果不正常,启动 ntpd,sudo systemctl start ntpdsudo systemctl enable ntpd 设置 ntpd 开机自动启动
如果 ntpd 运行正常,查看 ntp 是否与 remote 同步,运行
[nic@localhost ~]$ ntpq -premote refid st t when poll reach delay offset jitter==============================================================================+120.25.115.20 10.137.53.7 2 u 27 64 377 41.655 -2.405 0.915*203.107.6.88 10.137.38.86 2 u 30 64 377 18.068 2.142 1.410202.112.7.150 .INIT. 16 u - 64 0 0.000 0.000 0.000
ntpd 不能开机启动
https://forums.centos.org/viewtopic.php?t=58530#:~:text=CentOS7%20defaults%20to%20chronyd%20for,123%20is%20already%20in%20use.&text=To%20use%20ntpd%20you%20will,then%20start%20the%20nptd%20service.
CentOS7 defaults to chronyd for NTP services. This service is probably configured to start at boot and using port 123. When ntpd attempts to start if fails because port 123 is already in use.
You can check this with # netstat -tulpn | grep 123
To use ntpd you will need to stop and disable the chronyd service, then start the nptd service.systemctl disable chronyd
