NTP: Network Time Protocol
当有多台Web Server时,而且每台服务器的时间需要保持一致,这时就可以考虑使用NTP 服务了。
1. 先用用ntpstat查看一下NTP service 当前的状态。
[root@ztweb103 ~]$ ntpstat
如果输出下面内容说明已经在工作了。
synchronised to NTP server (198.55.111.5) at stratum 3 time correct to within 238 ms polling server every 64 s
如果输出, “unsynchronised”, 需要重新启动(ntpd restart)一下进行同步.
如果输出, “Unable to talk to NTP daemon. Is it running?”, 应该是没有启动,可能还需要设置服务器重启时NTP服务自启动.2. 使用 “ntpq -p” 查看 NTP server 列表
[root@ztweb103 ~]$ ntpq -p remote refid st t when poll reach delay offset jitter==============================================================================*dns1.synet.edu. 202.118.1.46 2 u 46 64 377 19.924 11.896 5.692+dns2.synet.edu. 202.118.1.46 2 u 45 64 317 20.518 11.833 6.992 dns.sjtu.edu.cn .STEP. 16 u - 64 0 0.000 0.000 0.000
3. 启动NTP服务
[root@ztweb103 ~]$ sudo service ntpd startStarting ntpd: [ OK ]Enable NTP to start at boot time with the chkconfig command.
4. 开启NTP自启动
[root@ztweb103 ~]$ sudo chkconfig ntpd onVerify that NTP is enabled with the following command.
5. 检查NTP自启动情况
[root@ztweb103 ~]$ sudo chkconfig --list ntpdntpd 0:off1:off2:on3:on4:on5:on6:offHere ntpd is on in runlevels 2, 3, 4, and 5, which is correct.
6. 自定义NTP server 参考: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html
原文地址:使用NTP服务管理/同步服务器时间, 感谢原作者分享。 最好的节约是珍惜时间,最大的浪费是虚度年华。