今天把几台放了一段时间的单板机开了起来
两台装了rocky linux ,一台装了Ubuntu server 20
树莓派的更新yum显示报错
报CA错误,但是我一想,树莓派节点是没有rtc电池的,没有硬件时间,很可能是因为时间问题导致的这个错误
于是我开始查找如何同步时间,centos8 和 rocky linux 8 都默认不带ntpdate,使用chrony进行时间同步,chrony是一个ntp协议的实现,使用起来更简单
只需要如下配置
systemctl enable chronyd.service
systemctl start chronyd.service
systemctl status chronyd.service
就可以看到
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2018-06-22 11:11:53 UTC; 16h ago
Docs: man:chronyd(8)
man:chrony.conf(5)
Main PID: 270 (chronyd)
Tasks: 1 (limit: 11407)
CGroup: /system.slice/chronyd.service
└─270 /usr/sbin/chronyd
这个时候时间还是没有同步到的,我们需要修改配置文件
/etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#pool 2.pool.ntp.org iburst //注释掉默认的服务器
server ntp.aliyun.com iburst
server ntp.ntsc.ac.cn iburst
//添加阿里云和国家授时中心
查看服务
[root@node3 yum.repos.d]# chronyc sourcestats -v
210 Number of sources = 2
.- Number of sample points in measurement set.
/ .- Number of residual runs with same sign.
| / .- Length of measurement set (time).
| | / .- Est. clock freq error (ppm).
| | | / .- Est. error in freq.
| | | | / .- Est. offset.
| | | | | | On the -.
| | | | | | samples. \
| | | | | | |
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
==============================================================================
203.107.6.88 4 3 6 +246.828 4770.108 +217us 566us
114.118.7.161 3 3 6 +500.884 218244 +18ms 1077us
此时我们查看下时间是否正确
[root@node3 yum.repos.d]# timedatectl
Local time: 五 2021-11-26 02:05:36 UTC
Universal time: 五 2021-11-26 02:05:36 UTC
RTC time: n/a
Time zone: UTC (UTC, +0000)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
[root@node1 ~]# timedatectl
Local time: Thu 2021-11-25 21:20:39 EST
Universal time: Fri 2021-11-26 02:20:39 UTC
RTC time: Fri 2021-11-26 02:20:39
Time zone: America/New_York (EST, -0500)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
时间是对了,但是时区不对,我们设置时区,再查看时间
root@node3 yum.repos.d]# timedatectl set-timezone Asia/Shanghai
[root@node3 yum.repos.d]#
[root@node3 yum.repos.d]# timedatectl
Local time: 五 2021-11-26 10:06:43 CST
Universal time: 五 2021-11-26 02:06:43 UTC
RTC time: n/a
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
OK,我们再次尝试 yum makecache
[root@node3 yum.repos.d]# yum makecache
Rocky Linux 8 - AppStream 4.6 MB/s | 7.0 MB 00:01
Rocky Linux 8 - BaseOS 2.6 MB/s | 2.9 MB 00:01
Rocky Linux 8 - Extras 643 kB/s | 322 kB 00:00
元数据缓存已建立。
OK ,问题解决~