CentOS架設NTP時間伺服器
1. NTP簡介NTP(Network Time Protocol,網路時間協議)是用來使網路中的各個電腦時間同步的一種協議。它的用途是把電腦的時鐘同步到世界協調時UTC,其精度在區域網路內可達0.1ms,在互連網上絕大多數的地方其精度可以達到1-50ms。
NTP伺服器就是利用NTP協議提供時間同步服務的。
2. NTP伺服器安裝#系統內建ntp
[root@xuliangwei
~]# rpm -qa ntp
ntp-4.2.6p5-5.el6.centos.x86_64
#如果沒有就安裝
yum -y
install ntp3.配置NTP服務[root@xuliangwei
~]# 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.gov4.啟動NTP伺服器#如果計劃任務有時間同步,先注釋,兩種用法會衝突。
[root@xuliangwei
~]# crontab -e
# time
sync by oldboy at 2010-2-1
#*/5 *
* * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1
[root@xuliangwei
~]# /etc/init.d/ntpd start
Starting
ntpd:[ OK ]
[root@oldboyedu
~]# ntpq -p
remote refid st t when poll reach delayoffset jitter
==============================================================================
*ntp1.aliyun.com
10.137.38.86 2 u 2264 1 525.885-42.367 0.000
[root@xuliangwei
~]# ntpstat
synchronised
to NTP server (110.75.186.247) at stratum 3
time correct to within 4257 ms
polling server every 64 s
[root@xuliangwei
~]# ntpdate 10.0.0.9
7 Dec 18:43:07 ntpdate[26950]: the NTP socket
is in use, exiting5.客戶機時間同步客戶機要等幾分鐘再與新啟動的ntp伺服器進行時間同步,否則會提示noserver suitable for synchronization found錯誤。
[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
#將命令放入計劃任務即可。