解决方案

解决方案

我的服务器位于未来 2027 年:

# sudo ntpdate ptbtime1.ptb.de
9 Jul 00:04:01 ntpdate[10000]: step time server 192.53.103.108 offset -353547847.989546 sec
# date
Di 21. Sep 23:48:18 CEST 2027
# hwclock
Sa 09 Jul 2016 02:03:56 CEST  -0.234935 Sekunden

漂移非常大,而且还有 10 多年的时间。我无法通过“正常”重置来改变漂移。我已经阅读了几篇文章,并尝试了很多方法,例如ntpdate –bntpd-gq 命令或者修补恐慌 0。我更改了时区,并尝试手动设置日期/时间。但没有任何效果。我该如何纠正这个问题?有人能帮我吗?我正在运行 Kubuntu 14.04 LTS(GNU/Linux 3.13.0-66-generic i686)

==================================================================

这会引起问题吗?

# sudo service ntp stop
 * Stopping NTP server ntpd                                                                             [ OK ]
# ntpq -p
ntpq: read: Connection refused

==================================================================

# sudo service ntp stop
 * Stopping NTP server ntpd                                                                                      [ OK ]
# sudo ntpd -gq
ntpd: time set -353547849.485594s
# sudo service ntp start
 * Starting NTP server ntpd                                                                                      [ OK ]
# date
Mi 22. Sep 11:39:09 CEST 2027

====================================================================

请注意对于 ntpd 来说,距离“太远”有多远?它能通过突然跳到重负载来达到这个距离吗?这能被覆盖吗?“根据手册页,如果您的时钟偏差超过 1000 秒,ntpd 将无法工作。”

====================================================================

我尝试手动更改它:

# date
Mi 22. Sep 11:32:09 CEST 2027
# sudo date --set="2016-07-09 11:50:59.990"
Sa 9. Jul 11:50:59 CEST 2016
# date
Mi 22. Sep 11:35:08 CEST 2027

==================================================================

我可以用日期——设置“-1年”。但我没法减少它。

=========================================================================

它不起作用:

# sudo service ntp stop
 * Stopping NTP server ntpd                                                            [ OK ]
# sudo ntpdate-debian
 9 Jul 14:56:52 ntpdate[3684]: step time server 131.188.3.220 offset -353547850.182477 sec
# sudo service ntp start
 * Starting NTP server ntpd                                                            [ OK ]
# date
Mi 22. Sep 14:41:25 CEST 2027

更新:我没有足够的耐心。我不得不再等一秒钟,但巨大的漂移仍然存在。

=====================================================

/etc/ntp.conf

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
tinker panic 0

driftfile /var/lib/ntp/ntp.drift


# Enable this if you want statistics to be logged.
statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
server ntp.ubuntu.com
server pool.ntp.org
server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org
server 3.ubuntu.pool.ntp.org

# Use Ubuntu's ntp server as a fallback.
server ntp.ubuntu.com

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust

=====================================================

我也尝试了 sntp

# sudo sntp -s ntp.ubuntu.com
22 Sep 12:53:56 sntp[17210]: Started sntp
2027-09-22 12:53:56.128427 (-0100) -353533451.192434 +/- 0.049652 secs
2027-09-22 12:53:56.155758 (-0100) -176766725.596156 +/- 0.024307 secs
2027-09-22 12:53:56.183422 (-0100) -265150088.380065 +/- 0.049652 secs
# date
Mi 22. Sep 12:54:01 CEST 2027

=====================================================

这是 ntpdate-debian 之后的日期:

# date
Mi 22. Sep 12:54:40 CEST 2027
# sudo ntpdate-debian -s ntp.ubuntu.com && date
Sa 9. Jul 17:15:02 CEST 2016
# date
Mi 22. Sep 12:59:20 CEST 2027
# sudo ntpdate-debian -s ntp.ubuntu.com && date && date && date
Mi 22. Sep 13:00:21 CEST 2027
Mi 22. Sep 13:00:21 CEST 2027
Mi 22. Sep 13:00:21 CEST 2027
# sudo ntpdate-debian -s ntp.ubuntu.com && date && date && date
Sa 9. Jul 17:16:44 CEST 2016
Mi 22. Sep 13:00:55 CEST 2027
Mi 22. Sep 13:00:55 CEST 2027

=====================================================

已删除的漂移文件:

sudo service ntp stop
rm /etc/adjtime
rm /var/lib/ntp/ntp.drift
shutdown –h now

重启后 /var/lib/ntp/ntp.drift 为空。/etc/adjtime 为

0.000000 1821611426 0.000000
1821611426
UTC

日期/时间仍然相同。漂移存储在哪里?

========================================================

解决方案

作者:迈克尔·汉普顿:

我停止了 ntp(用 检查ps –aux | grep ntp)并使用hwclock –s

# sudo service ntp stop 
* Stopping NTP server ntpd                                                                                         [ OK ]
# sudo hwclock --set --date="7/9/16 18:37:30"
# hwclock
Sa 09 Jul 2016 18:37:34 CEST  -0.047338 Sekunden
# hwclock -s
# hwclock
Sa 09 Jul 2016 18:37:47 CEST  -0.984834 Sekunden
# hwclock
Sa 09 Jul 2016 18:38:01 CEST  -0.219219 Sekunden
# date
Mi 22. Sep 00:24:34 CEST 2027
# date
Mi 22. Sep 00:29:32 CEST 2027
# date
Mi 22. Sep 00:33:49 CEST 2027

我必须重新启动并且必须更正文件系统,因为它抱怨最后一次文件系统检查是在将来。

非常感谢所有帮助过我的人,特别感谢迈克尔!!!

答案1

由于您正在运行基于 Debian 的发行版,请尝试以下操作:

sudo service ntp stop
sudo ntpdate-debian
sudo service ntp start

相关内容