NTP在Ubuntu 18.04.02上不同步

问题描述 投票:-1回答:1

我的操作系统是Ubuntu 18.04.02-没有NTP,我必须使用apt-get安装它。我有一个必须使用NTP才能兼容的应用程序。我禁用并删除了时间同步以避免冲突。

我将ntp.conf配置为使用:

0.north-america.pool.ntp.org

1.north-america.pool.ntp.org

2.north-america.pool.ntp.org

我可以无问题地对其进行ping操作。互联网连接很好。 NTP服务正在运行,但永远处于请求状态,并且不同步时间。

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

我想念什么?我必须启用防火墙或端口吗?我正在阻止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个回答
0
投票

以前在设置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时间同步服务。 (或重新启动:))。而且您应该没问题,我不记得做任何其他事情了。希望这会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.