chrony时间同步:
(server端172.25.254.101,client端172.25.254.201)
在client端用timedatectl命令将时间改为11:11:11

而server端时间如下
server:
yum install chrony -y ##安装服务
vim /etc/chrony.conf ##主配置文件
21 # Allow NTP client access from local network.
22 allow 172.25.254.0/24 ##允许谁去同步我的时间
23
24 # Listen for commands only on localhost.
25 bindcmdaddress 127.0.0.1
26 bindcmdaddress ::1
27
28 # Serve time even if not synchronized to any NTP server.
29 local stratum 10 ##不去同步任何人的时间,时间同步服务器级别
22行:去掉注释并改为允许172.25.254.x网段的机器同步server端的时间
29行:去掉注释
systemctl stop firewalld
systemctl restart chronyd.service
client:
vim /etc/chrony.conf
3-6行注释,增加第7行内容,表示从哪台主机同步时间。
systemctl restart chronyd.service
chronyc sources -v查看状态

systemctl restart chronyd
重启服务,过一会发现client端时间与server一样了。
timedatectl命令
timedatectl status ##显示当前时间信息
set-time ##设定当前时间
set-timezone ##设定当前时区
set-local-rtc 0|1 ##设定是否使用utc时间
timedatectl set-time 11:00:00 #将时间修改为11:00:00
timedatectl set-timezone "Asia/Shanghai" #将时区修改为“亚洲/上海”
本文介绍如何使用Chrony服务进行时间同步配置。包括在server端安装Chrony服务、配置允许客户端访问、设置本地时间级别,以及在client端配置时间同步源,并通过命令重启服务验证时间同步效果。
649

被折叠的 条评论
为什么被折叠?



