見出し画像

AWS EC2 AmazonLinux 2023 chrony設定変更


前提条件

EC2 サーバーを作成していることが必須になります。
こちらの内容をご参考にしてください。

ご説明

chrony時刻同期のソフトウェアになります。
デフォルトの設定では、「time.aws.com」を参照いたします。
今回は時刻同期サーバーの変更方法を記載いたします。

chrony現在の設定確認

対象のEC2 サーバーにログインしてください。
下記のコマンドで現在のchronyの設定状況を確認いたします。

chronyc sources

MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* 169.254.169.123               3   4   377    12    +11us[  +14us] +/-  696us
^- ec2-15-152-48-157.ap-nor>     4   6   377    13    -38us[  -34us] +/-  493us
^- ec2-13-208-246-234.ap-no>     4   6   377    12    -23us[  -20us] +/-  471us
^- ec2-15-152-226-72.ap-nor>     4   6   377    12    -60us[  -60us] +/-  469us
^- ec2-13-208-78-139.ap-nor>     4   6   377    13    -12us[-8995ns] +/-  453us

chronyの設定変更

下記のコマンドを実施してください。

vi /etc/sysconfig/chronyd
USE_AMAZON_NTP_POOL="no"

vi /usr/share/chrony/ntp-pool.sources
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (https://www.pool.ntp.org/join.html).

# This will use (up to):
# - 1 source from {0,1,3}.amazon.pool.ntp.org each (IPv4 only atm)
# - 2 sources from 2.amazon.pool.ntp.org which is IPv6 enabled as well
# This means by default, up to 2 dual-stack and up to 3 additional IPv4-only
# sources will be used.
#pool 0.amazon.pool.ntp.org iburst maxsources 1
#pool 1.amazon.pool.ntp.org iburst maxsources 1
#pool 2.amazon.pool.ntp.org iburst maxsources 2
#pool 3.amazon.pool.ntp.org iburst maxsources 1
pool ntp.nict.jp iburst

systemctl restart chronyd

vi /etc/sysconfig/chronyd
viでファイル開いて「yes」から「no」に変更いたします。

vi /usr/share/chrony/ntp-pool.sources
viでファイルを開いて、「amazon.pool.ntp.org」をコメントアウトします。
「pool ntp.nict.jp iburst」を追加いたします。

systemctl restart chronyd
chronydを再起動いたします。

chronyの設定確認

下記のコマンドを実施してください。
時刻同期サーバー変更されたことがわかったと思います。

chronyc sources

MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^? ntp-b3.nict.go.jp             1   6     1     1   -362us[ -362us] +/- 4457us
^? ntp-k1.nict.jp                1   6     1     1    -15us[  -15us] +/- 1743us
^? ntp-b2.nict.go.jp             1   6     1     1   -271us[ -271us] +/- 4587us
^? ntp-a2.nict.go.jp             1   6     1     2   +256us[ +256us] +/- 4338us

以上で「AWS EC2 AmazonLinux 2023 chrony設定変更」完了いたします。


いいなと思ったら応援しよう!