第1章 ntp時間伺服器搭建
ntp(networktime protocol,網絡時間協定)是用來使網絡中的各個計算機時間同步的一種協定。它的用途是把計算機的時鐘同步到世界協調時utc,其精度在區域網路内可達0.1ms,在網際網路上絕大多數的地方其精度可以達到1-50ms。
ntp伺服器就是利用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
客戶機要等幾分鐘再與新啟動的ntp伺服器進行時間同步,否則會提示<code>no serversuitable for synchronization found</code>錯誤。
[root@zyops ~]# ntpdate 10.0.0.9
7 dec 18:40:16 ntpdate[1453]: step time server10.0.0.9 offset 40.880807 sec
# 将指令放入計劃任務即可。