提供:すだちWiki
NTPサーバー構築(chrony)(AlmaLinux9)
メインページ > Category:自宅サーバー > AlmaLinux 9 で自宅サーバー構築 > NTPサーバー構築(chrony)(AlmaLinux9)
Chrony をインストールして、時刻同期サービスを提供する NTP サーバーを構築します。
chrony のインストール
[root@host2 ~]# dnf -y install chrony
chrony サーバー設定
[root@host2 ~]# 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@host2 ~]# systemctl enable --now chronyd
動作確認
[root@host2 ~]# systemctl status chronyd ● chronyd.service - NTP client/server Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; preset: enabled) Active: active (running) since Sat 2024-04-06 16:15:54 JST; 20h ago Docs: man:chronyd(8) man:chrony.conf(5) Main PID: 937 (chronyd) Tasks: 1 (limit: 48236) Memory: 3.0M CPU: 157ms CGroup: /system.slice/chronyd.service mq937 /usr/sbin/chronyd -F 2 4月 06 16:15:53 host2.awajp.com systemd[1]: Starting NTP client/server... 4月 06 16:15:54 host2.awajp.com chronyd[937]: chronyd version 4.3 starting (+CMDMON +NTP +> 4月 06 16:15:54 host2.awajp.com chronyd[937]: Using right/UTC timezone to obtain leap seco> 4月 06 16:15:54 host2.awajp.com chronyd[937]: Loaded seccomp filter (level 2) 4月 06 16:15:54 host2.awajp.com systemd[1]: Started NTP client/server. 4月 06 16:16:03 host2.awajp.com chronyd[937]: Selected source 202.182.111.234 (2.almalinux> 4月 06 16:16:03 host2.awajp.com chronyd[937]: System clock TAI offset set to 37 seconds 4月 06 16:16:05 host2.awajp.com chronyd[937]: Selected source 122.215.240.51 (2.almalinux.> 4月 06 16:16:06 host2.awajp.com chronyd[937]: Selected source 2001:a7ff:102::a
時刻同期状態確認
[root@host2 ~]# chronyc sources -v .-- Source mode '^' = server, '=' = peer, '#' = local clock. / .- Source state '*' = current best, '+' = combined, '-' = not combined, | / 'x' = may be in error, '~' = too variable, '?' = unusable. || .- 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 =============================================================================== ^- time.cloudflare.com 3 10 377 689 +2279us[+2213us] +/- 68ms ^- 122x215x240x51.ap122.ftt> 2 10 377 702 +1085us[+1020us] +/- 38ms ^- 202.182.111.234.vultruse> 2 10 377 141 -629us[ -629us] +/- 14ms ^+ wasabi.ruselabs.com 2 10 377 1014 -607us[ -662us] +/- 9380us ^* 2001:a7ff:102::a 1 9 377 355 +864us[ +787us] +/- 6234us ^+ 2001:a7ff:102::b 1 10 377 713 +1195us[+1130us] +/- 6314us
[root@host2 ~]# chronyc sources MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^- time.cloudflare.com 3 10 377 768 +2279us[+2213us] +/- 68ms ^- 122x215x240x51.ap122.ftt> 2 10 377 781 +1085us[+1020us] +/- 38ms ^- 202.182.111.234.vultruse> 2 10 377 220 -629us[ -629us] +/- 14ms ^+ wasabi.ruselabs.com 2 10 377 63 -551us[ -551us] +/- 9555us ^* 2001:a7ff:102::a 1 9 377 435 +864us[ +787us] +/- 6234us ^+ 2001:a7ff:102::b 1 10 377 793 +1195us[+1130us] +/- 6314us