前言
三台机器的时间需要保持一致。
一、安装chrony
sudo dnf install chrony
二、在bztc110上修改配置文件
vim /etc/chrony.conf
原配置文件:
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (https://www.pool.ntp.org/join.html).
pool 2.centos.pool.ntp.org iburst
# Use NTP servers from DHCP.
sourcedir /run/chrony-dhcp
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
..........
修改为:
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (https://www.pool.ntp.org/join.html).
#pool 2.centos.pool.ntp.org iburst
server ntp.aliyun.com iburst
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
server ntp4.aliyun.com iburst
server ntp5.aliyun.com iburst
# Use NTP servers from DHCP.
sourcedir /run/chrony-dhcp
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
..........
三、将配置文件同步到其他机器
data_rsync.sh /etc/chrony.conf
四、启动和启用 chronyd 服务
启动 chronyd 服务并设置为开机自启:
sudo systemctl start chronyd
# 有的已启动,需要重启下
sudo systemctl restart chronyd
sudo systemctl enable chronyd
五、验证时间同步
chronyc sources -v
三台机器都应如下图:
ntp.aliyun.com对应的ip是:203.107.6.88
总结
以后3台机器做集群时,需要时间互相保持一致。