提供: すだちWiki
移動先: 案内検索

ヘルプ:NTPサーバー構築(chrony)(CentOS8)

メインページ > ヘルプ:目次 > ヘルプ:自宅サーバー構築(CentOS8)  > NTPサーバー構築(chrony)(CentOS8)

Chrony をインストールして、時刻同期サービスを提供する NTP サーバーを構築します。

chrony のインストール

[root@host4 ~]# dnf -y install chrony

chrony サーバー設定

[root@host4 ~]# vi /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
#Please consider joining the pool (http://www.pool.ntp.org/join.html).
# 同期をとるサーバーを変更
#pool 2.centos.pool.ntp.org iburst
pool ntp.nict.jp iburst

# Allow NTP client access from local network.
# 内部からの時刻同期を許可
#allow 192.168.0.0/16
allow 192.168.1.0/24

chronyd の起動

[root@host4 ~]# systemctl enable --now chronyd

動作確認

[root@host4 ~]# systemctl status chronyd
 chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor pre>
   Active: active (running) since Mon 2020-03-09 20:09:27 JST; 14h ago
     Docs: man:chronyd(8)
          man:chrony.conf(5)
 Main PID: 1373 (chronyd)
    Tasks: 1 (limit: 26213)
   Memory: 2.1M
   CGroup: /system.slice/chronyd.service
           mq1373 /usr/sbin/chronyd

 3月 09 20:09:26 host3.sudachi.jp systemd[1]: Starting NTP client/server...
 3月 09 20:09:26 host3.sudachi.jp chronyd[1373]: chronyd version 3.5 starting (+CMDMON +NTP +REFCLOC>
 3月 09 20:09:26 host3.sudachi.jp chronyd[1373]: Using right/UTC timezone to obtain leap second data
 3月 09 20:09:27 host3.sudachi.jp systemd[1]: Started NTP client/server.
 3月 09 20:09:47 host3.sudachi.jp chronyd[1373]: Selected source 202.181.103.212
 3月 09 20:09:47 host3.sudachi.jp chronyd[1373]: System clock TAI offset set to 37 seconds
 3月 09 20:10:52 host3.sudachi.jp chronyd[1373]: Selected source 122.215.240.51
 3月 10 01:43:21 host3.sudachi.jp chronyd[1373]: Selected source 202.181.103.212

時刻同期状態確認

[root@host4 ~]# 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
===============================================================================
^+ ntp-b2.nict.go.jp             1   6   377     6  -5220us[-5220us] +/-   10ms
^* ntp-b3.nict.go.jp             1   6   377     7  -3998us[-5985us] +/-   11ms
^+ ntp-a3.nict.go.jp             1   6   375     4  +7775us[+7775us] +/-   23ms
^+ ntp-a2.nict.go.jp             1   6   377     4  +7578us[+7578us] +/-   24ms
[root@host4 ~]# chronyc sources
210 Number of sources = 4
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^- ntp-b2.nict.go.jp             1   6   377    74  +3988us[+1936us] +/-   18ms
^- ntp-b3.nict.go.jp             1   6   377     9    +11ms[  +11ms] +/-   26ms
^- ntp-a3.nict.go.jp             1   6   357     7  +7422us[+7422us] +/-   22ms
^- ntp-a2.nict.go.jp             1   6   377     8    +12ms[  +12ms] +/-   26ms