文章目录
RTC 误差计算
1ppm 代表 100 万秒内误差为 1s。
通常晶振精度为 20ppm,那么一天的误差大约是:
20(ppm)* 24(小时) * 60(分钟)* 60(秒)=1728000/1000000s=1.728s
linux 下使用 chrony
关闭系统自动网络对时
设置上海时区,可用指令或者上图中设置
timedatectl set-timezone Asia/Shanghai
设置 RTC 时区为系统当前时区
timedatectl set-local-rtc yes
检查设置,结果如下图:
timedatectl
安装 chrony
yum install -y chrony
关闭 chrony 自动对时,改为手动对时
vim /etc/chrony.conf
注释 ntp 服务器段和 rtc 同步段。
设置主机名,以区分 log。
#例如配置21机台可以设置为:
hostname -b cfg21
连接外网,第一次手动对时,确认 RTC 时间已经纠正,断开网络
chronyd -q 'server 2.rhel.pool.ntp.org iburst' >> /home/$(hostname)_rtc.check.log 2>&1
#将网络对时后的OS时间写入RTC
hwclock -w
#检查RTC时间与网络时间相同
timedatectl
48/72小时后手动对时,重新连接外网,记录误差值
chronyd -q 'server 2.rhel.pool.ntp.org iburst' >> /home/$(hostname)_rtc.check.log 2>&1