ntpdate同步更新时间

ntpdate同步更新时间

知识预览

 Linux服务器运行久时,系统时间就会存在一定的误差,一般情况下可以使用date命令进行时间设置,但在做数据库集群分片等操作时对多台机器的时间差是有要求的,此时就需要使用ntpdate进行时间同步

回到顶部

1、安装ntpdate

1

yum install ntpdate -y

ntpdate简单用法:

1

2

# ntpdate ip

# ntpdate 210.72.145.44

回到顶部

2、date命令

1

2

date :查看当前时间,结果如下:Tue Mar 4 01:36:45 CST 2014

date -s 09:38:40 :设置当前时间,结果如下:Tue Mar 4 09:38:40 CST 2014

回到顶部

3、ntpdate命令

1

ntpdate -u 210.72.145.44 :网络时间同步命令

 注意:若不加上-u参数, 会出现以下提示:no server suitable for synchronization found

1

2

-u:从man ntpdate中可以看出-u参数可以越过防火墙与主机同步;

210.72.145.44:中国国家授时中心的官方服务器。

回到顶部

4、ntp常用服务器

1

2

中国国家授时中心:210.72.145.44

NTP服务器(上海) :ntp.api.bz

经测试中国国家授时中心与NTP上海服务器可以正常同步时间,注意需要加上-u参数!

1

2

ntpdate -u ntp.api.bz

ntpdate -u 210.72.145.44

国外:

1

2

3

4

美国:time.nist.gov

复旦:ntp.fudan.edu.cn

微软公司授时主机(美国) :time.windows.com

台警大授时中心(台湾):asia.pool.ntp.org

回到顶部

5、加入crontab

1

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

以下是一些可用的NTP服务器地址:

Name

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

猜你喜欢

转载自blog.csdn.net/qq_37960324/article/details/85044376