ntpd 時間同步

xiayulai發表於2009-02-09

前一段時間,有個機器配置了ntpd服務,結果時間還是不對,結果使用的gg找來問為什麼?我也不清楚,然後上去檢查一下:

root@xxxx:/root#ntpq -pn
remote refid st t when poll reach delay offset jitter
==============================================================================
*10.0.xx.xxx 127.127.1.0 11 u 126 128 377 0.293 0.030 0.007

發現,根本就沒有使用時間伺服器同步,而是以本地為準,之後重新找了幾個時間伺服器重新配置:

root@xxxx:/etc#vi ntp.conf

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.

restrict default nomodify notrap

# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.


# -- CLIENT NETWORK -------
# Permit systems on this network to synchronize with this
# time service. Do not permit those systems to modify the
# configuration of this service. Also, do not use those
# systems as peers for synchronization.
# restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap


server 61.xx.xx.xx
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org



# configuration of this service. Also, do not use those
# systems as peers for synchronization.
# restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap



server 61.xx.xx.xx
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org



restrict 61.xx.xx.xx mask 255.255.255.255
restrict 127.0.0.1

# --- NTP MULTICASTCLIENT ---
#multicastclient # listen on default 224.0.1.1





# --- GENERAL CONFIGURATION ---
#
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available. The
# default stratum is usually 3, but in this case we elect to use stratum
# 0. Since the server line does not have the prefer keyword, this driver
# is never used for synchronization, unless no other other
# synchronization source is available. In case the local host is
# controlled by some external source, such as an external oscillator or
# another protocol, the prefer keyword would cause the local host to
# disregard all other synchronization sources, unless the kernel
# modifications are in use and declare an unsynchronized condition.
#

#
# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
#
driftfile /var/lib/ntp/drift
"ntp.conf" 72L, 2649C written
root@xxxx:/etc#

完了,停止ntpd服務,否則的話埠被現有的服務佔有,無法同步

root@xxxx:/etc#service ntpd stop
Shutting down ntpd: [ OK ]

手工執行ntpdate 加上要使用的時間伺服器地址

root@xxxx:/etc#ntpdate 61.xx.xx.xx
9 Feb 09:38:05 ntpdate[8731]: step time server 61.xx.xx.xx offset 599.505333 sec

時間同步完成,啟動ntpd 服務。
root@xxxx:/etc#service ntpd start
ntpd: Synchronizing with time server: [ OK ]
Starting ntpd: [ OK ]
root@xxxx:/etc#

檢視一下時間同步的情況

root@xxxx:/root#ntpq -pn
remote refid st t when poll reach delay offset jitter
==============================================================================
+61.xx.xx.xx xxx.xx.xx.x 2 u 241 256 77 5.215 -20.446 0.017
221.130.196.230 0.0.0.0 16 u - 128 0 0.000 0.000 4000.00
*221.xx.xx.230 192.xx.xx.xx 2 u 72 256 247 113.303 46.281 4.569
+61.xx.xx.226 64.xx.xx.54 2 u 249 256 277 5.622 -18.847 0.956
看看是否是正常了呢。

[@more@]n

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7312700/viewspace-1017025/,如需轉載,請註明出處,否則將追究法律責任。

相關文章