Kim*_*cks 4 server networking ntp 14.04
服务器是 14.04
我的 timedatectl status
www-data@Mercury:$ timedatectl status
Local time: Fri 2017-08-04 14:34:31 SGT
Universal time: Fri 2017-08-04 06:34:31 UTC
Timezone: Asia/Singapore (SGT, +0800)
NTP enabled: no
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
Run Code Online (Sandbox Code Playgroud)
当我运行 ntpq 时,连接被拒绝。我已经谷歌搜索,但没有一个解决方案适合我。
www-data@Mercury:$ sudo ntpq -p
ntpq: read: Connection refused
Run Code Online (Sandbox Code Playgroud)
这是我的 /etc/ntp.conf
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
Run Code Online (Sandbox Code Playgroud)
我花了一年时间,但现在我终于明白了这个问题。我正在使用的服务器位于内部网络中,该网络仅限于某些 NTP 服务器。
以下是对 Ubuntu 14.04 无头服务器进行故障排除的有用步骤列表
timedatectl status
你应该看到
# timedatectl status
Local time: Mon 2018-09-17 10:49:04 +08
Universal time: Mon 2018-09-17 02:49:04 UTC
Timezone: Asia/Singapore (+08, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
Run Code Online (Sandbox Code Playgroud)
ntpq -p
# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
ns1.ericsson.se 194.58.202.148 2 u 3 64 1 237.716 1217396 0.000
sesblx50.mgmt.e 194.58.202.148 2 u 2 64 1 242.759 1217391 0.000
chilipepper.can .INIT. 16 u - 64 0 0.000 0.000 0.000
Run Code Online (Sandbox Code Playgroud)
如果您看到.INIT.refid 中显示的所有内容,则表示未连接到 NTP 服务器。向您的网络管理员询问 NTP 服务器。这是我最初的问题。如果您看到refid正确指向某个 IP 地址,则您的 NTP 服务正确连接到 NTP 服务器。
作为root,去vim /etc/ntp.conf
# 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 0.ubuntu.pool.ntp.org
#server 1.ubuntu.pool.ntp.org
#server 2.ubuntu.pool.ntp.org
#server 3.ubuntu.pool.ntp.org
server time1.suppliedbyadmin.com
server time2.suppliedbyadmin.com
Run Code Online (Sandbox Code Playgroud)
然后改变这个 service ntp restart
即使您更新到正确的 ntp 服务器,系统时钟仍然可能是错误的。所以你需要强制NTP更新。
停止ntp服务
强制更新 ntpd -gq
然后再次启动ntp服务
它应该是这样的:
# service ntp stop
# ntpd -gq
ntpd: time set +1217.437601s
# service ntp start
Run Code Online (Sandbox Code Playgroud)
这应该工作
用 service ntp status
# service ntp status
* NTP server is running
Run Code Online (Sandbox Code Playgroud)
即使您知道该服务正在运行,也不意味着 NTP 服务正确连接到 NTP 服务器。检查ntpq -p命令以确保