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