1 时间同步主服务器,主服务器最好与北京时间同步如果没有网络连接那就设置好本地时间
# 设置东八区
timedatectl set-timezone Asia/Shanghai
# 安装ntp服务
apt install ntp
vim /etc/ntp.conf
# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1
# 添加这一行,允许内网同步
restrict 192.168.1.0 mask 255.255.255.0 nomodify
重启服务
systemctl restart ntp
2 时间同步从服务器,从主服务器同步时间
# 设置东八区
timedatectl set-timezone Asia/Shanghai
# 安装ntp服务
apt install ntp
vim /etc/ntp.conf
# 添加这一行,192.168.1.10为第一步主服务器的ip地址
server 192.168.1.10 prefer
重启服务
systemctl restart ntp