NTP服务器配置
服务器的配置文件/etc/ntp.conf
注释server域名配置
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
设置本机为ntp服务端
server 127.127.1.0
fudge 127.127.1.0 stratum 10
NTP客户端配置
客户端的配置文件/etc/ntp.conf设置服务器信息
server 服务端主机名
NTP服务自动停止
systemctl status ntpd
Apr 28 11:50:08 jianghuihui02 ntpd[6145]: 0.0.0.0 c617 07 panic_stop -2510 s; set clock manually within 1000 s.
Apr 28 11:50:08 jianghuihui02 systemd[1]: ntpd.service: main process exited, code=exited, status=255/n/a
Apr 28 11:50:08 jianghuihui02 systemd[1]: Unit ntpd.service entered failed state.
Apr 28 11:50:08 jianghuihui02 systemd[1]: ntpd.service failed.
客户端的时间与服务端的时间超过1000s,那么ntp进程就会退出并在系统日志文件中记录。
解决方法:
在配置文件/etc/ntp.conf中增加一行:
tinker panic 0
使ntp在时间差较大时依然工作
查看ntp同步情况
命令: ntpq -p
查看主机硬件时间
查看硬件时间:hwclock
将硬件时间同步到系统时间:hwclock -s
将系统时间同步到硬件时间:hwclock -w