我的服务器上的时间已经正确同步了几个星期,然后我们上周重新启动了服务器,今天休息了 10 分钟。我做了“sudo ntpdate ntp.ubuntu.com”并得到:
4 Oct 14:22:08 ntpdate[17734]: the NTP socket is in use, exiting
我猜这意味着它已经在运行……但是为什么当我重新启动服务器时它没有运行?
更新
/etc/ntp.conf
driftfile /var/lib/ntp/ntp.drift
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
server ntp.ubuntu.com
server 0.north-america.pool.ntp.org
server 1.north-america.pool.ntp.org
server 2.north-america.pool.ntp.org
server 3.north-america.pool.ntp.org
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
restrict 127.0.0.1
restrict ::1
Run Code Online (Sandbox Code Playgroud)
你确定当盒子重新启动时 ntpd 没有运行吗?检查您的 syslog'ed 启动日志,看看它是否在盒子启动时启动。
另外,请记住,如果时间差太多,ntpd 会假设您的时间源可能存在问题,并且不会更改时间。默认情况下,如果从外部时间服务器报告的时间与本地时间相差 1000 秒以上,就会发生这种情况。多年来,我遇到了一些事情(例如 CMOS 电池耗尽),可能会导致本地机器时间在重新启动时出现严重偏差。
仔细检查您的 /etc/ntp.conf 配置,确保它是准确的(时间服务器可访问等)。然后尝试重新启动 ntpd,并在执行此操作时查看日志。看看那里是否一切都很好。然后返回系统日志并找到所有与 ntpd 相关的日志。查找错误、问题等。确保它在启动时启动。
在这种情况下,日志通常是故障排除的最佳信息来源。
如果时间差超过 1000 秒,并且需要重置它,则需要先停止 ntpd,然后运行 ntpdate 重置时间,然后重新启动 ntpd。以下命令将执行此操作:
sudo /etc/init.d/ntp stop
sudo ntpdate 0.north-america.pool.ntp.org
sudo /etc/init.d/ntp start
Run Code Online (Sandbox Code Playgroud)
如果您在每次重新启动时遇到时间严重偏移的问题,可能值得在每次启动时启动 ntpd 之前编写 ntpdate 脚本来运行。这应该有助于在 ntpd 处理之前将时间重置为可管理的。
| 归档时间: |
|
| 查看次数: |
13375 次 |
| 最近记录: |