在一台centos最小化安装的机器上面,yum -y install ntpdate安装ntpdate同步时间。然而执行ntpdate -u ntp.sjtu.edu.cn的时候,死活调不了时间。并报以下错误
30 Oct 23:30:56 ntpdate[8200]: no server suitable for synchronization found
执行:ntpdate -d ntp.sjtu.edu.cn 命令调试的时候,出现一下信息:
30 Oct 23:26:54 ntpdate[8183]: ntpdate [email protected] Sat Nov 23 18:21:48 UTC 2013 (1)
Looking for host ntp.sjtu.edu.cn and service ntp
host found : 202.120.2.100
transmit(202.120.2.100)
transmit(202.120.2.100)
transmit(202.120.2.100)
transmit(202.120.2.100)
transmit(202.120.2.100)
202.120.2.100: Server dropped: no data
“......以下信息略”
30 Oct 23:27:33 ntpdate[8183]: no server suitable for synchronization found
百度了几遍,搜出来的东西都一个样子的,复制来复制去。根本解决不了我的问题。无意中解决了这个问题。分享一下,供大家参考。
在外网另外一台机器上面,同步时间正常,执行的ntpdate -d ntp.sjtu.edu.cn调试,输出以下调试信息
17 Dec 00:17:19 ntpdate[26682]: ntpdate [email protected] Tue May 31 10:09:22 UTC 2016 (1)
Looking for host cn.ntp.org.cn and service ntp
host found : time5.aliyun.com
transmit(182.92.12.11)
receive(182.92.12.11)
transmit(182.92.12.11)
receive(182.92.12.11)
transmit(182.92.12.11)
receive(182.92.12.11)
transmit(182.92.12.11)
receive(182.92.12.11)
server 182.92.12.11, port 123
stratum 2, precision -24, leap 00, trust 000
refid [182.92.12.11], delay 0.06557, dispersion 0.00020
transmitted 4, in filter 4
reference time: dbfe91f0.e0ab0269 Sat, Dec 17 2016 0:16:48.877
originate timestamp: dbfe920f.cce69aec Sat, Dec 17 2016 0:17:19.800
transmit timestamp: dbfe920f.c9ccaaf5 Sat, Dec 17 2016 0:17:19.788
filter delay: 0.06631 0.06557 0.06557 0.06583
0.00000 0.00000 0.00000 0.00000
filter offset: -0.00835 -0.00782 -0.00800 -0.00801
0.000000 0.000000 0.000000 0.000000
delay 0.06557, dispersion 0.00020
offset -0.007821
17 Dec 00:17:19 ntpdate[26682]: adjust time server 182.92.12.11 offset -0.007821 sec
发现同样的ntp.sjtu.edu.cn域名,解析出来的IP居然不一样!!!!
然后在同步时间有问题的那台机器上面这样执行:ntpdate -d 182.92.12.11
17 Dec 00:22:12 ntpdate[4876]: ntpdate [email protected] Mon Nov 14 18:25:09 UTC 2016 (1)
Looking for host 182.92.12.11 and service ntp
host found : time5.aliyun.com
^[[C^[[Atransmit(182.92.12.11)
receive(182.92.12.11)
transmit(182.92.12.11)
receive(182.92.12.11)
transmit(182.92.12.11)
receive(182.92.12.11)
transmit(182.92.12.11)
receive(182.92.12.11)
server 182.92.12.11, port 123
stratum 2, precision -24, leap 00, trust 000
refid [182.92.12.11], delay 0.11998, dispersion 0.02696
transmitted 4, in filter 4
reference time: dbfe9340.e0a6e895 Sat, Dec 17 2016 0:22:24.877
originate timestamp: dbfe9341.f1042a0c Sat, Dec 17 2016 0:22:25.941
transmit timestamp: dbfe933a.876de705 Sat, Dec 17 2016 0:22:18.529
filter delay: 0.11998 0.28513 0.22147 0.13644
0.00000 0.00000 0.00000 0.00000
filter offset: 7.335746 7.322472 7.394457 7.357022
0.000000 0.000000 0.000000 0.000000
delay 0.11998, dispersion 0.02696
offset 7.335746
17 Dec 00:22:18 ntpdate[4876]: step time server 182.92.12.11 offset 7.335746 sec
奇迹出现了,居然同步到时间了!不知道为什么会解析到那个IP上面,不知道是dns解析到错误的IP,还是那个IP不能同步时间。反正就是换个IP就能解决。
另外,ntp服务使用的是utp的123端口,如果端口被限制,也无法同步。可以执行
1.service ntpd stop
2.nc -ul 123 和 nc -u $server_ip 123进行端口测试
参考:https://blog.csdn.net/zyy247796143/article/details/53701085/