需求:
chrony为全网提供时间同步服务器;
Server01、Server02、Server04、Client和Rserver应定期与其校正时间;
每隔1分钟自动校正一次时间。
步骤:
chrony服务器操作
安装chrony
apt install -y chrony
修改配置
mv /etc/chrony/chrony.conf /etc/chrony/chrony.conf.bak
vim /etc/chrony/chrony.conf
server 服务器ip
allow 允许连接的ip
local stratum 10 连接不到ntp服务器时,用本地时间同步时间
开启ntp同步
timedatectl set-ntp yes
server1配置
安装chrony和ntpdate
apt install -y chrony ntpdate
修改配置
vim /etc/chrony/chrony.conf
注释pool 2.debian.pool.ntp.org iburst
添加chrony服务器ip
server chrony服务器ip iburst
开启ntp同步
timedatectl set-net yes
添加定时任务
1分钟同步一次时间
vim /etc/crontab
测试
chrony服务器
查看连接的客户端
server01
查看连接的chrony服务器
^*状态正常
server01服务器查看时间
chrony服务器修改时间
server01服务器自动同步时间