linux 7 配置chrony的客户端后,侦测时间是否同步
有些版本的操作系统在镜像里已不包含ntp包了,linux7 可以使用chrony来代替ntp。chrony服务端和客户单的配置有很多blog有说明,这里只描述下检测是否成功1.第一种方法直接对比ntp时间服务器和客户端服务器的时间。这个是明显的直观的2.第二种方法如果配置多台client可以比较相互之间是否有差异,不过这个有一定概率性,除非clinet数量比较多3.第三种方...
有些版本的操作系统在镜像里已不包含ntp包了,linux7 可以使用chrony来代替ntp。
chrony服务端和客户单的配置有很多blog有说明,这里只描述下检测是否成功
1.第一种方法
直接对比ntp时间服务器和客户端服务器的时间。这个是明显的、直观的
2.第二种方法
如果配置多台client可以比较相互之间是否有差异,不过这个有一定概率性,除非clinet数量比较多
3.第三种方法
通过命令
chronyc sources -v
3.1不通的情况
# chronyc sources -v
210 Number of sources = 2
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^? 192.168.11.253 0 10 0 - +0ns[ +0ns] +/- 0ns
^? 192.168.11.252 9 10 0 5d -108us[ -129us] +/- 11ms
3.2通的情况
#chronyc sources -v
210 Number of sources = 2
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.11.252 9 8 377 74 -165us[ -193us] +/- 10ms
^? 192.168.11.253 0 10 0 - +0ns[ +0ns] +/- 0ns
注意斜体部分中加粗的部分,3.1的?表示不通,3.2*表示通
第四种方法
根据命令反馈
4.1成功
Mar 09 17:09:17 zgbffile02 systemd[1]: Starting NTP client/server...
Mar 09 17:09:17 zgbffile02 chronyd[1461]: chronyd version 3.2 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SECHASH +SIGND +ASYNCDNS +IPV6 +DEBUG)
Mar 09 17:09:17 zgbffile02 chronyd[1461]: Frequency -123.732 +/- 0.043 ppm read from /var/lib/chrony/drift
Mar 09 17:09:17 zgbffile02 systemd[1]: Started NTP client/server.
Mar 09 17:16:04 zgbffile02 chronyd[1461]: Selected source 192.168.11.253
4.2成功
Mar 11 09:43:57 zgbfbak01 systemd[1]: Starting NTP client/server...
Mar 11 09:43:57 zgbfbak01 chronyd[142049]: chronyd version 3.2 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SECHASH +SIGND +ASYNCDNS +IPV6 +DEBUG)
Mar 11 09:43:57 zgbfbak01 chronyd[142049]: Frequency 0.000 +/- 1000000.000 ppm read from /var/lib/chrony/drift
Mar 11 09:43:57 zgbfbak01 systemd[1]: Started NTP client/server.
Mar 11 09:44:02 zgbfbak01 chronyd[142049]: Selected source 192.168.11.253
Mar 11 09:44:02 zgbfbak01 chronyd[142049]: System clock wrong by 50.609568 seconds, adjustment started
Mar 11 09:44:52 zgbfbak01 chronyd[142049]: System clock was stepped by 50.609568 seconds
4.3不成功
Mar 04 15:48:31 zgbfbak02 systemd[1]: Starting NTP client/server...
Mar 04 15:48:31 zgbfbak02 chronyd[108810]: chronyd version 3.2 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SECHASH +SIGND +ASYNCDNS +IPV6 +DEBUG)
Mar 04 15:48:31 zgbfbak02 systemd[1]: Started NTP client/server.
tips :第一种是已经同步,已经选择了时间服务器的源;第二种是发现与时间服务器不同步,开始调整;第三种情况只是启动了时间服务,并未与时间服务器交互。
查看是否能ping通时间服务器,如果ping能的话systemctl restart chronyd.service
更多推荐
所有评论(0)