1. 基础命令
yum -y install ntp ntpdate
systemctl disable chronyd
systemctl start ntpd
firewall-cmd --zone=public --add-port=123/udp --permanent
firewall-cmd --reload
ntpdate cn.pool.ntp.org
2. 配置服务端
vim /etc/ntp.conf
restrict 172.22.10.6 nomodify notrap nopeer noquery //当前节点IP地址
restrict 172.22.10.0 mask 255.255.255.0 nomodify notrap //集群所在网段、掩码、权限
server 127.127.1.0
fudge 127.127.1.0 stratum 10
interface ignore wildcard
interface listen 172.22.10.6
interface listen 127.0.0.1
3. 配置客户端
1. 简单版
server 4.centos.pool.ntp.org iburst
2. 详细版(不熟)
1)修改配置文件
vim /etc/ntp.conf
restrict 172.22.10.92 nomodify notrap nopeer noquery //当前节点IP地址
restrict 172.22.10.0 mask 255.255.255.0 nomodify notrap //集群所在网段的网段(Gateway),子网掩码(Genmask)
server 172.22.10.6 iburst //NTP服务器IP地址,可以注释掉别的server或者在需要配置的ntp服务器后添加perfer--优先,提高优先级,如:server 172.22.10.6 perfer iburst
fudge 172.22.10.6 stratum 10 //NTP服务器层级设置
2)预先同步一次时间(先关闭ntpd服务)
ntpdate 172.22.10.6