码迷,mamicode.com
首页 > 其他好文 > 详细

chrony时钟同步

时间:2020-04-16 13:06:07      阅读:67      评论:0      收藏:0      [点我收藏+]

标签:exp   配置   info   status   oca   please   lease   hardware   att   

chrony

安装 Chrony

1.安装Chrony

yum install chrony -y

启动chronyd进程

systemctl start chronyd.service
systemctl enable chronyd.service

检查chronyd的进程状态

systemctl status chronyd.service

Firewalld设置

firewall-cmd --add-service=ntp --permanent
firewall-cmd --reload

配置 Chrony

chrony 配置文件/etc/chrony.conf

# 使用pool.ntp.org项目中的公共服务器。以server开,理论上你想添加多少时间服务器都可以。
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
?
# 根据实际时间计算出服务器增减时间的比率,然后记录到一个文件中,在系统重启后为系统做出最佳时间补偿调整。
driftfile /var/lib/chrony/drift
?
# chronyd根据需求减慢或加速时间调整,
# 在某些情况下系统时钟可能漂移过快,导致时间调整用时过长。
# 该指令强制chronyd调整时期,大于某个阀值时步进调整系统时钟。
# 只有在因chronyd启动时间超过指定的限制时(可使用负值来禁用限制)没有更多时钟更新时才生效。
makestep 1.0 3
?
# 将启用一个内核模式,在该模式中,系统时间每11分钟会拷贝到实时时钟(RTC)。
rtcsync
?
# Enable hardware timestamping on all interfaces that support it.
# 通过使用hwtimestamp指令启用硬件时间戳
#hwtimestamp eth0
#hwtimestamp eth1
#hwtimestamp *
?
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
?
# 指定一台主机、子网,或者网络以允许或拒绝NTP连接到扮演时钟服务器的机器
#allow 192.168.0.0/16
#deny 192.168/16
?
# Serve time even if not synchronized to a time source.
local stratum 10
?
# 指定包含NTP验证密钥的文件。
#keyfile /etc/chrony.keys
?
# 指定日志文件的目录。
logdir /var/log/chrony
?
# Select which information is logged.
#log measurements statistics tracking

检查chrony配置源 我们可以使用命令确认现在 chrony 使用的时间源:

chronyc sources

chronyc 工具可以对每个源进行统计,比如使用 sourcestats 命令获得漂移速率和进行偏移估计。

chronyc sourcestats

如果你的系统没有连接到互联网,你需要告知 Chrony 系统没有连接到 互联网。为了这样做,运行:

chronyc offline

检查 NTP 源的状态,只需要运行:

chronyc activity

一旦你连接到互联网,只需要使用命令告知 Chrony 你的系统已经回到在线状态:

chronyc online

强制同步下系统时钟

chronyc -a makestep

校准时间服务器

 chronyc tracking

 

chrony时钟同步

标签:exp   配置   info   status   oca   please   lease   hardware   att   

原文地址:https://www.cnblogs.com/jiangwh/p/12711977.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!