■debian stretchにntpdを導入する。
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.1 (stretch)
Release: 9.1
Codename: stretch
$ sudo apt-get install -y ntp
■デフォルトの時刻同期参照先を無効化
$ sudo sed -i -e 's/^pool/# &/' /etc/ntp.conf
$ grep "^# pool" /etc/ntp.conf
■自ネットワークの時刻同期参照先を設定
iburstによる同期高速化を指定する。
$ grep ^server /etc/ntp.conf
server -4 172.31.31.252 iburst
■ntpデーモンの再起動、階層(stratum)3で、
正常に同期(leap=00)していることを確認。
$ sudo systemctl restart ntp.service
$ watch -d -n 1 'ntpq -pn -c rv'
Every 1.0s: ntpq -pn -c rv vm-stretch: Tue Aug 1 22:01:11 2017
remote refid st t when poll reach delay offset jitter
==============================================================================
*172.31.31.252 78.73.67.84 2 u 5 64 1 0.471 -0.015 0.424
associd=0 status=0614 leap_none, sync_ntp, 1 event, freq_mode,
version="ntpd 4.2.8p10@1.3728-o Sun May 7 22:26:51 UTC 2017 (1)",
processor="x86_64", system="Linux/4.9.0-3-amd64", leap=00, stratum=3,
precision=-24, rootdelay=39.762, rootdisp=209.193, refid=172.31.31.252,
reftime=dd2afa12.e621a54f Tue, Aug 1 2017 22:01:06.898,
clock=dd2afa17.56606af9 Tue, Aug 1 2017 22:01:11.337, peer=31741, tc=6,
mintc=3, offset=0.418392, frequency=0.000, sys_jitter=0.000000,
clk_jitter=0.207, clk_wander=0.000
$ sudo tail -f /var/log/syslog | grep --color ntp
Aug 1 22:07:09 vm-stretch ntp[19630]: Starting NTP server: ntpd.
Aug 1 22:07:09 vm-stretch ntpd[19641]: proto: precision = 0.063 usec (-24)
Aug 1 22:07:09 vm-stretch ntpd[19641]: Listen and drop on 0 v6wildcard [::]:123
Aug 1 22:07:09 vm-stretch ntpd[19641]: Listen and drop on 1 v4wildcard 0.0.0.0:123
Aug 1 22:07:09 vm-stretch ntpd[19641]: Listen normally on 2 lo 127.0.0.1:123
Aug 1 22:07:09 vm-stretch ntpd[19641]: Listen normally on 3 ens192 172.31.31.70:123
Aug 1 22:07:09 vm-stretch ntpd[19641]: Listen normally on 4 lo [::1]:123
Aug 1 22:07:09 vm-stretch ntpd[19641]: Listen normally on 5 ens192 [fe80::20c:29ff:fe45:ba0f%2]:123
Aug 1 22:07:09 vm-stretch ntpd[19641]: Listening on routing socket on fd
■統計ログを有効にする。
$ grep log /etc/ntp.conf
$ grep drift /etc/ntp.conf
driftfile /var/lib/ntp/ntp.drift
$ sudo sed -i -e 's/^#\(statsdir\)/\1/' /etc/ntp.conf
$ sudo systemctl restart ntp.service
$ ls /var/lib/ntp/ /var/log/ntpstats/
/var/lib/ntp/:
ntp.drift
/var/log/ntpstats/:
loopstats loopstats.20170801 peerstats peerstats.20170801