【问题标题】:NTP does not synchronize on Ubuntu 18.04.02NTP 在 Ubuntu 18.04.02 上不同步
【发布时间】:2020-03-03 18:12:08
【问题描述】:

我的操作系统是 Ubuntu 18.04.02 - 没有 NTP,我必须使用 apt-get 安装它。我有一个应用程序,我必须使用 NTP 来实现兼容性。我禁用并删除了 timesyncd 以避免冲突。

我将 ntp.conf 配置为使用:

0.north-america.pool.ntp.org

1.north-america.pool.ntp.org

2.north-america.pool.ntp.org

我可以毫无问题地 ping 它们。互联网连接很好。 NTP 服务正在运行,但一直处于请求状态,未同步时间。

这只是一个客户端 IoT 设备。我只需要与同一网络上的其他计算机同步执行任务的时间即可。

我错过了什么?我必须启用防火墙或端口吗?我正在阻止 IPV6,我在 NTPD_OPTS 中添加了 -4。

$ sudo service ntp status
● ntp.service - Network Time Service
   Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enab
   Active: active (running) since Mon 2020-03-02 13:07:14 EST; 17h ago
     Docs: man:ntpd(8)
  Process: 2078 ExecStart=/usr/lib/ntp/ntp-systemd-wrapper (code=exited, status=
 Main PID: 2090 (ntpd)
    Tasks: 2 (limit: 1600)
   CGroup: /system.slice/ntp.service
           └─2090 /usr/sbin/ntpd -p /var/run/ntpd.pid -4 -g -u 106:113

Mar 03 06:36:13 FD50-AE ntpd[2090]: Soliciting pool server 209.115.181.1
Mar 03 06:36:34 FD50-AE ntpd[2090]: Soliciting pool server 45.33.2.219
Mar 03 06:36:38 FD50-AE ntpd[2090]: Soliciting pool server 64.79.100.197
Mar 03 06:36:55 FD50-AE ntpd[2090]: Soliciting pool server 91.189.91.157
Mar 03 06:37:20 FD50-AE ntpd[2090]: Soliciting pool server 149.56.47.60
Mar 03 06:37:20 FD50-AE ntpd[2090]: bind(19) AF_INET 127.0.0.1#123 flags
Mar 03 06:37:20 FD50-AE ntpd[2090]: unable to create socket on lo (212)
Mar 03 06:37:20 FD50-AE ntpd[2090]: failed to init interface for address
Mar 03 06:37:38 FD50-AE ntpd[2090]: Soliciting pool server 45.63.54.13
Mar 03 06:37:43 FD50-AE ntpd[2090]: Soliciting pool server 173.255.140.3

[1]+  Stopped                 sudo service ntp status

$ ntpstat
unsynchronised
   polling server every 8 s

$ timedatectl
                      Local time: Tue 2020-03-03 06:58:34 EST
                  Universal time: Tue 2020-03-03 11:58:34 UTC
                        RTC time: Tue 2020-03-03 11:58:34
                       Time zone: America/New_York (EST, -0500)
       System clock synchronized: no
systemd-timesyncd.service active: no
                 RTC in local TZ: no

$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.north-america .POOL.          16 p    -   64    0    0.000    0.000   0.000
 1.north-america .POOL.          16 p    -   64    0    0.000    0.000   0.000
 2.north-america .POOL.          16 p    -   64    0    0.000    0.000   0.000
 ntp.ubuntu.com  .POOL.          16 p    -   64    0    0.000    0.000   0.000
$

$ sudo systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:systemd-timesyncd.service(8)

下面是我的 ntp.conf:

#interface listen IPv4
#interface ignore IPv6
interface ignore wildcard

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

driftfile /var/lib/ntp/ntp.drift

# Leap seconds definition provided by tzdata
leapfile /usr/share/zoneinfo/leap-seconds.list

# 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.
#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst

pool 0.north-america.pool.ntp.org iburst
pool 1.north-america.pool.ntp.org iburst
pool 2.north-america.pool.ntp.org iburst

# Use Ubuntu's ntp server as a fallback.
pool 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
# 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 limited
restrict -6 default kod notrap nomodify nopeer noquery limited

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

# Needed for adding pool entries
restrict source notrap nomodify noquery

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


# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient

#Changes recquired to use pps synchonisation as explained in documentation:
#http://www.ntp.org/ntpfaq/NTP-s-config-adv.htm#AEN3918

#server 127.127.8.1 mode 135 prefer    # Meinberg GPS167 with PPS
#fudge 127.127.8.1 time1 0.0042        # relative to PPS for my hardware

#server 127.127.22.1                   # ATOM(PPS)
#fudge 127.127.22.1 flag3 1            # enable PPS API

【问题讨论】:

标签: ubuntu-18.04 ntp


【解决方案1】:

我之前在设置 Ubuntu 18.04 机器时遇到了一些问题。我只是看了一些日志,我可能会提供帮助。

$ timedatectl 
                  Local time: Wed 2020-03-18 18:01:20 GMT
              Universal time: Wed 2020-03-18 18:01:20 UTC
                    RTC time: Wed 2020-03-18 18:01:20
                   Time zone: Europe/London (GMT, +0000)
   System clock synchronized: yes

这是我的 timedatectl 输出。我必须通过将其添加到“/etc/systemd/timesyncd.conf”来同步它:

[Time] NTP=10.199.999.99 10.999.999.999

只需输入您尝试与之同步的服务器的 IP 地址。重启 timedate 和 ntp 和 systemd timesync 服务。 (或重新启动:))。你应该没事,我不记得做过别的事情。希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-29
    • 1970-01-01
    • 2013-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多