CentOS本机配置为时间源

CentOS本机配置为时间源

安装chrony,默认已安装

bash 复制代码
yum -y install chrony

修改配置文件 /etc/chrony.conf

bash 复制代码
# cat /etc/chrony.conf | grep -Ev "^$|#"
server ceph00 iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
allow 10.0.0.0/16
local stratum 10
logdir /var/log/chrony
bash 复制代码
# 删除或注释掉其他 server 行
# 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

server ceph00 iburst

# 配置本机作为时间源
local stratum 10

# 允许其他客户端访问本机时间服务
# 根据实际网络配置修改
allow 10.0.0.0/16

# 记录系统时钟的偏移率
driftfile /var/lib/chrony/drift

# 允许在前三次更新中步进式调整系统时钟
makestep 1.0 3

# 启用实时时钟同步
rtcsync

# 指定日志目录
logdir /var/log/chrony

# 启用详细日志记录
log measurements statistics tracking
bash 复制代码
systemctl restart chronyd
systemctl enable chronyd
bash 复制代码
   # 检查服务状态
   systemctl status chronyd
   
   # 检查时间源
   chronyc sources
bash 复制代码
# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* ceph00                       10   6    37     5     +1ns[-1098ns] +/-   12us
bash 复制代码
Number of sources = 1:配置了1个时间源
时间源是 ceph00
^* 表示当前选中的时间源(已同步)
Stratum = 10:层级为10,符合本地时间源的设置
Poll = 6:轮询间隔为 2^6 = 64秒
Reach = 37:(八进制)表示最近的连接成功状态
LastRx = 5:5秒前最后一次接收到更新
Last sample = +1ns[-1098ns]:最后一次采样的时间偏差
+/- 12us:测量的误差范围

客户端配置

  • 修改 ceph01 的 /etc/chrony.conf
bash 复制代码
# 配置 ceph00 作为时间源
server ceph00 iburst

# 记录系统时钟的偏移率
driftfile /var/lib/chrony/drift

# 允许在前三次更新中步进式调整系统时钟
makestep 1.0 3

# 启用实时时钟同步
rtcsync

# 注释掉本地时间源配置(因为是客户端)
#local stratum 10

# 指定日志目录
logdir /var/log/chrony

# 启用详细日志记录(建议取消注释以便于调试)
#log measurements statistics tracking
bash 复制代码
systemctl restart chronyd
systemctl status chronyd
systemctl enable chronyd
# 检查时间源
chronyc sources

# 检查详细的同步状态
chronyc tracking
相关推荐
Linux运维技术栈22 分钟前
多系统 Node.js 环境自动化部署脚本:从 Ubuntu 到 CentOS,再到版本自由定制
linux·ubuntu·centos·node.js·自动化
刘一说4 小时前
CentOS 系统 Java 开发测试环境搭建手册
java·linux·运维·服务器·centos
Fireworkitte14 小时前
Ubuntu、CentOS、AlmaLinux 9.5的 rc.local实现 开机启动
linux·ubuntu·centos
ac.char15 小时前
在CentOS系统中查询已删除但仍占用磁盘空间的文件
linux·运维·centos
Viking_bird2 天前
centos 7.5 + Hadoop 3.2.4 集群搭建
linux·运维·服务器·hadoop·centos
大路谈数字化2 天前
Centos中内存CPU硬盘的查询
linux·运维·centos
焄塰3 天前
Ansible 管理变量和事实
学习·centos·ansible
炫友呀3 天前
Centos 更新/修改宝塔版本
linux·运维·centos
wml000003 天前
CentOS启动两个MySQL实例
mysql·centos·3406