最近搞了一台PC來取代原有的web server. 裝好CentOS後, 並順利的將原web server轉移到此台PC.
起初, 還蠻順利的將server轉移過來. 今天連上這台server時, 才發現時間誤差了8小時!!
我記得當初裝CentOS時, 在第一次啟動畫面時有設定ntp啊, 怎會時間會錯掉??
再次執行system-config-date, 發現ntp並未啟用. 怪怪!! 難道是我老了, 記憶力衰退了嗎.
不管, 將』Enable Network time Protocol』 打勾, 並設定台灣的ntp server: time.stdtime.gov.tw
如下圖:
嗯, 設定完之後, 便回到console, 用ntpstat來看看狀態.
當然, 一開始ntpstat回報如下:
unsynchronised
time server re-starting
polling server every 64 s
所以, 就先離開, 等一會再回來試.
幾分鐘, 回來再下ntpstat, 竟然出現如下訊息:
Unable to talk to NTP daemon. Is it running?
啥?!! ntp daemon為何停掉了??
不甘心, 又執行了system-config-date, 發現』Enable Network time Protocol』 沒有打勾. 見鬼了耶!! 我剛剛腦袋有秀斗嗎?
又再次勾一便. 這次就在螢幕面前用ntpstat一直等.
真的沒想到, 1分鐘後ntp daemon就又不見了.
是哪裡的問題呢?? 這台電腦才剛灌好沒多久, 沒有啥特別的設定啊…
搞了一陣子後, 最後在/var/log/message中發現如下的訊息:
Jun 11 22:23:48 hns2 ntpd[14847]: ntpd 4.2.2p1@1.1570-o Tue May 19 13:58:05 UTC 2009 (1)
Jun 11 22:23:48 hns2 ntpd[14848]: precision = 1.000 usec
Jun 11 22:23:48 hns2 ntpd[14848]: Listening on interface wildcard, 0.0.0.0#123 Disabled
Jun 11 22:23:48 hns2 ntpd[14848]: Listening on interface wildcard, ::#123 Disabled
Jun 11 22:23:48 hns2 ntpd[14848]: Listening on interface lo, ::1#123 Enabled
Jun 11 22:23:48 hns2 ntpd[14848]: Listening on interface eth0, fe80::230:1bff:fe82:9213#123 Enabled
Jun 11 22:23:48 hns2 ntpd[14848]: Listening on interface lo, 127.0.0.1#123 Enabled
Jun 11 22:23:48 hns2 ntpd[14848]: Listening on interface eth0, 192.168.7.3#123 Enabled
Jun 11 22:23:48 hns2 ntpd[14848]: kernel time sync status 0040
Jun 11 22:23:48 hns2 ntpd[14848]: frequency initialized 97.927 PPM from /var/lib/ntp/drift
Jun 11 22:26:59 hns2 ntpd[14848]: synchronized to LOCAL(0), stratum 10
Jun 11 22:26:59 hns2 ntpd[14848]: kernel time sync disabled 0001
Jun 11 22:28:06 hns2 ntpd[14848]: synchronized to 220.130.158.52, stratum 2
Jun 11 22:28:06 hns2 ntpd[14848]: time correction of -28800 seconds exceeds sanity limit (1000); set clock manually to the correct UTC time.
請注意最後一行!!! 啥?? 時間誤差太多, ntp竟然無法同步?? 這真的是我第一次遇到!!
好吧, 只好手動將時間調到正常的時間. 用date指令確定時間正常後, 再一次的啟動ntp daemon.
就OK! 真的是又學到一些經驗了~~