《Linux之使用NTP服務(wù)管理/同步服務(wù)器時間》要點(diǎn):
本文介紹了Linux之使用NTP服務(wù)管理/同步服務(wù)器時間,希望對您有用。如果有疑問,可以聯(lián)系我們。
當(dāng)有多臺Web Server時,而且每臺服務(wù)器的時間需要保持一致,這時就可以考慮使用NTP 服務(wù)了.
1.先用用ntpstat查看一下NTP service當(dāng)前的狀態(tài).
#ntpstat
如果輸出下面內(nèi)容,說明還沒有啟動,需要設(shè)置服務(wù)器重啟時NTP服務(wù)自啟動:
Unable to talk to NTP daemon. Is it running?
如果輸出下面內(nèi)容說明已經(jīng)在工作了:
synchronised to NTP server (198.55.111.5) at stratum 3
time correct to within 238 ms
polling server every 64 s
如果輸出:unsynchronised, 需要重新啟動(ntpd restart)一下進(jìn)行同步.
2.使用ntpq -p查看NTP server列表
#ntpq -p
remote ? ? ? ? ? refid ? ? ?st t when poll reach ? delay ? offset ?jitter
==============================================================================
*dns1.synet.edu. 202.118.1.46 ? ? 2 u ? 46 ? 64 ?377 ? 19.924 ? 11.896 ? 5.692
+dns2.synet.edu. 202.118.1.46 ? ? 2 u ? 45 ? 64 ?317 ? 20.518 ? 11.833 ? 6.992
dns.sjtu.edu.cn .STEP. ? ? ? ? ?16 u ? ?– ? 64 ? ?0 ? ?0.000 ? ?0.000 ? 0.000
3.手動同步時間
#ntpdate
如果輸出下面內(nèi)容,說明ntp服務(wù)已經(jīng)啟動導(dǎo)致手動同步時間失敗,需要先停止ntp服務(wù):
the NTP socket is in use. exiting
#service ntpd stop
#ntpdate?cn.pool.ntp.org
如果輸出下面內(nèi)容,說明手動同步時間成功:
adjust time server xxx
最后記得將ntp服務(wù)啟動,讓他自動更新.
4.啟動NTP服務(wù)
#service ntpd start
Starting ntpd: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? [ ?OK ?]
Enable NTP to start at boot time with the chkconfig command.
5.開啟NTP自啟動
#chkconfig ntpd on
Verify that NTP is enabled with the following command.
6.檢查NTP自啟動情況
#chkconfig –list ntpd
ntpd ? ? ? ? ? 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Here ntpd is on in runlevels 2, 3, 4, and 5, which is correct.
7.自定義NTP server
參考這里.
文章素材來自ChinaUnix博客
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/4555.html