# Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). #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
[root@m-01 ~]# ntpstat unsynchronised time server re-starting polling server every 8 s
[root@m-01 ~]# ntpstat synchronised to NTP server (120.25.115.20) at stratum 3 time correct to within 154 ms polling server every 64 s
三、客户端配置
3.1 安装 ntp、ntpdate
[root@web-01 ~]# yum install ntp ntpdate
3.2 修改配置文件
ntp 的配置文件路径为 /etc/ntp.conf 。
3.2.1 注释配置
# Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). #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
[root@web-01 zabbix]# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== 172.16.1.61 120.25.115.20 3 u 30 64 1 0.512 -42.740 0.000 localhost .INIT. 16 l - 64 0 0.000 0.000 0.000
四、验证 NTP 服务
4.1 查看 ntp 服务端时间
[root@m-01 ~]# date Sun Mar 29 00:10:52 CST 2020
4.2 修改客户端时间
[root@web-01 ~]# date -s 2020-01-01 Wed Jan 1 00:00:00 CST 2020 [root@web-01 ~]# date Wed Jan 1 00:00:03 CST 2020
4.3 同步服务端时间
实际上,等待一段时间后客户端时间会自动同步服务端时间,这里用手动同步验证下。
[root@web-02 ~]# ntpdate -u 172.16.1.61 29 Mar 00:12:14 ntpdate[19563]: adjust time server 172.16.1.61 offset 0.008159 sec [root@web-01 ~]# date Sun Mar 29 00:12:22 CST 2020