web-dev-qa-db-ja.com

NTP同期はsyslogに表示されません

LAN用にローカルNTPサーバーをセットアップしようとしています。ntpdate server_ipを実行して手動で時刻を更新できます。しかし、ntpデーモンが何もログインしていないようです。 Syslogなので、システムが同期したかどうかはわかりません。

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift
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
logconfig =syncall +clockall
# 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.
server  10.0.1.201 iburst minpoll 3 maxpoll 4
restrict -4 default kod notrap nomodify nopeer
restrict -6 default kod notrap nomodify nopeer
# 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.
# 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

何が欠けているのでしょうか?

1
Prateek Bhatt

NTPは通常、syslogでは非常に静か/サイレントです。それが現れた場合、物事はうまくいかない。ハードウェアクロックが機能している場合は、起動時にクロックを変更する必要はありません。適切な設定を行うと、ntpdateを置き換えて、必要に応じて起動時の時計を設定できます。

確認したいログは、loopstatsファイルとpeerstatsファイルです。実行すると、NTPはクロックを同期する必要はありません。クロックの同期を維持するためにティックタイミングをわずかに調整します。loopstatsファイルはローカル状態を提供し、peerstatsは、使用しているサーバーに関連する状態を示します。これらのファイルの詳細については、 NTPトラブルシューティングガイド を参照してください。

2
BillThor

システムが同期されていることを確認するために、以下を実行できます。

# ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 159.69.144.253  94.16.116.137    3 u   60   64   37    2.749   -2.464   0.066
*176.9.241.107   192.53.103.108   2 u   61   64   37    0.461    0.237   0.026
 193.175.73.20   .MRS.            1 u   62   64   37   19.189    1.786   0.072
 138.68.126.106  130.149.17.8     2 u   59   64   37    5.366    0.562   0.043

レコードの*サフィックスは、そのピアが現在同期に使用されていることを示します。

一方、クロック同期イベントの詳細な監視/ログ記録には、次のことが非常に役立つことがわかりました。

まず、次のフォルダーが存在しない場合は作成し、NTPデーモンを実行しているユーザーに所有権を割り当てます。

# mkdir /var/NTP/
# chown ntp /var/NTP/

次に、ntp.confを次のように変更します。ここで、これらの各エントリの意味は http://doc.ntp.org/4.2.6p3/monopt.html

statsdir /var/NTP/
filegen clockstats file clockstats
filegen cryptostats file cryptostats
filegen loopstats file loopstats
filegen peerstats file peerstats
filegen protostats file protostats
filegen rawstats file rawstats
filegen sysstats file sysstat
filegen timingstats file timingstats

次に、NTPサービスを再起動し、/var/NTP/フォルダーを確認します。

最後に、たとえば、時間の経過とともに同期に使用されたピアを特定するには、sys_peer/var/NTP/protostatsで終わる行を探します。例:

58827 80454.306 159.69.144.253 8014 84 reachable
58827 80647.304 176.9.241.107 901a 8a sys_peer
58827 80647.304 0.0.0.0 c615 05 clock_sync
58827 80842.323 193.175.73.20 901a 8a sys_peer

PS:

  • 私はNTPの専門家ではないので、前のステートメントのいくつかで間違っている可能性があります。
1
Jaime Hablutzel