NTPサーバー構築(chrony)(AlmaLinux)

提供:あわ自由帳

メインページ > Category:自宅サーバー > AlmaLinux 8 で自宅サーバー構築  > NTPサーバー構築(chrony)(AlmaLinux)

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

chrony のインストール

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

chrony サーバー設定

[root@host3 ~]# 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@host3 ~]# systemctl status chronyd
 chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor pre>
   Active: active (running) since Sun 2019-10-06 08:53:49 JST; 2min 23s ago
     Docs: man:chronyd(8)
           man:chrony.conf(5)
 Main PID: 4274 (chronyd)
    Tasks: 1 (limit: 26213)
   Memory: 1.1M
   CGroup: /system.slice/chronyd.service
           mq4274 /usr/sbin/chronyd

10月 06 08:53:49 host3.sudachi.jp systemd[1]: Starting NTP client/server...
10月 06 08:53:49 host3.sudachi.jp chronyd[4274]: chronyd version 3.3 starting (>
10月 06 08:53:49 host3.sudachi.jp chronyd[4274]: Frequency 0.000 +/- 1000000.00>
10月 06 08:53:49 host3.sudachi.jp chronyd[4274]: Using right/UTC timezone to ob>
10月 06 08:53:49 host3.sudachi.jp systemd[1]: Started NTP client/server.
10月 06 08:53:54 host3.sudachi.jp chronyd[4274]: Selected source 133.243.238.244
10月 06 08:53:54 host3.sudachi.jp chronyd[4274]: System clock TAI offset set to>
10月 06 08:53:56 host3.sudachi.jp chronyd[4274]: Selected source 133.243.238.163
10月 06 08:55:00 host3.sudachi.jp chronyd[4274]: Selected source 133.243.238.164
lines 1-20/20 (END)

時刻同期状態確認

[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