自学[vue+SpringCloud]-007-同步Linux虚拟机时间


前言

三台机器的时间需要保持一致。


一、安装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台机器做集群时,需要时间互相保持一致。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值