1.设定实验环境
时间同步服务器:
IP:172.25.254.100
火墙:关闭
root@node1 \~# systemctl disable --now firewalld #关闭防火墙
root@node1 \~# systemctl mask firewalld #锁定
Created symlink /etc/systemd/system/firewalld.service → /dev/null.
客户端:
IP:172.25.254.200
火墙:不做要求
确保此主机能和172.25.254.100通信
ping 172.25.254.100 #测试两台机器是否能够通信
2.配置时间同步服务器服务端
在172.25.254.100主机中
安装服务
root@node1 \~# dnf install chrony -y
正在更新 Subscription Management 软件仓库。
无法读取客户身份
本系统尚未在权利服务器中注册。可使用 "rhc" 或 "subscription-manager" 进行注册。
上次元数据过期检查:0:30:22 前,执行于 2026年07月16日 星期四 14时18分20秒。
软件包 chrony-4.6.1-1.el9.x86_64 已安装。
依赖关系解决。
无需任何处理。
完毕!
编写时间服务器配置文件
root@node1 \~# vim /etc/chrony.conf
#pool 2.rhel.pool.ntp.org iburst
Allow NTP client access from local network.
allow 0.0.0.0/0 #放宽条件
Serve time even if not synchronized to a time source.
local stratum 10
root@node1 \~# systemctl stop chronyd.service #暂停时间同步服务
root@node1 ~]# timedatectl set-time "2026-11-11 11:11:11" #设定时间,后续客户端需同步此时间
root@node1 \~# timedatectl #查看是否修改成功
Local time: 三 2026-11-11 11:11:14 CST
Universal time: 三 2026-11-11 03:11:14 UTC
RTC time: 三 2026-11-11 03:11:14
Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: no
root@node1 \~# systemctl start chronyd #开启时间同步服务
在客户端测试
root@node2 \~# dnf install chrony -y
root@node2 \~# vim /etc/chrony.conf
pool 172.25.254.100 iburst
root@node2 \~# systemctl restart chronyd
root@node2 \~# chronyc sources -v
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current best, '+' = combined, '-' = not combined,
| / 'x' = may be in error, '~' = too variable, '?' = unusable.
|| .- 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
===============================================================================
^* 172.25.254.100 10 6 17 7 +5972ns+1668ns +/- 119us
root@node2 \~# date
2026年 11月 11日 星期三 11:12:25 CST