A、安裝ntp
yum install -y ntp ntpdate
B、配置ntp.conf
sudo vi /etc/ntp.conf
文末添加:
server 192.168.111.200
wq儲存
亞洲網絡時鐘:
cat >> /etc/ntp.conf << EOF
server 0.asia.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
server 3.asia.pool.ntp.org
EOF
C、啟動ntp服務
## 需要禁掉chronyd.service 不然無法開機自啟
systemctl disable chronyd.service
systemctl start ntpd
systemctl enable ntpd.service
D、檢查狀态
systemctl status ntpd
E、修改硬體時間,保持和軟體NTP時間同步
hwclock -w
F、驗證服務
ntpq -p
G、手動同步一次
ntpdate -q 192.168.111.200
H、(可忽略)建立Job,自動運作,每天同步
00 01 * * * root /usr/sbin/ntpdate -q 192.168.111.200