利用 chrony,配置 linux1 为其他 linux 主机提供 NTP 服务
server:
[root@linux ~]# yum -y install chrony #安装服务
[root@linux ~]# vim /etc/chrony.conf #进入配置文件
#pool 2.pool.ntp.org iburst #注释掉第三行
Server 10.2.220.10 iburst #第四行添加服务器主机的ip,iburst表示加急
allow 10.2.220.0/24 #在24行添加服务器ip的网段
local stratum 10 #在27行解释掉注释[root@linux ~]# systemctl restart chronyd #重启服务
[root@linux ~]# firewall-cmd --add-port=123/udp --per #防火墙对应端口
success[root@linux ~]# firewall-cmd --reload #重启防火墙
[root@client ~]# timedatectl #服务器
Local time: Tue 2023-06-06 06:04:43 EDT
Universal time: Tue 2023-06-06 10:04:43 UTC
RTC time: Tue 2023-06-06 10:04:43
Time zone: America/New_York (EDT, -0400)
System clock synchronized: no
NTP service: active
RTC in local TZ: no
client:
[root@client ~]# yum -y install chrony #安装服务
[root@client ~]# vim /etc/chrony.conf #进入配置文件
#pool 2.pool.ntp.org iburst #注释第三行
Server 10.2.220.101 iburst #在第四行添加服务器主机的ip
allow 10.2.220.0/24 #在24行删除注释,添加服务器ip的网段
local stratum 10 #在27行删除注释[root@client ~]# systemctl restart chronyd #删除注释
[root@client ~]# firewall-cmd --add-port=123/udp --per #开启防火墙对应端口
success[root@client ~]# timedatectl #客户端查看
Local time: Tue 2023-06-06 06:04:43 EDT
Universal time: Tue 2023-06-06 10:04:43 UTC
RTC time: Tue 2023-06-06 10:04:43
Time zone: America/New_York (EDT, -0400)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no完成