Help us understand the problem. What is going on with this article?

CentOS7 on EC2 の時刻を Chrony で Amazon Time Sync Service と同期する

More than 1 year has passed since last update.

はじめに

AWS から NTP サービス Amazon Time Sync Service がリリースされました。
この記事では CentOS 7 の EC2 インスタンスでの利用方法について書きます。

Chrony とは

chrony は chrony パッケージで提供されている CentOS 7 標準の NTP クライアント/サーバの実装です。

Amazon Time Sync Service とは

Amazon Time Sync Service は、VPC で実行されているすべてのインスタンスについて、169.254.169.123 のIPアドレスで NTP を通じて時刻同期に利用できるサービスです。

設定手順

ntp パッケージがインストール済みならアンインストール

$ yum list ntp*
$ sudo yum remove ntp*

chrony パッケージが入っていなければインストール

$ yum list chrony
$ sudo yum install chrony

設定ファイル( /etc/chrony.conf )を修正、169.254.169.123 を優先するように設定を追加

$ diff -C 5 /etc/chrony.conf.orig /etc/chrony.conf
*** 1,7 ****
--- 1,8 ----
  # Use public servers from the pool.ntp.org project.
  # Please consider joining the pool (http://www.pool.ntp.org/join.html).
+ server 169.254.169.123 prefer iburst
  server 0.centos.pool.ntp.org iburst
  server 1.centos.pool.ntp.org iburst
  server 2.centos.pool.ntp.org iburst
  server 3.centos.pool.ntp.org iburst

chrony サービスを起動

$ sudo systemctl start chronyd

同期の確認

169.254.169.123 を参照していることを確認

$ chronyc tracking
Reference ID    : A9FEA97B (169.254.169.123)
Stratum         : 4
Ref time (UTC)  : Sun Dec 03 09:53:05 2017
System time     : 0.000008275 seconds fast of NTP time
Last offset     : +0.000009504 seconds
RMS offset      : 0.000009557 seconds
Frequency       : 7.661 ppm slow
Residual freq   : +0.005 ppm
Skew            : 0.112 ppm
Root delay      : 0.002082497 seconds
Root dispersion : 0.000339727 seconds
Update interval : 64.7 seconds
Leap status     : Normal

169.254.169.123 が優先 (^*) されていることを確認

$ chronyc sources -v
210 Number of sources = 5

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* 169.254.169.123               3   6   377    43  +3901ns[+4528ns] +/- 1370us
^- jp.dan.me.uk                  2   6   377    43  -5827us[-5826us] +/-  168ms
^- sv1.localdomain1.com          2   6   377   109    +45us[  +36us] +/-   17ms
^- extendwings.com               2   6   357    42   -112us[ -112us] +/-  190ms
^- x.ns.gin.ntt.net              2   6   377    45   +570us[ +571us] +/-   72ms

参照している各ソースの誤差のレートとオフセットの推定プロセスについての情報を確認

$ chronyc sourcestats -v
210 Number of sources = 5
                             .- Number of sample points in measurement set.
                            /    .- Number of residual runs with same sign.
                           |    /    .- Length of measurement set (time).
                           |   |    /      .- Est. clock freq error (ppm).
                           |   |   |      /           .- Est. error in freq.
                           |   |   |     |           /         .- Est. offset.
                           |   |   |     |          |          |   On the -.
                           |   |   |     |          |          |   samples. \
                           |   |   |     |          |          |             |
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
169.254.169.123             9   5   330     -0.030      0.168   -639ns    10us
jp.dan.me.uk                9   7   330     +0.464      1.558  -5684us    94us
sv1.localdomain1.com        7   4   265     -0.096      0.492    +10us    19us
extendwings.com             8   6   330     +0.376     13.316   +139us   884us
x.ns.gin.ntt.net            9   5   328     +0.288      1.723   +574us   120us

参考

satotech
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした