Rocky Linux 8配置时间同步服务 chrony

发布时间 2023-09-23 15:33:01作者: wjzzzjq

我们需要再单独去安装 dnf install -y chrony,只需要配置对应的时间同步服务器即可。

服务器配置

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 10.32.186.70 iburst    //添加时间服务器

 

allow 10.32.186.0/24       //允许指定网段访问此时间服务器,不然只允许本地网络

local stratum 10          //本机不同步其它主机时间

 

# 设置时区为亚洲/上海

timedatectl set-timezone Asia/Shanghai

# 配置防火墙,也可以设置允许123/UDP端口

firewall-cmd --add-service=ntp
firewall-cmd --runtime-to-permanent

# 重启时间服务 & 查看服务启动状态

systemctl restart chronyd && systemctl status chronyd

# 设置开机自启动

systemctl enable chronyd

客户端配置

客户端配置与服务器端配置基本相同,但是因为客户端不需要接收来自其他主机的时间同步请求,因此不需要指定allow ***这行。
需要单独安装chrony服务。

# 我们可以使用`chronyd`命令手动将Linux服务器的时间与远程服务器进行同步。

chronyd -q 'server 10.32.186.70 iburst'

# 配置参数 /etc/chrony.conf

vi /etc/chrony.conf
server 10.32.186.70 iburst