文章目录
1.timedatectl
timedatectl set-time "2020-11-11 11:11:11" 设定系统时间
timedatectl list-timezones 显示系统的所有时区
timedatectl set-timezone "Asia/shanghai" 设定系统时区为亚洲上海
timedatectl set-local-rtc 0|1 0表示使用UTC时间计算方式,1表示系统时间计算方式
注意:
使用UTC时间计算方式会更改硬件时间,双系统的话会导致时间错误。
2.时间同步服务
node2同步node1的时间:
node2:
date
vim /etc/chrony.conf
3 pool 172.25.254.128 iburst 设置同步时间的来源
systemctl restart chronyd.service
node1:
date
timectl set-time "11:11:11"
date
vim /etc/chrony.conf
22 # Allow NTP client access from local network.
23 allow 172.25.254.228/24 允许172.25.254.228、24网段主机同步时间
24
25 # Serve time even if not synchronized to a time source.
26 local stratum 10 开启时间同步服务功能,并设定级别为10
systemctl restart chronyd.service
测试:
node2上:
chronyc sources -v
date