LoginSignup
6
6

More than 5 years have passed since last update.

時刻同期chronyの導入

Last updated at Posted at 2018-07-28

概要

時刻同期のNTPサーバとして、chronyを導入する。
なおデフォルトでインストールされている。

chronyの導入

chronyのインストール

以下のコマンドでchronyをインストールする。

chronyのインストール
sudo yum -y install chrony

chronyの設定

以下のコマンドで設定ファイルのバックアップを取得する。

chrony.confのバックアップ
sudo cp -piv /etc/chrony.conf /etc/chrony.conf.`date "+%Y%m%d"`

<出力結果>
`/etc/chrony.conf' -> `/etc/chrony.conf.YYYYMMDD'

以下のファイルを編集し、chronyの設定を行う。

/etc/chrony.conf
#Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
### NTP Server begin
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server ntp.nict.jp iburst
server ntp1.jst.mfeed.ad.jp iburst
server ntp2.jst.mfeed.ad.jp iburst
### NTP Server end
(中略)
# Allow NTP client access from local network.
### NTP Server begin
#allow 192.168.0.0/16
allow 192.168.11.0/24
### NTP Server end
(以下、省略)

以下のコマンドでchronyを起動し、再起動時に自動起動するように設定する。

chronyの起動
sudo systemctl restart chronyd
systemctl status chronyd

<出力結果>
● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
   Active: active (running) since 土 2018-07-28 11:12:24 JST; 3h 22min ago
     Docs: man:chronyd(8)
           man:chrony.conf(5)
 Main PID: 639 (chronyd)
   CGroup: /system.slice/chronyd.service
           mq639 /usr/sbin/chronyd

chronyの自動機能設定
sudo systemctl enable chronyd

chronyの動作確認

以下のコマンドで設定したNTPサーバから時刻同期しているかを確認する。

chronyの動作確認
chronyc sources

<出力結果>
210 Number of sources = 3
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* ntp-b2.nict.go.jp             1   6   377    31  +1285us[ +158us] +/- 7948us
^- ntp1.jst.mfeed.ad.jp          2   6   377    31   +669us[ +669us] +/-   74ms
^- ntp2.jst.mfeed.ad.jp          2   6   377    31  +1009us[+1009us] +/-   83ms

次の手順

以上

6
6
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
6
6