0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

前提

NTP サーバとして Chrony のインストールは完了したので、今日は NTP の設定をしていく。
Chrony のインストールはこちらを参照あれ。

環境

Ubuntu 22.04
Chrony 4.2
構成図:
image.png

設定

NTP サーバ

$ sudo vi /etc/chrony/chrony.conf
pool ntp.nict.jp iburst
allow 192.168.0.0/16
$ chronyc sources
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^+ ntp-a2.nict.go.jp             1   6   177    19   +418us[ +418us] +/- 1623us
^- ntp-k1.nict.jp                1   6   177    20    +13us[  +18us] +/- 6348us
^* ntp-b2.nict.go.jp             1   6   177    20  +9339ns[  +14us] +/- 1832us
^+ ntp-b3.nict.go.jp             1   6   177    19   +154us[ +154us] +/- 1763us

NTP クライアント

設定前の確認
Status を見ると、ntp.ubuntu.comになってるのがわかる。というわけで、まだntp.j-fortidemo.comとは同期してないことがわかる。

$ sudo systemctl status systemd-timesyncd
[sudo] password for aito: 
Sorry, try again.
[sudo] password for aito: 
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-12-08 14:30:07 UTC; 1 day 11h ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 658 (systemd-timesyn)
     Status: "Initial synchronization to time server 185.125.190.57:123 (ntp.ubuntu.com)."
      Tasks: 2 (limit: 1029)
     Memory: 1.3M
        CPU: 671ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─658 /lib/systemd/systemd-timesyncd
$ sudo timedatectl 
               Local time: Sat 2022-12-10 01:52:36 UTC
           Universal time: Sat 2022-12-10 01:52:36 UTC
                 RTC time: Sat 2022-12-10 01:52:36
                Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

というわけで、同期させましょう。

$ sudo vi /etc/systemd/timesyncd.conf

NTP=ntp.j-fortidemo.com

よし、同期できた!

$ sudo systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-12-10 02:25:56 UTC; 3s ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 7978 (systemd-timesyn)
     Status: "Connecting to time server 192.168.10.249:123 (ntp.j-fortidemo.com)."
      Tasks: 2 (limit: 1029)
     Memory: 1.3M
        CPU: 118ms
     CGroup: /system.slice/systemd-timesyncd.service
             └─7978 /lib/systemd/systemd-timesyncd

でも、Time zone は変わらないので、これも変えておきましょう。

$ sudo timedatectl set-timezone Asia/Tokyo
$ sudo timedatectl 
               Local time: Sat 2022-12-10 11:30:08 JST
           Universal time: Sat 2022-12-10 02:30:08 UTC
                 RTC time: Sat 2022-12-10 02:30:08
                Time zone: Asia/Tokyo (JST, +0900)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

完!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?