NTP クライアント Chrony

## 概要
安定した常時接続が前提の NTP デーモン (ntpd) に代わり、モバイルや仮想環境などの不安定な接続環境に対応した **Chrony** [^ntp-choosing] が RHEL 7 (CentOS 7) からデフォルトインストールされるようになった。 [^installing-chrony]

[^ntp-choosing]: https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/ch-Configuring_NTP_Using_the_chrony_Suite.html#sect-Choosing_between_NTP_daemon

[^installing-chrony]: https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Using_chrony.html#sect-Installing_chrony

## インストール
CentOS 7.2.1511 以前では minimal では Chrony がインストールされないので以下の通りインストールする。

```
yum install chrony
sed -i.org /etc/chrony.conf -e '/^server/ s/^/#/'
systemctl enable chronyd && systemctl start chronyd
```

## 公開 NTP サーバー

[公開 NTP サーバー](http://qiita.com/bezeklik/items/6c2ebbc8da774a053704)

## 強制的な時刻同期
```bash
chronyc -a makestep
```
```:出力例
200 OK
200 OK
```

## chrony トラッキングの確認
```bash
chronyc tracking
```
```:出力例
Reference ID    : 157.7.208.12 (timpany.srv.jre655.com)
Stratum         : 3
Ref time (UTC)  : Mon Dec 12 11:29:59 2016
System time     : 0.000663179 seconds fast of NTP time
Last offset     : +0.001061445 seconds
RMS offset      : 0.002669210 seconds
Frequency       : 59.962 ppm slow
Residual freq   : +0.574 ppm
Skew            : 20.360 ppm
Root delay      : 0.009656 seconds
Root dispersion : 0.005571 seconds
Update interval : 65.2 seconds
Leap status     : Normal
```

## chrony ソースの確認
```
chronyc sources -v
```
```:出力例
210 Number of sources = 4

  .-- 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
===============================================================================
^- y.ns.gin.ntt.net              2   6    17    23  +3115us[+3115us] +/-  298ms
^- v157-7-235-92.z1d6.static     2   6    17    22  -2315us[-2315us] +/-  104ms
^- hachi.paina.jp                2   6    17    23  -1007us[-1007us] +/-   34ms
^* ekg.netfort.gr.jp             2   6    17    23    -19us[-1443us] +/-   41ms
```

## chrony ソースの統計情報の確認
```bash
chronyc sourcestats -v
```
```:出力例
210 Number of sources = 4
                             .- 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
==============================================================================
timpany.srv.jre655.com      6   4   136     -1.911    122.287    -74us  2157us
x.ns.gin.ntt.net            6   5   135    +25.199    249.621  +3566us  3308us
v157-7-235-92.z1d6.static   6   5   136    +10.827    477.476  +1529us  6730us
li400-120.members.linode.   6   5   136    +46.856    427.178  +6431us  4876us
```