171015chrony时间同步

来源:互联网 发布:thinkphp商城源码下载 编辑:程序博客网 时间:2024/06/05 19:41

chrony时间同步:

server172.25.254.101client172.25.254.201

client端用timedatectl命令将时间改为111111

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 #将时间修改为110000

timedatectl set-timezone "Asia/Shanghai"  #将时区修改为亚洲/上海




原创粉丝点击