第一章部署 chrony服务器

时间同步chrony--ntp-123/udp

准备工作:

bash 复制代码
# 临时停止防火墙
systemctl stop firewalld
# 禁止防火墙开机启动(永久生效)
systemctl disable firewalld
# 验证防火墙状态(确保显示inactive)
systemctl status firewalld
# 临时关闭SELinux(重启失效)
setenforce 0
# 验证SELinux状态
getenforce

遇到问题:

bash 复制代码
bash-5.1# setenforce 0
bash: setenforce:未找到命令

setenforce 0
sestatus
ash-5.1# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Memory protection checking:     actual (secure)
Max kernel policy version:      33
setenforce 0

#ok成功

实验1:当前主机通过外网ntp.aliyun.com时间服务器进行同步

客户端环境要求:访问外网 --- nat

客户端:chrony

vim /etc/chrony.conf

pool 时间服务器主机的ip或者域名 ibusrt 启动软件读取配置(发起时间同步请求)

systemctl restart chronyd

实验2: 通过自构建的时间服务器主机给客户端主机同步时间

服务器:

bash 复制代码
# 安装Chrony
yum install chrony -y

# 打开配置文件
vim /etc/chrony.conf

# -------------- 配置文件修改内容 --------------

server ntp.aliyun.com iburst 
allow 10.211.55.6/24  # 允许该网段所有客户端同步服务端时间
driftfile /var/lib/chrony/drift  # 记录时间漂移,优化后续同步
makestep 1.0 3  # 若时间偏差>1秒,前3次更新允许"跳变"修正
rtcsync  # 启用硬件时钟(RTC)与系统时钟同步
# ---------------------------------------------

:wq


systemctl restart chronyd
systemctl enable chronyd
systemctl status chronyd

客户端:

bash 复制代码
yum install chrony -y
chronyc -v

vim /etc/chrony.conf

# -------------- 配置文件修改内容 --------------
# 1. 删除默认的pool地址,添加服务端IP作为时间源
server 10.211.55.6 iburst 

driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
# ---------------------------------------------

:wq 

systemctl restart chronyd
systemctl enable chronyd
systemctl status chronyd
相关推荐
小草cys6 小时前
在 openEuler 上安装 DDE 图形桌面环境(适用于华为鲲鹏服务器/PC)
运维·服务器
天才奇男子13 小时前
HAProxy高级功能全解析
linux·运维·服务器·微服务·云原生
小李独爱秋13 小时前
“bootmgr is compressed”错误:根源、笔记本与台式机差异化解决方案深度指南
运维·stm32·单片机·嵌入式硬件·文件系统·电脑故障
❀͜͡傀儡师14 小时前
centos 7部署dns服务器
linux·服务器·centos·dns
Dying.Light14 小时前
Linux部署问题
linux·运维·服务器
S190114 小时前
Linux的常用指令
linux·运维·服务器
萤丰信息14 小时前
AI 筑基・生态共荣:智慧园区的价值重构与未来新途
大数据·运维·人工智能·科技·智慧城市·智慧园区
小义_15 小时前
【RH134知识点问答题】第7章 管理基本存储
linux·运维·服务器
运维小欣15 小时前
Agentic AI 与 Agentic Ops 驱动,智能运维迈向新高度
运维·人工智能
_运维那些事儿16 小时前
VM环境的CI/CD
linux·运维·网络·阿里云·ci/cd·docker·云计算