如何检查“11分钟模式”是否将硬件时钟同步到系统时钟?

您应该知道Linux内核具有一种模式,它每11分钟将系统时间复制到硬件时钟(我们称其为“ 11分钟模式”)。当您使用诸如ntp之类的复杂功能来保持系统时间同步时,这是一个很好的模式。

RHEL8或更高版本,使用chrony进行同步

timedatectl不能用于检查“ 11分钟模式”是否打开和工作。该命令无法报告正确的结果。即使在/etc/chrony.conf中注释了“rtcsync”,它也会显示“System clock synchronized: yes”。如何查看请看“检查RHEL8和RHEL9系统中的”11分钟模式”是否正常的解决方案”。

RHEL7,使用chrony进行同步

在 RHEL7 中,使用“timedatectl”命令来验证”11分钟模式”是否开启和工作。

[root@shizhanxia.com ~]# timedatectl 
      Local time: Tue 2023-04-04 15:24:54 HKT
  Universal time: Tue 2023-04-04 07:24:54 UTC
        RTC time: Tue 2023-04-04 07:24:53
       Time zone: Asia/Hong_Kong (HKT, +0800)
     NTP enabled: yes
NTP synchronized: yes  <--------------
 RTC in local TZ: no
      DST active: n/a

如果synchronized为yes,则 chronyd (ntpd)处于同步状态并且”11分钟模式”正在运行。
如果您在/etc/chrony.conf中禁用“rtcsync”选项,则同步将为否。”11分钟模式”也将不起作用。如何检查“11分钟模式”是否将硬件时钟同步到系统时钟?

RHEL7及更早版本,带有ntp包

使用ntptime命令来验证”11分钟模式”是否开启和工作。

[root@shizhanxia.com ~]# ntptime 
ntp_gettime() returns code 5 (ERROR)
  time db39ef1c.a33d8000  Wed, Jul 20 2016 18:07:48.637, (.637657),
  maximum error 16000000 us, estimated error 16 us, TAI offset 0
ntp_adjtime() returns code 5 (ERROR)
  modes 0x0 (),
  offset 0.000 us, frequency 0.000 ppm, interval 1 s,
  maximum error 16000000 us, estimated error 16 us,
  status 0x41 (PLL,UNSYNC), 
  time constant 7, precision 1.000 us, tolerance 500 ppm,

如果UNSYNC出现在状态中,则ntpd不同步并且”11分钟模式”不起作用。
如果ntpd工作在步进模式,并且硬件时钟和系统时间之间的时间接近,ntpd会自动以11分钟模式同步系统时间到硬件时钟。

[root@shizhanxia.com ~]# ntptime 
ntp_gettime() returns code 0 (OK)
  time db39f2df.91194798  Wed, Jul 20 2016 18:23:51.566, (.566792379),
  maximum error 8080726 us, estimated error 25 us, TAI offset 0
ntp_adjtime() returns code 0 (OK)
  modes 0x0 (),
  offset 65.893 us, frequency -3.135 ppm, interval 1 s,
  maximum error 8080726 us, estimated error 25 us,
  status 0x2001 (PLL,NANO),  
  time constant 6, precision 0.001 us, tolerance 500 ppm,

如果UNSYNC不存在于状态中,则它处于同步状态。

原创文章,作者:实战侠,如若转载,请注明出处:https://www.shizhanxia.com/1356.html

(0)
上一篇 2023年4月19日 18:11
下一篇 2023年4月21日 14:37

相关推荐

发表回复

登录后才能评论