1. 選作一個機器作為ntp 服務端,例如 ip 為192.168.0.1
1)安裝 ntp服務
yum install ntp
2) 修改ntp.conf 文件
vi /etc/ntp.conf
注釋掉 #restrict 127.0.0.1
#restrict -6 ::1
#server 0.rhel.pool.ntp.org iburst
添加 server 192.168.0.1 iburst
server 127.127.1.0
fudge 127.127.1.0 stratum
3)保證防火牆關閉,或者放開端口 udp 123 ,啟動ntp
systemctl start ntpd
systemctl enable ntpd
systemctl status ntpd
4) ntpq -p 確定ntp是否正常
2. 安裝客戶端
1)yum -y install chrony(ps.該服務在Redhat7以上默認有)
2)vim /etc/chrony.conf
server 192.168.0.1 iburst
3) systemctl enable chronyd
4)systemctl restart chronyd.service
5) timedatectl 即可同步時間
ps.也可以手動同步時間:ntpdate -u 192.168.0.1 將其加入到定時任務中
timedatectl set-ntp true (開啟同步)