CentOS6.9中ntpdate命令无法同步网络时间

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

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 found

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


此时被坑:

210.72.145.44:中国国家授时中心的官方服务器。加上-u参数依然出现:no server suitable for synchronization found

[root@oldboyedu41-1~]#ntpdate-u210.72.145.44
30Sep10:57:00ntpdate[7383]:noserversuitableforsynchronizationfound
[root@oldboyedu41-1~]#ntpdate-untp.fudan.edu.cn
30Sep10:57:20ntpdate[7384]:noserversuitableforsynchronizationfound

使用-d参数查看:

[root@oldboyedu41-1 ~]# ntpdate -d 210.72.145.44

12 Oct 11:08:48 ntpdate[7489]: ntpdate 4.2.6p5@1.2349-o Mon Feb 6 07:22:46 UTC 2017 (1)

Looking for host 210.72.145.44 and service ntp

host found : 210.72.145.44

transmit(210.72.145.44)

transmit(210.72.145.44)

transmit(210.72.145.44)

transmit(210.72.145.44)

transmit(210.72.145.44)

210.72.145.44: Server dropped: no data

server 210.72.145.44,port 123

stratum 0,precision 0,leap 00,trust 000

refid [210.72.145.44],delay 0.00000,dispersion 64.00000

transmitted 4,in filter 4

reference time: 00000000.00000000 Mon,Jan 1 1900 8:05:43.000

originate timestamp: 00000000.00000000 Mon,Jan 1 1900 8:05:43.000

transmit timestamp: dd895b44.121faac4 Thu,Oct 12 2017 11:08:52.070

filter delay: 0.00000 0.00000 0.00000 0.00000

0.00000 0.00000 0.00000 0.00000

filter offset: 0.000000 0.000000 0.000000 0.000000

0.000000 0.000000 0.000000 0.000000

delay 0.00000,dispersion 64.00000

offset 0.000000

12 Oct 11:08:53 ntpdate[7489]: no server suitable for synchronization found


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

[root@oldboyedu41-1 ~]# ntpdate -u ntp.api.bz

12 Oct 10:57:09 ntpdate[7385]: step time server 115.28.122.198 offset 1036740.838009 sec

[root@oldboyedu41-1 ~]# date

Thu Oct 12 10:57:20 CST 2017


ntpdate -d 也正常了:

[root@oldboyedu41-1 ~]# ntpdate -d ntp.api.bz

12 Oct 11:12:46 ntpdate[7495]: ntpdate 4.2.6p5@1.2349-o Mon Feb 6 07:22:46 UTC 2017 (1)

Looking for host ntp.api.bz and service ntp

host found : time6.aliyun.com

transmit(115.28.122.198)

receive(115.28.122.198)

transmit(115.28.122.198)

receive(115.28.122.198)

transmit(115.28.122.198)

transmit(115.28.122.198)

receive(115.28.122.198)

server 115.28.122.198,32);">stratum 2,precision -24,trust 000

refid [115.28.122.198],delay 0.09003,dispersion 8.00105

transmitted 4,in filter 4

reference time: dd895bdd.5ccd6f6b Thu,Oct 12 2017 11:11:25.362

originate timestamp: dd895c2f.62a52b8d Thu,Oct 12 2017 11:12:47.385

transmit timestamp: dd895c2f.58a80a6d Thu,Oct 12 2017 11:12:47.346

filter delay: 0.09056 0.10063 0.00000 0.09003

0.00000 0.00000 0.00000 0.00000

filter offset: 0.006100 0.009650 0.000000 0.006793

0.000000 0.000000 0.000000 0.000000

delay 0.09003,dispersion 8.00105

offset 0.006793

12 Oct 11:12:47 ntpdate[7495]: adjust time server 115.28.122.198 offset 0.006793 sec

――――――――――――――――――――――――――――――――――――――――

没想到中国国家授时中心的官方服务器竟然不可用,也许是跟我们公司使用VPN有关系吧。

另外保留几个常用的服务器:

210.72.145.44 中国国家授时中心

ntp.fudan.edu.cn 复旦大学

ntp.api.bz

0.pool.ntp.org

133.100.11.8 日本 福冈大学

time.windows.com

相关文章

linux下开机自启: 在/etc/init.d目录下新建文件elasticsear...
1、因为在centos7中/etc/rc.d/rc.local的权限被降低了,所以...
最简单的查看方法可以使用ls -ll、ls-lh命令进行查看,当使用...
ASP.NET Core应用程序发布linux在shell中运行是正常的。可一...
设置时区(CentOS 7) 先执行命令timedatectl status|grep &...
vim /etc/sysconfig/network-scripts/ifcfg-eth0 B...