- 安装ntp服务器
yum install -y ntp
- 关闭CentOS自带的chrony
systemctl stop chronyd.service
systemctl disable chronyd.service
- 修改ntp服务器配置文件
cat>/etc/ntp.conf<<'EOF'
driftfile /var/lib/ntp/drift
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
#restrict default nomodify notrap nopeer noquery
#允许本机访问
restrict 127.0.0.1
restrict ::1
#允许所有网段访问
restrict 0.0.0.0 netmask 0.0.0.0 nomodify nostrap
#上游时间服务器
server ntp.aliyun.com iburst
#上游时间服务器不可访问是,以本地为准正常运行提供ntp服务
server 127.127.1.0
fudge 127.127.1.0 stratum 10
disable monitor
#设定监听接口
interface listen 172.22.10.6
interface listen 127.0.0.1
EOF
sudo systemctl restart ntpd
- 手动更新时间
ntpdate -u -s ntp.aliyun.com
- 开通防火墙NTP端口
sudo firewall-cmd --add-service=ntp --permanent
sudo firewall-cmd --reload