ntpdate同步更新時間

 Linux服務器運行久時,系統時間就會存在必定的偏差,通常狀況下能夠使用date命令進行時間設置,但在作數據庫集羣分片等操做時對多臺機器的時間差是有要求的,此時就須要使用ntpdate進行時間同步數據庫

一、安裝ntpdate

yum install ntpdate -y

ntpdate簡單用法:windows

# ntpdate ip
# ntpdate 210.72.145.44

二、date命令

date :查看當前時間,結果以下:Tue Mar 4 01:36:45 CST 2014
date -s 09:38:40 :設置當前時間,結果以下:Tue Mar 4 09:38:40 CST 2014

三、ntpdate命令

ntpdate -u 210.72.145.44 :網絡時間同步命令

 注意:若不加上-u參數, 會出現如下提示:no server suitable for synchronization foundapi

-u:從man ntpdate中能夠看出-u參數能夠越過防火牆與主機同步;
210.72.145.44:中國國家授時中心的官方服務器。

四、ntp經常使用服務器

中國國家授時中心:210.72.145.44
NTP服務器(上海) :ntp.api.bz

經測試中國國家授時中心與NTP上海服務器能夠正常同步時間,注意須要加上-u參數!服務器

ntpdate -u ntp.api.bz
ntpdate -u 210.72.145.44

國外:網絡

美國:time.nist.gov 
復旦:ntp.fudan.edu.cn 
微軟公司授時主機(美國) :time.windows.com 
臺警大授時中心(臺灣):asia.pool.ntp.org

五、加入crontab

echo "*/20 * * * * /usr/sbin/ntpdate -u ntp.api.bz >/dev/null &" >> /var/spool/cron/root

如下是一些可用的NTP服務器地址:測試

Nameui

IP Location
210.72.145.44 210.72.145.44 中國(國家授時中心)
133.100.11.8 133.100.11.8 日本(福岡大學)
time-a.nist.gov 129.6.15.28 NIST,Gaithersburg,Maryland
time-b.nist.gov 129.6.15.29 NIST,Gaithersburg,Maryland
time-a.timefreq.bldrdoc.gov 132.163.4.101 NIST,Boulder,Colorado
time-b.timefreq.bldrdoc.gov 132.163.4.102 NIST,Boulder,Colorado
time-c.timefreq.bldrdoc.gov 132.163.4.103 NIST,Boulder,Colorado
utcnist.colorado.edu 128.138.140.44 UniversityofColorado,Boulder
time.nist.gov 192.43.244.18 NCAR,Boulder,Colorado
time-nw.nist.gov 131.107.1.10 Microsoft,Redmond,Washington
nist1.symmetricom.com 69.25.96.13 Symmetricom,SanJose,California
nist1-dc.glassey.com 216.200.93.8 Abovenet,Virginia
nist1-ny.glassey.com 208.184.49.9 Abovenet,NewYorkCity
nist1-sj.glassey.com 207.126.98.204 Abovenet,SanJose,California
nist1.aol-ca.truetime.com 207.200.81.113 TrueTime,AOLfacility,Sunnyvale,California
nist1.aol-va.truetime.com 64.236.96.53 TrueTime,AOLfacility,Virginia
相關文章
相關標籤/搜索