<svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> <path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path> </svg> <p>关于chrony:</p>
讯享网
讯享网
OS环境:
NTP Server:192.168.170.8
NTP Client:192.168.170.9
CentOS Linux release 7.2.1504 (Core)
1.安装Chrony
系统默认已经安装,如未安装,请执行以下命令安装:
[root@node3 ~]# systemctl enable chronyd.service
[root@node3 ~]# systemctl start chronyd.service
[root@node3 ~]# systemctl status chronyd.service
3.Firewalld设置
[root@node3 ~]# firewall-cmd –add-service=ntp –permanent
[root@node3 ~]# firewall-cmd –reload
因NTP使用123/UDP端口协议,所以允许NTP服务即可。
4.配置Chrony
修改默认配置文件,并做说明:
[root@node3 ~]# vi /etc/chrony.conf
#server 0.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 192.168.170.8 iburst
#chronyd根据需求减慢或加速时间调整,
#在某些情况下系统时钟可能漂移过快,导致时间调整用时过长。
#该指令强制chronyd调整时期,大于某个阀值时步进调整系统时钟。
#只有在因chronyd启动时间超过指定的限制时(可使用负值来禁用限制)没有更多时钟更新时才生效。
makestep 1.0 3
#Enable hardware timestamping on all interfaces that support it.
#通过使用hwtimestamp指令启用硬件时间戳
#hwtimestamp eth0
#hwtimestamp eth1
#hwtimestamp *
#指定一台主机、子网,或者网络以允许或拒绝NTP连接到扮演时钟服务器的机器
#allow 192.168.0.0/16
#deny 192.168⁄16
allow 192.168.0.0/16 允许该网段客户端来同步时间
[root@node3 ~]# systemctl restart chronyd
NTP Client 做测试
[root@node2 ~]# yum -y install ntp 安装ntp工具
[root@node3 ~]# ntpdate 192.168.170.8
5.设置时区
查看当前系统时区:
[root@node3 ~]# timedatectl
Local time: Fri 2018-10-29 13:31:04 CST
Universal time: Fri 2018-10-29 05:31:04 UTC
RTC time: Fri 2018-10-29 08:17:20
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
如果你当前的时区不正确,请按照以下操作设置。
查看所有可用的时区:
[root@node3 ~]# timedatectl list-timezones
筛选式查看在亚洲S开的上海可用时区:
[root@node3 ~]# timedatectl list-timezones | grep -E “Asia/S.*”
Asia/Sakhalin
Asia/Samarkand
Asia/Seoul
Asia/Shanghai
Asia/Singapore
Asia/Srednekolymsk
设置当前系统为Asia/Shanghai上海时区:
[root@node3 ~]# timedatectl set-timezone Asia/Shanghai
设置完时区后,强制同步下系统时钟:
7.常用命令
查看时间同步源:
[root@node3 ~]# chronyc sources -v
查看时间同步源状态:
[root@node3 ~]# chronyc sourcestats -v
设置硬件时间
硬件时间默认为UTC:
[root@node3 ~]# timedatectl set-local-rtc 1
启用NTP时间同步:
[root@node3 ~]# timedatectl set-ntp yes
校准时间服务器:
[root@node3 ~]# chronyc tracking

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/179793.html