加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Linux之使用NTP服务管理/同步服务器时间

发布时间:2020-12-15 04:57:17 所属栏目:安全 来源:网络整理
导读:《Linux之使用NTP服务管理/同步服务器时间》要点: 本文介绍了Linux之使用NTP服务管理/同步服务器时间,希望对您有用。如果有疑问,可以联系我们。 当有多台Web Server时,而且每台服务器的时间需要保持一致,这时就可以考虑使用NTP 服务了. 1.先用用ntpstat查

《Linux之使用NTP服务管理/同步服务器时间》要点:
本文介绍了Linux之使用NTP服务管理/同步服务器时间,希望对您有用。如果有疑问,可以联系我们。

当有多台Web Server时,而且每台服务器的时间需要保持一致,这时就可以考虑使用NTP 服务了.

1.先用用ntpstat查看一下NTP service当前的状态.
#ntpstat
如果输出下面内容,说明还没有启动,需要设置服务器重启时NTP服务自启动:
Unable to talk to NTP daemon. Is it running?
如果输出下面内容说明已经在工作了:
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)一下进行同步.

2.使用ntpq -p查看NTP server列表

#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.手动同步时间
#ntpdate
如果输出下面内容,说明ntp服务已经启动导致手动同步时间失败,需要先停止ntp服务:
the NTP socket is in use. exiting
#service ntpd stop
#ntpdate?cn.pool.ntp.org
如果输出下面内容,说明手动同步时间成功:
adjust time server xxx
最后记得将ntp服务启动,让他自动更新.

4.启动NTP服务
#service ntpd start
Starting ntpd: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [ ?OK ?]
Enable NTP to start at boot time with the chkconfig command.

5.开启NTP自启动
#chkconfig ntpd on
Verify that NTP is enabled with the following command.

6.检查NTP自启动情况
#chkconfig –list ntpd
ntpd ? ? ? ? ? 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Here ntpd is on in runlevels 2,3,4,and 5,which is correct.

7.自定义NTP server
参考这里.

 

文章素材来自ChinaUnix博客

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读