(前回からの続き)
システム更新
1 |
# yum update |
タイムゾーン設定
変更前確認
1 2 3 4 5 6 7 8 9 10 11 |
# date Wed Sep 1 05:04:58 UTC 2021 # timedatectl Local time: Wed 2021-09-01 05:05:13 UTC Universal time: Wed 2021-09-01 05:05:13 UTC RTC time: Wed 2021-09-01 05:05:13 Time zone: n/a (UTC, +0000) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: n/a |
設定変更
1 2 3 |
# timedatectl list-timezones | grep Los_Angeles America/Los_Angeles # timedatectl set-timezone America/Los_Angeles |
変更後確認
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# date Tue Aug 31 22:06:06 PDT 2021 # timedatectl Local time: Tue 2021-08-31 22:06:20 PDT Universal time: Wed 2021-09-01 05:06:20 UTC RTC time: Wed 2021-09-01 05:06:20 Time zone: America/Los_Angeles (PDT, -0700) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2021-03-14 01:59:59 PST Sun 2021-03-14 03:00:00 PDT Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2021-11-07 01:59:59 PDT Sun 2021-11-07 01:00:00 PST |
ホスト名設定
変更前確認
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# hostname ip-xxx-xxx-xxx-xxx.us-west-1.compute.internal # hostnamectl Static hostname: ip-xxx-xxx-xxx-xxx.us-west-1.compute.internal Icon name: computer-vm Chassis: vm Machine ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Boot ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Virtualization: xen Operating System: Amazon Linux 2 CPE OS Name: cpe:2.3:o:amazon:amazon_linux:2 Kernel: Linux 4.14.243-185.433.amzn2.x86_64 Architecture: x86-64 |
設定変更
1 |
# hostnamectl set-hostname myserver.mydomain.com |
変更後確認
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# hostname myserver.mydomain.com # hostnamectl Static hostname: myserver.mydomain.com Icon name: computer-vm Chassis: vm Machine ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Boot ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Virtualization: xen Operating System: Amazon Linux 2 CPE OS Name: cpe:2.3:o:amazon:amazon_linux:2 Kernel: Linux 4.14.243-185.433.amzn2.x86_64 Architecture: x86-64 |
chrony(時刻同期)のインストール
もしNTPサービスがインストールされていたらアンインストール
1 |
# yum erase 'ntp*' |
chronyをインストール
1 |
# yum install chrony |
設定確認
1 2 3 |
# vi /etc/chrony.conf 以下の行が存在することを確認する server 169.254.169.123 prefer iburst minpoll 4 maxpoll 4 |
起動
1 |
# service chronyd restart |
自動起動をオンにする
1 |
# chkconfig chronyd on |
動作確認
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# 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 =============================================================================== ^* 169.254.169.123 3 4 17 7 +4251ns[+2773ns] +/- 462us ^- tick.srs1.ntfo.org 3 6 17 6 -1224us[-1224us] +/- 107ms ^- li1210-167.members.linod> 2 6 17 7 -88us[ -90us] +/- 42ms ^- 44.190.6.254 1 6 17 7 +63us[ +61us] +/- 2319us ^- ntp2i.versadns.com 2 6 17 7 +4272us[+4271us] +/- 45ms # chronyc tracking Reference ID : A9FEA97B (169.254.169.123) Stratum : 4 Ref time (UTC) : Wed Sep 01 05:25:34 2021 System time : 0.000002313 seconds fast of NTP time Last offset : +0.000003001 seconds RMS offset : 0.000006041 seconds Frequency : 1.454 ppm fast Residual freq : -0.053 ppm Skew : 0.959 ppm Root delay : 0.000397119 seconds Root dispersion : 0.000269764 seconds Update interval : 16.2 seconds Leap status : Normal |
(次回へ続く)
参考サイト
Set the time for your Linux instance
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html