从CentOS 8开始,不使用ntpdate同步时间了。用chrony代替
安裝
dnf install chrony
yum install -y chrony
主配置文件:/etc/chrony.conf 客户端程序:/usr/bin/chronyc 服务端程序:/usr/sbin/chronyd
配置文件:/etc/chrony.conf
# 使用 pool.ntp.org 项目的公共服务器。 # 请考虑加入这个池(http://www.pool.ntp.org/join.html)。 server 0.centos.pool.ntp.org iburst # 使用 0.centos.pool.ntp.org 作为 NTP 服务器,并启用快速初始化模式 server 1.centos.pool.ntp.org iburst # 使用 1.centos.pool.ntp.org 作为 NTP 服务器,并启用快速初始化模式 server 2.centos.pool.ntp.org iburst # 使用 2.centos.pool.ntp.org 作为 NTP 服务器,并启用快速初始化模式 server 3.centos.pool.ntp.org iburst # 使用 3.centos.pool.ntp.org 作为 NTP 服务器,并启用快速初始化模式 # 记录系统时钟的快慢变化率。 driftfile /var/lib/chrony/drift # 指定用于记录系统时钟漂移率的文件路径 # 如果系统时钟的偏移量大于1秒,则在前三次更新中允许调整系统时钟。 makestep 1.0 3 # 在前三次更新中,如果时钟偏差超过1秒,则进行调整 # 启用实时时钟(RTC)的内核同步。 rtcsync # 启用与硬件实时时钟的同步功能 # 在支持的所有接口上启用硬件时间戳。 #hwtimestamp * # 启用硬件级时间戳,如果需要可以取消注释 # 增加调整系统时钟所需的可选择源的最小数量。 #minsources 2 # 设置可选择的最小NTP源数量,如果需要可以取消注释 # 允许本地网络中的 NTP 客户端访问。 #allow 192.168.0.0/16 # 允许指定IP范围内的设备访问NTP服务,如果需要可以取消注释并调整IP范围 # 即使未与时间源同步也提供时间服务。 #local stratum 10 # 设置本地时间层级,用于在没有外部同步源时提供时间服务,如果需要可以取消注释 # 指定包含 NTP 认证密钥的文件。 #keyfile /etc/chrony.keys # 指定NTP认证密钥文件的路径,如果需要使用NTP认证功能可以取消注释 # 指定日志文件的存储目录。 logdir /var/log/chrony # 设置chrony日志文件的存储目录 # 选择要记录的信息类型。 #log measurements statistics tracking # 指定要记录的日志信息类型,如需要可以取消注释
單次測試:
chronyd -q 'server 10.225.8.93 iburst'
服務相關:
systemctl start chronyd systemctl enable chronyd systemctl status chronyd
追蹤:
chronyc tracking
檢查同步源
chronyc sources -v
本文作者:澳门🇲🇴上班的IT人
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!