NTP服務

 

 經常使用軟件安裝及使用首頁html

 

NTP 時間服務器vim

原文:http://www.zyops.com/ntp/centos

ntp也是一種協議服務器

ntp軟件(支持ntp協議)  CentOS6自帶 CentOS7須要安裝的網絡

chrony軟件(支持ntp協議)   CentOS7自帶socket

1. NTP簡介

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

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

2. NTP服務器安裝

# 系統自帶ntp
[root@oldboyedu ~]# rpm -qa ntp
ntp-4.2.6p5-5.el6.centos.x86_64
# 若是沒有就安裝
yum -y install ntp

3. 配置NTP服務

[root@oldboyedu ~]# vim /etc/ntp.conf
# 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

4. 啓動NTP服務器

# 若是計劃任務有時間同步,先註釋,兩種用法會衝突。
[root@oldboyedu ~]# crontab -e
# time sync by oldboy at 2010-2-1
#*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1
[root@oldboyedu ~]# /etc/init.d/ntpd start
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 ~]# ntpdate 10.0.0.9
 7 Dec 18:43:07 ntpdate[26950]: the NTP socket is in use, exiting

5. 客戶機時間同步

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

[root@zyops ~]# ntpdate 10.0.0.9
 7 Dec 18:40:16 ntpdate[1453]: step time server 10.0.0.9 offset 40.880807 sec
 # 將命令放入計劃任務便可。
相關文章
相關標籤/搜索