今天发现之前配置了chrony时间同步,但是发现时间同步客户端机器跟时间同步服务器端的时间并不同步。
查客户端:
manage@k8s-master1[/home/manage]$timedatectl
Local time: 三 2019-08-07 10:03:33 CST
Universal time: 三 2019-08-07 02:03:33 UTC
RTC time: 三 2019-08-07 10:03:33
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: yes
DST active: n/a
Warning: The system is configured to read the RTC time in the local time zone.
This mode can not be fully supported. It will create various problems
with time zone changes and daylight saving time adjustments. The RTC
time is never updated, it relies on external facilities to maintain it.
If at all possible, use RTC in UTC by calling
'timedatectl set-local-rtc 0'.
底下有个warning,所以按照他的要求,关闭本地时间同步。
按照提示执行下面的命令即可。
sudo timedatectl set-local-rtc 0
然后在查看:
manage@k8s-master1[/home/manage]$timedatectl
Local time: 三 2019-08-07 10:07:37 CST
Universal time: 三 2019-08-07 02:07:37 UTC
RTC time: 三 2019-08-07 02:07:36
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
看到本地同步关闭。
查看服务端:
manage@commmanage[/home/manage]$systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: active (running) since 四 2019-07-25 14:07:02 CST; 1 weeks 5 days ago
Docs: man:firewalld(1)
Main PID: 60144 (firewalld)
Tasks: 2
CGroup: /system.slice/firewalld.service
└─60144 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
7月 25 14:07:02 commmanage systemd[1]: Starting firewalld - dynamic firewal....
7月 25 14:07:02 commmanage systemd[1]: Started firewalld - dynamic firewall....
Hint: Some lines were ellipsized, use -l to show in full.
发现防火墙是开着的,所以怀疑是防火墙使的坏。
关闭服务器端防火墙:
sudo systemctl stop firewalld
重启客户端chronyd进程:
sudo systemctl restart chronyd
查看客户端时间同步状态:
manage@k8s-master1[/home/manage]$timedatectl
Local time: 三 2019-08-07 10:23:24 CST
Universal time: 三 2019-08-07 02:23:24 UTC
RTC time: 三 2019-08-07 02:25:35
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
看到已经可以时间同步了。
但是目前不想关闭服务端的防火墙:
sudo firewall-cmd --zone=public --add-port=123/tcp --permanent
sudo firewall-cmd --zone=public --add-port=123/udp --permanent
sudo systemctl reload firewalld
sudo systemctl restart firewalld
重启客户端chrony服务:
sudo systemctl restart chronyd
manage@k8s-master1[/home/manage]$timedatectl
Local time: 三 2019-08-07 10:47:13 CST
Universal time: 三 2019-08-07 02:47:13 UTC
RTC time: 三 2019-08-07 02:49:24
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
也是ok的。