ntpdのLeap Smearingを有効にし、うるう秒を24時間かけて調整する

うるう秒を挿入せず、1秒分を長い時間で少しずつ適応することでソフトウェアなどのバグを回避する Leap Smearingは ntpdでも使用できる。


4.2.8.p3 と 4.3.47以降でサポートしているが、defaultでは無効になっているので自身でビルドする必要がある。

ubuntu 16.04で試す

wget http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/ntp-4.2.8p9.tar.gz
tar zxvf ./ntp-4.2.8p9.tar.gz
cd ./ntp-4.2.8p9/
./configure --enable-leap-smear
make


動作確認(既存のntpdが起動してれば事前に切っておく)
ntpq -c rv で leapsmearinterval が表示される

$ echo 'leapsmearinterval 86400' | sudo tee -a /etc/ntp.conf
$ sudo ./ntpd/ntpd

$ ntpq -c rv
associd=0 status=0618 leap_none, sync_ntp, 1 event, no_sys_peer,
version="ntpd 4.2.8p9@1.3265-o Thu Dec  1 13:54:30 UTC 2016 (1)",
processor="x86_64", system="Linux/4.4.0-31-generic", leap=00, stratum=3,
precision=-23, rootdelay=8.972, rootdisp=292.929, refid=59.106.180.168,
reftime=dbeab436.6e302275  Thu, Dec  1 2016 14:37:42.430,
clock=dbeab49a.75ac45a4  Thu, Dec  1 2016 14:39:22.459, peer=58337, tc=6,
mintc=3, offset=-86.392728, frequency=-125.660, sys_jitter=0.000000,
clk_jitter=28.609, clk_wander=2.963, leapsmearinterval=86400,
leapsmearoffset=0.000

おまけ

現在IETFで「Network Time Protocol Best Current Practices」として、NTPのベスト・プラクティスが書かれている。


section 4.6.1でLeap Smearingについて書かれている。パブリックサーバとして使用しないように勧められている他、現在のサーバ構成を把握しSmearingしてるサーバとSmearingしてないサーバを混在させないようにすることが推奨されている