새로운 NTPD 설치가 동기화되지 않은 상태로 유지됨

새로운 NTPD 설치가 동기화되지 않은 상태로 유지됨

ntpd를 사용하여 Raspberry Pi에서 NTP를 작동시키려고 합니다. systemd-timesyncd를 비활성화하고 다음을 사용하여 ntp를 설치했습니다.

$ sudo apt-get install ntp

그러나 설치 후에는 ntp어떤 서버와도 동기화되지 않습니다. ntp 재설치 후 가끔 1~2개의 서버에 접속해서 동기화가 되는 경우가 있습니다. 그러나 재설정( sudo service ntp restart) 후에는 더 이상 어떤 서버에도 연결할 수 없습니다.

저는 Raspberry Pi 2 모델 B와 Raspberry Pi 3 모델 B+를 사용하고 있습니다. 두 장치 모두에서 작동하지 않습니다. 나는 또한 Raspberry Pi 3 모델 B를 가지고 있는데 예상대로 작동합니다. Raspberry Pi는 모두 동일한 네트워크에 연결되어 있습니다(따라서 이는 네트워크 방화벽의 결함이 될 수 없습니다). 라즈베리 파이는 Raspbian Buster에서 실행됩니다.

때때로 올바르게 동기화되면 ntpd -p하나 또는 두 개의 서버만 실행하고 표시됩니다. 그러나 작동하는 Raspberry Pi는 4개 이상의 서버와 동기화할 수 있습니다. NTP는 이전에 Raspberry Pi 2 모델 B에서 작업했지만 시스템 변경 없이 작동을 중단했습니다. 그 후 NTP를 완전히 다시 설치했지만 성공하지 못했습니다( sudo apt-get purge --autoremove ntp). 이러한 결과가 사용됩니다 /etc/ntp.conf.

systemd-timesyncd이 시스템을 기본 시스템의 서버로 사용하고 싶기 때문에 사용할 수 없습니다 . systemd-timesyncd제대로 작동하는 것 같지만 장치 간에 1ms 미만의 클럭 동기화를 달성하려면 서버가 필요합니다.

NTP 상태

아래에는 NTP의 상태와 결과가 나와 있습니다.ntpq -pn

다시 시작한 후 ntp 상태:

pi@raspberrypi:~ $ sudo service ntp status
● ntp.service - Network Time Service
   Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-04-24 14:48:10 CEST; 5s ago
     Docs: man:ntpd(8)
  Process: 2837 ExecStart=/usr/lib/ntp/ntp-systemd-wrapper (code=exited, status=0/SUCCESS)
 Main PID: 2843 (ntpd)
    Tasks: 2 (limit: 2200)
   Memory: 1.0M
   CGroup: /system.slice/ntp.service
           └─2843 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 109:114

Apr 24 14:48:10 raspberrypi ntpd[2843]: Listen normally on 3 eth0 192.168.0.103:123
Apr 24 14:48:10 raspberrypi ntpd[2843]: Listen normally on 4 lo [::1]:123
Apr 24 14:48:10 raspberrypi ntpd[2843]: Listen normally on 5 eth0 [fe80::1ef8:d982:66ac:4214%2]:123
Apr 24 14:48:10 raspberrypi ntpd[2843]: Listening on routing socket on fd #22 for interface updates
Apr 24 14:48:10 raspberrypi ntpd[2843]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
Apr 24 14:48:10 raspberrypi ntpd[2843]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
Apr 24 14:48:11 raspberrypi ntpd[2843]: Soliciting pool server 174.138.9.187
Apr 24 14:48:12 raspberrypi ntpd[2843]: Soliciting pool server 194.5.96.30
Apr 24 14:48:13 raspberrypi ntpd[2843]: Soliciting pool server 162.159.200.123
Apr 24 14:48:14 raspberrypi ntpd[2843]: Soliciting pool server 83.162.149.224

결과 ntpq -pn:

pi@raspberrypi:~ $ ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.debian.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.001
 1.debian.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.001
 2.debian.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.001
 3.debian.pool.n .POOL.          16 p    -   64    0    0.000    0.000   0.001

결과 ntpstat:

pi@raspberrypi:~ $ ntpstat
unsynchronised
   polling server every 8 s

NTP가 서버와 동기화되지 않는 이유를 아는 사람이 있습니까?

출력 sudo ntpdate -qu 0.debian.pool.ntp.org:

pi@raspberrypi:~ $ sudo ntpdate -qu 0.debian.pool.ntp.org
server 213.136.0.252, stratum 1, offset 0.017778, delay 0.04608
server 45.159.204.28, stratum 2, offset 0.016319, delay 0.04184
server 83.98.155.30, stratum 2, offset 0.016869, delay 0.04346
server 94.228.220.14, stratum 2, offset 0.017546, delay 0.04454
24 Apr 16:23:17 ntpdate[3139]: adjust time server 213.136.0.252 offset 0.017778 sec

구성 /etc/ntp.conf:

pi@raspberrypi:~ $ grep '^[^#]' /etc/ntp.conf
driftfile /var/lib/ntp/ntp.drift
leapfile /usr/share/zoneinfo/leap-seconds.list
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
pool 0.debian.pool.ntp.org iburst
pool 1.debian.pool.ntp.org iburst
pool 2.debian.pool.ntp.org iburst
pool 3.debian.pool.ntp.org iburst
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited
restrict 127.0.0.1
restrict ::1
restrict source notrap nomodify noquery

결과 timedatectl status:

pi@raspberrypi:~ $ timedatectl status
               Local time: Fri 2020-04-24 16:40:05 CEST
           Universal time: Fri 2020-04-24 14:40:05 UTC
                 RTC time: n/a
                Time zone: Europe/Amsterdam (CEST, +0200)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no

답변1

문제는 의 매개변수가 이어야 한다는 것입니다 System clock synchronised. timedatectl status그러나 yes항상 그런 것은 아닙니다.

이는 다음에 대한 올바른 출력입니다 timedatectl status.

$ timedatectl status
               Local time: Tue 2020-04-28 11:28:44 CEST
           Universal time: Tue 2020-04-28 09:28:44 UTC
                 RTC time: n/a
                Time zone: Europe/Amsterdam (CEST, +0200)
System clock synchronized: yes
              NTP service: inactive
          RTC in local TZ: no

이 문제는 다음 단계를 수행하여 해결할 수 있습니다.

먼저 삭제해야 합니다 ntpd. 그렇지 않으면 systemd-timesyncd문제가 발생할 수 있습니다. 이는 다음 명령을 사용하여 수행할 수 있습니다(이 명령은 삭제되지 않음 /etc/ntp.conf).

sudo apt-get remove ntp

그런 다음 다음 명령을 실행하여 ntp를 활성화하고 "systemd-timesyncd"를 시작할 수 있습니다.

sudo timedatectl set-ntp yes

명령이 systemd-timesyncd자동으로 열립니다. 따라서 systemd-timesyncd중지하고 비활성화해야 합니다. 이는 다음 명령을 사용하여 달성할 수 있습니다.

sudo systemctl stop systemd-timesyncd
sudo systemctl disable systemd-timesyncd

ntpd이제 다음을 다시 설치할 수 있습니다.

sudo apt-get install ntp

이제 ntpd다음 명령을 사용하여 다시 시작할 수 있습니다.

sudo service ntp restart

제대로 작동하는지 확인해보세요

ntp다음 명령을 실행하여 제대로 작동하는지 확인할 수 있습니다 .

ntpq -pn여러 IP가 반환되어야 합니다.

ntpstatNTP 서버와 동기화되었다고 표시되어야 합니다. ntpstat다음 명령을 사용하여 설치할 수 있습니다.

sudo apt-get install ntpstat

관련 정보