我的时钟不准,所以我想用ntpdate来进行同步。我尝试了几个不同的NTP服务器,但是不知何故,我总是收到以下错误信息:
从这篇文章中: 我得到的想法是,在我的工作场所,我的电脑/网络可能被阻止了端口123。确实如此,
即使使用了
也许层级太高了?
最后,从serverfault上的这篇帖子中: ...我想也许是NTP服务器的层级太高了。然而事实并非如此。让我们看一些更多的调试信息:
$ sudo ntpdate ntp.ubuntu.com
4 Mar 12:27:35 ntpdate[1258]: no server suitable for synchronization found
$ sudo ntpdate pool.ntp.org
4 Mar 12:27:50 ntpdate[1267]: no server suitable for synchronization found
$ sudo ntpdate de.pool.ntp.org
4 Mar 12:28:01 ntpdate[1273]: no server suitable for synchronization found
$ sudo ntpdate us.pool.ntp.org
4 Mar 12:28:12 ntpdate[1276]: no server suitable for synchronization found
相关问题
我已经浏览了相关问题,但没有一个能解决我的问题:
- 无法使用NTP同步时间 - 这个人遇到的错误与我不同;他的问题是与
ntpd
守护程序冲突。我根本没有安装ntp
包(其中包括ntpd
守护程序)。 - 如何强制使用ntp进行时钟更新? - 这个人的问题是,在将
ntpdate
命令放入/etc/rc.local
中时,它在启动时无法正常工作,并且问题类似于正在运行的ntpd
守护程序冲突。我既不打算在启动时运行ntpdate
,也没有安装ntpd
守护程序。 - 无法使用`ntpdate`同步时间,错误:“找不到适合同步的服务器” - 这是我的错误,但接受的答案基本上是“使用
ntpd
代替ntpdate
”。唉...
我尝试过的事情
我安装了ntp软件包
...并尝试使用ntpd
守护进程而不是ntpdate
实用程序。它也无法同步我的时间;守护进程启动正常,但我的时钟仍然不准确。我甚至尝试使用后一篇帖子中被接受答案中的确切/etc/ntp.conf
文件,并重新启动守护进程。但没有效果。无论如何,我不想使用守护进程。我完全意识到ntpdate
被认为是“已弃用”的,并建议使用ntpd -q
代替。还请参阅这里:
但由于ntpd
对我也不起作用,问题出在其他地方。而且我发现我宁愿不安装任何额外的软件包来同步时钟。ntpdate
已经预装在Ubuntu上,并且应该可以正常工作。所以我又卸载了ntp
软件包。
从这篇文章中: 我得到的想法是,在我的工作场所,我的电脑/网络可能被阻止了端口123。确实如此,
$ sudo nmap -p123 -sU -P0 localhost
...
PORT STATE SERVICE
123/udp closed ntp
...
$ sudo ufw allow 123/udp
Rules updated
Rules updated (v6)
$ sudo nmap -p123 -sU -P0 localhost
...
PORT STATE SERVICE
123/udp open ntp
...
但是仍然:
$ sudo ntpdate ntp.ubuntu.com
4 Mar 13:06:16 ntpdate[4361]: no server suitable for synchronization found
即使使用了
-u
选项,该选项告诉ntpdate
在同步时使用一个非特权端口(而不是端口123
),这个端口在我的工作地点肯定没有被阻止:$ sudo ntpdate -u ntp.ubuntu.com
4 Mar 13:06:28 ntpdate[4427]: no server suitable for synchronization found
也许层级太高了?
最后,从serverfault上的这篇帖子中: ...我想也许是NTP服务器的层级太高了。然而事实并非如此。让我们看一些更多的调试信息:
$ sudo ntpdate -dv ntp.ubuntu.com
4 Mar 13:12:24 ntpdate[4523]: ntpdate 4.2.6p5@1.2349-o Wed Oct 9 19:08:07 UTC 2013 (1)
Looking for host ntp.ubuntu.com and service ntp
host found : golem.canonical.com
transmit(91.189.89.199)
transmit(91.189.94.4)
transmit(91.189.89.199)
transmit(91.189.94.4)
transmit(91.189.89.199)
transmit(91.189.94.4)
transmit(91.189.89.199)
transmit(91.189.94.4)
transmit(91.189.89.199)
transmit(91.189.94.4)
91.189.89.199: Server dropped: no data
91.189.94.4: Server dropped: no data
server 91.189.89.199, port 123
stratum 0, precision 0, leap 00, trust 000
refid [91.189.89.199], delay 0.00000, dispersion 64.00000
transmitted 4, in filter 4
reference time: 00000000.00000000 Mon, Jan 1 1900 1:00:00.000
originate timestamp: 00000000.00000000 Mon, Jan 1 1900 1:00:00.000
transmit timestamp: d6c041ae.e6166441 Tue, Mar 4 2014 13:12:30.898
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
server 91.189.94.4, port 123
stratum 0, precision 0, leap 00, trust 000
refid [91.189.94.4], delay 0.00000, dispersion 64.00000
transmitted 4, in filter 4
reference time: 00000000.00000000 Mon, Jan 1 1900 1:00:00.000
originate timestamp: 00000000.00000000 Mon, Jan 1 1900 1:00:00.000
transmit timestamp: d6c041af.1948fc50 Tue, Mar 4 2014 13:12:31.098
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
4 Mar 13:12:33 ntpdate[4523]: no server suitable for synchronization found
嘘...这个有点长,抱歉。我被难住了。有什么线索吗?
更新:额外信息
无论在/etc/ntp.conf
中是否包含NTP服务器HOSTNAME
,以及ntpd
服务是否正在运行,每当我运行sudo ntpdate -u HOSTNAME
时,都会出现没有适合同步的服务器
的提示。当ntpd
服务未运行且我省略-u
选项时,情况也是一样。当ntpd
服务正在运行且我省略-u
选项时,我会得到NTP套接字正在使用,退出
的提示。
另外:
$ timedatectl status
Local time: Wed 2014-03-05 13:11:54 CET
Universal time: Wed 2014-03-05 12:11:54 UTC
Timezone: Europe/Berlin (CET, +0100)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: no
Last DST change: DST ended at
Sun 2013-10-27 02:59:59 CEST
Sun 2013-10-27 02:00:00 CET
Next DST change: DST begins (the clock jumps one hour forward) at
Sun 2014-03-30 01:59:59 CET
Sun 2014-03-30 03:00:00 CEST
但是这里的UTC时间不正确。现在的UTC时间是11:11
,而不是12:11
。
还有:
$ sudo hwclock --show
Wed 05 Mar 2014 01:11:56 PM CET -0.625627 seconds
sudo ntpdate ntp.ubuntu.com
,但是在将ntp.ubuntu.com
添加到/etc/ntp.conf
的服务器字段之后,你是否执行了这个操作?如果没有,请参考以下答案。 - Stormviruxsudo ntpdate 0.ubuntu.pool.ntp.org
命令。 - Stormviruxserver pool.ntp.org
添加到/etc/ntp.conf
中,但是ntpdate -u pool.ntp.org
抛出相同的错误。 我还尝试了在/etc/ntp.conf
中添加ntp.ubuntu.com
(重新启动ntp
服务,在刚才添加到/etc/ntp.conf
的确切服务器上重新运行ntpdate -u
)。 总而言之,无论我要同步的服务器是否在/etc/ntp.conf
中提到都没有关系。 在所有情况下(除非运行ntp
服务*并且省略-u
选项,然后我会得到“NTP套接字正在使用”错误),我都会收到“无可用服务器...”的错误消息。 - Malte Skoruppasudo ntpdate 0.ubuntu.pool.ntp.org
,这个命令已经在/etc/ntp.conf
文件中了。可惜没有成功,还是出现同样的错误。 - Malte Skoruppa