ytooyamaのブログ

サーバ構築とか、仕事で発見したこととか、趣味のこととかを書いています。

MacがNTPサーバーと同期しない

自宅サーバーでchronyd(NTPサーバー)を動かしているのですが、なんかMacだけ同期しているようでしていないという現象が発生していました。

ntpq -pコマンドを実行して本来ならremoteサーバーと同期(ドメイン前に*がつく)はずなのですが、10分待っても記号がつく様子はありませんでした。

ytooyama$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 raspberrypi.loc 202.181.103.212  3 u   26   64    7    7.389   19.018   1.948

そこで、NTPサーバー側の時刻が正しく設定されているか、公開NTPサーバーと同期されているか確認してみました。

pi@raspi:~ $ chronyc sources
210 Number of sources = 7
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* sv1.localdomain1.com          2  10   377   206  -1949us[-2012us] +/-   38ms
^+ balthasar.gimasystem.jp       3  10   363   609   -519us[ -567us] +/- 7668us
^- y.ns.gin.ntt.net              2   8   363   324    +23ms[  +23ms] +/-  350ms
^- next.kkyy.me                  2  10   377   17m  -2631us[-2664us] +/-  248ms
^- ntp1.jst.mfeed.ad.jp          2  10   377   186  -4611us[-4611us] +/-   93ms
^- ntp2.jst.mfeed.ad.jp          2  10   377   319  -2203us[-2262us] +/-   77ms
^- ntp3.jst.mfeed.ad.jp          2  10   377   312  -1938us[-1997us] +/-  126ms

ん?Stratum2と3が混じっていますね。時刻のズレもドメインごとに結構違うみたい。 Reachの値もちょっと違うドメインがあるし。

pi@raspi:~ $ sudo vi /etc/chrony/chrony.conf
...
#server 0.debian.pool.ntp.org offline minpoll 8   ←ここら辺をコメントアウト
#server 1.debian.pool.ntp.org offline minpoll 8
#server 2.debian.pool.ntp.org offline minpoll 8
#server 3.debian.pool.ntp.org offline minpoll 8
server ntp1.jst.mfeed.ad.jp offline minpoll 8
server ntp2.jst.mfeed.ad.jp offline minpoll 8
server ntp3.jst.mfeed.ad.jp offline minpoll 8

pi@raspi:~ $ sudo systemctl restart chrony.service
pi@raspi:~ $ chronyc sources
210 Number of sources = 3
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* ntp1.jst.mfeed.ad.jp          2   8    37     6   -847us[-1001us] +/-   76ms
^+ ntp2.jst.mfeed.ad.jp          2   8    37     6   +438us[ +284us] +/-   81ms
^+ ntp3.jst.mfeed.ad.jp          2   8    37     6   +704us[ +550us] +/-  131ms

3つだけにしました。10分ぐらいしてMacntpq -pコマンドを実行。

ytooyama$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*raspberrypi.loc 210.173.160.27   3 u   12   64   17    7.038   22.474   4.818

OK!

対処をした後に何度かコマンドを実行しましたが、その後はトラブルなく動作しているようです。

このブログサイトはJavaScriptを使っていますが、読み込んでいるJavaScriptは全てはてなが提供しているものであり、筆者が設置しているものではありません。