Linux系统不同主机之间的时间同步

摘要:同步各主机之间的时间,须得选定一个主机作为服务端,其他为客户端,这里仅以两台主机为例,即一个服务端和一个客户端的时间同步。
(一)服务端
1.打开主配置文件 vim /etc/chrony.conf
找到以下命令,并改之
21 # Allow NTP client access from local network.
22 allow 172.25.86.0/24 表示允许谁去同步我的时间
27 # Serve time even if not synchronized to any NTP server.
28 local stratum 10 不去同步任何人的时间,时间同步服务器级别
修改完成如下:
2.重启chronyd systemctl restart chronyd
3.关掉防火墙 systemctl stop firewalld
(二)客户端
1.打开主配置文件 vim /etc/chrony.conf
2. 将圈内文件修改,格式为:server ntpserverip iburst
例:server 172.25.86.11 iburst
3.重启chronyd并关闭其防火墙
(三)测试
(1)
(2)
(3)鼠标滑动有时延的,忽略忽略
(4)使用chronyc sources -v 测试
(四)timedatectl命令
1.timedatectl status 显示当前时间信息
2. timedatectl set-time 设定当前时间
3. timedatectl set-timezone 设定当前时区
效果如下:
4.timedatectl set-local-rtc 0|1 设定是否使用utc时间
效果如下:
(1)当 timedatectl set-local-rtc 0时
(1)当 timedatectl set-local-rtc 1 时




更多推荐
所有评论(0)