【Linux】Chrony时间同步

目录

前言

一、Chrony安装

二、服务配置

三、测试

四、稳定的国内外NTP服务器地址

总结



前言

        在Linux系统中,时间服务器确保系统时间的准确和一致性,这对于日志记录、安全性、调度任务等至关重要。通过NTP或Chrony等工具,系统可以定期与可信的时间源同步,避免时间差异导致的数据不一致和调试困难,特别在分布式系统中尤为重要。


一、Chrony安装

#sudo yum -y install chrony

二、服务配置

#vi /etc/chrony.conf


pool pool.ntp.org iburst		#配置ntp服务器地址

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3

# Enable kernel synchronization of the real-time clock (RTC).
rtcsync

# Allow NTP client access from local network.
allow 35.123.0.0/16				#如需放通所有则是 allow all

# Serve time even if not synchronized to a time source.
local stratum 10					#允许其他客户端从本机进行同步


#修改配置后需重启服务
systemctl restart chronyd && systemctl enable chronyd

三、测试

# chronyc sources -v


210 Number of sources = 1

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* 114.118.7.161                 1   6    61    19  -1141us[  +36ms] +/-   51ms



^* 表示连接服务器成功,通常修改地址后需要等待2-3分钟生效

四、稳定的国内外NTP服务器地址

国家授时中心 NTP 服务器(NTSC NTP Server)

ntp.ntsc.ac.cn

中国 NTP 快速授时服务(NTP ORG CN)

cn.ntp.org.cn

edu.ntp.org.cn        #教育网

国际 NTP 快速授时服务(Pool NTP ORG)

pool.ntp.org

0.pool.ntp.org

1.pool.ntp.org

2.pool.ntp.org

3.pool.ntp.org

asia.pool.ntp.org


总结

        Chrony时间服务器配置完成后,系统将能够可靠地与外部时间源同步,确保系统时间的准确性和稳定性,即使在网络连接不稳定的环境中,也能有效地维持时间一致性。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值