linux ntp時間同步配置

第1章 ntp時間服務器搭建

1.1ntp簡介

 

NTP(NetworkTime Protocol,網絡時間協議)是用來使網絡中的各個計算機時間同步的一種協議。它的用途是把計算機的時鐘同步到世界協調時UTC,其精度在局域網內可達0.1ms,在互聯網上絕大多數的地方其精度可以達到1-50ms。

NTP服務器就是利用NTP協議提供時間同步服務的。

 

1.2NTP服務器安裝

1.  # 系統自帶ntp
2.  [root@oldboyedu ~]# rpm -qa ntp
3.  ntp-4.2.6p5-5.el6.centos.x86_64
4.  # 如果沒有就安裝
5.  yum -y install ntp

1.3 配置ntp時間服務器

 

[root@oldboyedu ~]# vim/etc/ntp.conf

# restrict default kod nomodifynotrap nopeer noquery

restrict default nomodify

# nomodify客戶端可以同步

# 將默認時間同步源註釋改用可用源

# server 0.centos.pool.ntp.orgiburst

# server 1.centos.pool.ntp.orgiburst

# server 2.centos.pool.ntp.orgiburst

# server 3.centos.pool.ntp.orgiburst

server ntp1.aliyun.com

server time.nist.gov

 

啓動NTP服務器

 

[root@oldboyedu ~]# /etc/init.d/ntpdstart

Starting ntpd:                                            [  OK  ]

[root@oldboyedu ~]# ntpq -p

     remote           refid      st t when poll reach   delay  offset  jitter

==============================================================================

*ntp1.aliyun.com 10.137.38.86     2 u  22   64    1 525.885  -42.367   0.000

[root@oldboyedu ~]# ntpstat

synchronised to NTP server(110.75.186.247) at stratum 3

  time correct to within 4257 ms

  polling server every 64 s

[root@oldboyedu ~]# ntpdate10.0.0.9

 7 Dec 18:43:07 ntpdate[26950]: the NTP socketis in use, exiting


1.4客戶機時間同步

客戶機要等幾分鐘再與新啓動的ntp服務器進行時間同步,否則會提示no serversuitable for synchronization found錯誤。

[root@zyops ~]# ntpdate 10.0.0.9

 7 Dec 18:40:16 ntpdate[1453]: step time server10.0.0.9 offset 40.880807 sec

 # 將命令放入計劃任務即可。

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章