가상 머신이 ntpd를 실행 중이지만 동기화되지 않았습니다.

가상 머신이 ntpd를 실행 중이지만 동기화되지 않았습니다.

TL;DR

VM은 KVM을 사용하며 시간이 동기화되지 않습니다. 2분 동안 일시 정지한 후에는 영구적인 2분 간격이 남습니다. 다른 네트워크 구성으로 다른 가상 머신을 설정하면 네트워크 구성으로 인해 ntp가 작동하지 않는 것으로 나타납니다. 이 네트워크 문제를 해결하는 것은 주제를 벗어납니다.

그러나 네트워크 문제가 없는 새 가상 머신은 복구 후에도 동기화되지 않습니다. 동일한 테스트: 2분 동안 일시 중지합니다. 올바르게 동기화된 컴퓨터와의 날짜 차이를 확인하세요. 2분 지연은 영구적입니다.

이는 일반적인 문제인 것으로 보이며 가상 머신을 동기화 상태로 유지하고 NTP와 kvm-clock을 동시에 사용하는 방법에 대한 논쟁이 있습니다. 많은 참고 자료를 찾았지만 답변이 없습니다.

질문

ntpd실행되지만 시간을 수정할 수 없는 Debian VM이 있습니다 . 예를 들어 일시 중지/재개 후에 영구적인 2분 오프셋을 얻습니다.

/etc/ntp.conf기본값이거나 기본값에 가깝고 특별한 것은 없습니다.

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

driftfile /var/lib/ntp/ntp.drift


# 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


# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example

# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
server 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst
server 3.debian.pool.ntp.org iburst


# 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
# that might be intended to block requests from certain clients could also end
# 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
restrict -6 default kod notrap nomodify nopeer noquery

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

# 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

ntpq가 문제를 보고하는 것 같습니다.

# cat ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 37.187.7.160    .INIT.          16 u    - 1024    0    0.000    0.000   0.000
 195.154.211.37  .INIT.          16 u    - 1024    0    0.000    0.000   0.000
 195.154.216.44  .INIT.          16 u    - 1024    0    0.000    0.000   0.000
 95.81.173.155   .INIT.          16 u    - 1024    0    0.000    0.000   0.000

그러나 저는 netcat 마법사는 아니지만 UDP 포트 123의 AFAIU 나가는 트래픽은 다음을 통과합니다.

# nc -vvzu 37.187.7.160 123
mail.lafkor.de [37.187.7.160] 123 (ntp) open
 sent 0, rcvd 0

이 테스트는 방화벽 문제를 배제하기에 충분합니까?

호스트(Debian 시스템이기도 함)는 동일한 NTP 구성을 가지며 동기화가 실행 중입니다. 두 컴퓨터의 네트워크 구성이 다르기 때문에 네트워크 문제일 수 있다고 생각했습니다.

실행할 수 있는 다른 유용한 테스트가 있습니까?

tinker panic 0이 매개변수는 2분 간격이 아닌 큰 간격에 대한 업데이트를 강제하도록 설계되었기 때문에 여기서는 관련이 없다고 생각합니다 . 어쨌든 AFAIU는 시간 오프셋의 동작에 영향을 주지만 ntpq -pn단지 0을 반환하는 문제는 해결하지 못합니다 .

FWIW, 다른 테스트 출력은 다음에서 영감을 받았습니다.이 문제:

# ntpq
ntpq> pe
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 mail.lafkor.de  .INIT.          16 u    - 1024    0    0.000    0.000   0.000
 atoll.tropicdre .INIT.          16 u    - 1024    0    0.000    0.000   0.000
 oods.roflcopter .INIT.          16 u    - 1024    0    0.000    0.000   0.000
 ntp-3.arkena.ne .INIT.          16 u    - 1024    0    0.000    0.000   0.000
ntpq> as

ind assid status  conf reach auth condition  last_event cnt
===========================================================
  1 21025  8011   yes    no  none    reject    mobilize  1
  2 21026  8011   yes    no  none    reject    mobilize  1
  3 21027  8011   yes    no  none    reject    mobilize  1
  4 21028  8011   yes    no  none    reject    mobilize  1
ntpq> rv
associd=0 status=c012 leap_alarm, sync_unspec, 1 event, freq_set,
version="ntpd [email protected] Fri Apr 10 19:04:04 UTC 2015 (1)",
processor="x86_64", system="Linux/3.16.0-4-amd64", leap=11, stratum=16,
precision=-23, rootdelay=0.000, rootdisp=6683.055, refid=INIT,
reftime=00000000.00000000  Mon, Jan  1 1900  0:09:21.000,
clock=d9b51587.b7a1085f  Tue, Sep 29 2015 15:49:59.717, peer=0, tc=3,
mintc=3, offset=0.000, frequency=-0.125, sys_jitter=0.000,
clk_jitter=0.000, clk_wander=0.000
ntpq> rv 21025
associd=21025 status=8011 conf, sel_reject, 1 event, mobilize,
srcadr=mail.lafkor.de, srcport=123, dstadr=147.210.157.185, dstport=123,
leap=11, stratum=16, precision=-23, rootdelay=0.000, rootdisp=0.000,
refid=INIT, reftime=00000000.00000000  Mon, Jan  1 1900  0:09:21.000,
rec=00000000.00000000  Mon, Jan  1 1900  0:09:21.000, reach=000,
unreach=1137, hmode=3, pmode=0, hpoll=10, ppoll=10, headway=0,
flash=1600 peer_stratum, peer_dist, peer_unreach, keyid=0, offset=0.000,
delay=0.000, dispersion=15937.500, jitter=0.000, xleave=0.167,
filtdelay=     0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00,
filtoffset=    0.00    0.00    0.00    0.00    0.00    0.00    0.00    0.00,
filtdisp=   16000.0 16000.0 16000.0 16000.0 16000.0 16000.0 16000.0 16000.0

tcpdump/ntpdate 테스트

NTP 동기화가 제대로 작동하는 컴퓨터에서 tcpdump udp port ntp부팅하고 재부팅하면 ntpd다음 출력이 표시됩니다.

# tcpdump udp port ntp
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
17:31:33.719166 IP 10.0.2.15.ntp > spica.beduzar.fr.ntp: NTPv4, Client, length 48
17:31:33.736804 IP spica.beduzar.fr.ntp > 10.0.2.15.ntp: NTPv4, Server, length 48
17:31:35.973551 IP 10.0.2.15.ntp > ntp.tuxfamily.net.ntp: NTPv4, Client, length 48
17:31:35.992671 IP ntp.tuxfamily.net.ntp > 10.0.2.15.ntp: NTPv4, Server, length 48
[...]

문제가 있는 컴퓨터에서 ntpd재부팅할 때 출력이 전혀 표시되지 않습니다(요청 없음, 응답 없음). 최소한 이런 요청은 봐야 하지 않겠습니까?

좋은 기계에서:

# ntpdate 0.debian.pool.ntp.org
29 Sep 17:24:49 ntpdate[700]: adjust time server 193.55.167.1 offset -0.005196 sec

불량 머신의 경우:

# ntpdate 0.debian.pool.ntp.org
29 Sep 17:43:18 ntpdate[3180]: no server suitable for synchronization found

테스트를 위해 다른 가상 머신 사용

NTP 구성은 동일하지만 네트워크 구성이 다른 다른 가상 머신을 설정했습니다.

tcpdumpand 의 결과는 ntpdate정확하며 ntpq -pn좋은 결과를 반환합니다. 분명히 네트워크 구성은 실제로 결함이 있는 VM에 문제가 있는 것 같습니다.

그러나 새 가상 머신도 동기화되지 않습니다. 약 100초 지연되도록 일시중지하면 동기화되지 않습니다. 즉, 몇 분 후에도 간격은 여전히 ​​같은 초 수입니다. 그러나 ntpd가 다시 시작되면 즉시 동기화됩니다.

두 가지 문제가 있는 것 같습니다.

  • 첫 번째 가상 머신의 네트워크 구성

  • ntp는 둘 다에서 동기화되지 않습니다(재부팅하지 않는 한).

답변1

문제가 해결되었습니다.

인터넷 문제

VM에 ntpd의 성공을 방해하는 네트워크 문제가 있습니다. 두 개의 인터페이스가 있는데 eth, 게이트웨이가 있는 인터페이스는 우리가 직접 관리하지 않는 라우터를 통과합니다. 내 테스트에서는 이것이 표시되지 않았지만 일부 UDP 프레임이 차단되고 있는 것 같습니다. 우리는 다른 네트워크 구성으로 다른 가상 머신을 설정했고 ntpq더 나은 결과를 얻었습니다.

결국 우리는 ntp호스트가 시간을 로컬로 브로드캐스트하고 모든 VM이 동기화되도록 구성을 변경했습니다. 더 합리적이고 ntp공용 서버의 부하를 최소화합니다.

ntpd몇 분 후 즉시 시계를 설정하세요.

테스트 중에 나를 오해했을 수 있는 한 가지는 ntpd가 즉시 동기화되지 않는다는 것입니다. 제 생각에는 간격을 즉시 감지한 다음 클럭 속도를 수정하여 클럭이 소스 클럭에 점진적으로 합류하도록 하는 것 같습니다. 실제로 우리는 ( ntpd재부팅하지 않는 한) 시계가 몇 분 동안 변경되지 않았다가 갑자기 즉시 보이는 것처럼 설정되는 것을 발견했습니다. 한편, ntpq출력의 가장 오른쪽 열에는 동기화가 진행 중임을 표시합니다.

이 동작은 아마도 작동하더라도 작동하지 않는다고 ntpd생각하는 이유를 설명할 것입니다 . ntpd나는 충분히 오래 기다리지 않았고 ntpq결과를 이해하지 못했습니다.

관련 정보