Translated message

A translation of this page exists in English.

ntpd/chronyd を 2 つの NTP サーバーで使用して 1 つをプライマリー、もう 1 つをバックアップとして指定できますか?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux (RHEL)
    • 6
    • 7
    • 8
    • 9
  • ntp
  • chrony

Issue

  • Can ntpd/chronyd be used with two NTP servers, specifying one as primary and another as backup?
  • NTP 設定ファイルには、アップストリームタイムサーバーをいくつ設定する必要がありますか?

Resolution

推奨設定

  • 2 台の NTP サーバーのみを使用することは 推奨しません
  • 複数の NTP サーバーが必要な場合は、最低 4 台の NTP サーバーを使用することを推奨します。4 台のサーバー構成であれば、1 つの誤ったタイムソース "falseticker" に対して耐性があります。詳細は、Best practices for NTP を参照してください。
  • 詳細は、アップストリーム NTP ドキュメントも参照してください。5.3.オフサイト NTP サーバーの選択 (特に5.3.3 章 アップストリームタイムサーバー数量 ) は、適切に文書化され、内容が明確です。

冗長性 (Redundancy)

  • 冗長性のために 2 台の NTP サーバーが必要な場合は、ntp.conf の true オプションと chrony.conf の trust オプションを使用して、1 台のサーバーを truechimer と見なすことができます。しかし、NTP クライアントはこの情報を無条件に受け入れるわけではありません。

  • このオプションを使用すると、NTP のタイムソース選択アルゴリズムの目的が損なわれ、特定のソースがシステムクロックを強制的に設定できるようになります。指定されたタイムソースが不安定な場合、システムは問題を識別できません。

ntpd の例

  • /etc/ntp.conf の仕様例:
server 192.168.0.1 true  
server 192.168.0.2
  • 次に、ntpd サービスを再起動します。正確に動作するように NTP が十分な情報を収集するまで、15 分間ほど待機します。その後、ntpq -pn コマンドを使用して同期ステータスを確認できます。結果として 2 つ考えられます。

  • 両方の NTP サーバーが安定しており、相互に同期している場合は、両方の NTP サーバーの前に * または + が表示されます。以下に例を示します。

 [root@localhost ~]# ntpq -pn  
remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+192.168.0.1     LOCAL(0)         6 u   10   16  377    0.154    4.200   2.416
*192.168.0.2     LOCAL(0)         6 u    1   16  377    0.981    0.982   0.400
  • ローカル時間に準拠している 2 つの NTP サーバーによって提供される時間情報が同期していない場合、ntpd はオプションが true のサーバーを信頼し、もう 1 つは falseticker であると想定します。以下に例を示します。
[root@localhost ~]# ntpq -pn  
remote           refid       st t when poll reach   delay   offset   jitter  
==============================================================================  
*192.168.0.1        LOCAL(0)     6  u 10   16   377     0.211   -16.920 2.562  
x192.168.0.2        LOCAL(0)     6  u 1    16   377     0.581    5.242  4.597

chronyd の例

  • /etc/chrony.conf の仕様例:
server 192.168.0.1 trust  
server 192.168.0.2

Root Cause

  • ntpd/chronyd が 2 つのタイムソースから情報を取得し、それぞれが渡す時間の幅が小さく収まらない場合、ntpd/chronyd デーモンは、どのタイムソースが正しいか、どれが falseticker であるかを判断できません。

Diagnostic Steps

ntpd の場合:

  • 次のコマンドを使用して、/etc/ntp.conf ファイルで設定されているクロックの数を確認します。
[root@localhost ~]# grep -E '^(peer|server)' /etc/ntp.conf
  • ntpd が現在使用しているクロックの数を確認します。
[root@localhost ~]# ntpq -p

chronyd の場合:

  • 次のコマンドを使用して、/etc/chrony.conf ファイルで設定されているクロックの数を確認します。
[root@localhost ~]# grep -E '^(peer|server)' /etc/chrony.conf
  • chronyd が現在使用しているクロックの数を確認します。
[root@localhost ~]# chronyc sources
  • man ntp.conf より:
       true    Mark the association to assume truechimer  status;  that  is,  always
               survive  the  selection and clustering algorithms. This option can be
               used with any association, but is most useful  for  reference  clocks
               with  large  jitter on the serial port and precision pulse-per-second
               (PPS) signals. Caution: this option defeats the  algorithms  designed
               to  cast out falsetickers and can allow these sources to set the sys-
               tem clock. This option is valid only with the server  and  peer  com-
               mands.
  • man chrony.conf より:
           trust
               Assume time from this source is always true. It can be rejected as a
               falseticker in the source selection only if another source with this
               option does not agree with it.
  • Component
  • ntp

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments