LoginSignup
4
6

More than 5 years have passed since last update.

RHEL における ntpd/chrony の注意事項

Last updated at Posted at 2018-06-13

RHEL における ntpd/chrony を利用して時刻を取得する場合、幾つか注意事項があるのでそれをまとめてみた。

ntpd と chronyd の違い

まずはそれぞれの違いについて。

RHEL7 からは ntpd と chronyd が存在している。
当然だが、ntpd と chronyd には違いが存在し、RHEL がどのような環境で動作しているかで選択するサービスは異なる。
それぞれの違いについては、以下に記載されている。

第15章 CHRONY スイートを使用した NTP 設定
https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-configuring_ntp_using_the_chrony_suite

ざっくりとだけど、以下のような感じ。

  • chronyd:仮想環境や NTP サーバと常に通信できない環境で選択
  • ntpd:NTP サーバと常に通信できる環境で選択

注意事項

NTP サーバの選択について

続いて、ntpd や chrony で時刻を取得する上で参照する上位の NPT サーバの決める上での注意事項について。

以下のドキュメントを参照した上で、上位の NTP サーバを決める必要がある。

Best practices for NTP
https://access.redhat.com/solutions/778603

Red Hat Enterprise Linux server using NTP will not keep time in sync with Windows-synced NTP server / windows NTP server
https://access.redhat.com/solutions/23365

Can NTP be used with two NTP servers, specifying one as primary and another as backup?
https://access.redhat.com/solutions/58025

まとめると以下のような内容になる。

  • 上位の NTP サーバは最低 4 台が推奨される
    • 1 台でも時刻を取得することはできるけど、妥当と考えられる時間の刻みを計るには複数の NTP サーバが必要。
  • 必要ではない限り、ローカルクロック (127.127.1.0) は参照しない
    • あまり精度が高くないから。
  • 仮想マシンを上位の NTP サーバにするのは駄目
    • 精度が……
  • Windows Server (特に Windows Server 2016 より前) を上位の NTP サーバにするのは駄目
    • 精度が……

その他

ntpd/chrony によるハードウェアクロック調整と hwclock コマンドについて。

ntpd は以下の通り -x オプション無しでサービスを起動するとハードウェアクロックを調整 (システムクロックに同期) する。

How to check if 11 mints mode syncing hardware clock to system clock?
https://access.redhat.com/solutions/2455681

なお、上記の機能については、RHEL6 以降は ntpdate の起動も必要。また、ハードウェアクロックが ± 15 分離れると無効らしい。

16.18. ハードウェアクロック更新の設定
https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/7/html/system_administrators_guide/s1-configuring_the_hardware_clock_update

11 minute mode not syncing hardware clock to system clock
https://access.redhat.com/solutions/55432

chrony については、rtcsync の説明から同様の機能がある。
https://chrony.tuxfamily.org/doc/2.1/manual.html

ただし、man hwclock にあるが、上記の機能の有効にした状態で hwclock を実行するとハードウェアクロックが
正常に機能しなくなるので、注意。

  If your system runs with 11 minute mode on, don't use hwclock --adjust or hwclock --hctosys. 
  You'll just make a mess. It is acceptable to use a hwclock --hctosys at startup time to get 
  a reasonable System Time until your system is able to set the System Time from the external 
  source and start 11 minute mode.

man hwclock に記載の --adjust や --hctosys だけでなく hwclock コマンド自体が NG のはず。
ntpd/chrony による調整と hwclock コマンドのタイミングが重複すると OS を再起動するまでハードウェアクロックが更新されなくなる事がある。
※そもそも、上記の「11 mints mode」が存在する時点で、hwclock コマンド自体を実行する必要性はない気がするが。

おまけ

以下で ntpd 設定用のスクリプトを作成可能。

NTP Configuration
https://access.redhat.com/labs/ntpcc/

以下の情報も参照しておくこと。

Understanding RHEL System Clocks And Time Protocol Implementations
https://access.redhat.com/articles/1456843

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6