NTP時間服務器搭建

1. NTP

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

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

2. NTP器安裝

    yum -y install ntp

 vim /etc/ntp.conf

 允許任何ip的客戶機都可以進行時間同步

 將restrict default kod nomodify notrap nopeer noquery修改爲如下行:

 Restrict default nomodify  #nomodify客戶端可以同步

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

#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

server ntp1.aliyun.com

server time.nist.gov

加入定時任務同步時間

 crontab -e

    */5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1  

    /etc/init.d/ntpd start

    chkconfig ntpd on 

    ntpq -p        ntpstat     #看同步狀態

3客時間同步

 crontab -e

 */15 * * * * /usr/sbin/ntpdate 192.168.100.102(服務器端IP)

  注意

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


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