SSブログ

NTP機能の実装 [サーバ]

NTP機能を実装して外部サーバと時刻同期を行う。


まずインストール
端末より
# yum install ntp

正常に完了したら
/etc/ntp.conf 設定ファイルを自分の環境に合わせて変更

 # Hosts on local network are less restricted.
 restrict 192.168.11.0 mask 255.255.255.0 nomodify notrap # コメントを外してLAN内のNTPサーバとして機能させる

 # Use public servers from the pool.ntp.org project.
 # Please consider joining the pool (http://www.pool.ntp.org/join.html).
 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
      # ここに同期するNTPサーバを指定する

変更内容を保存する。

続いて動作させる。
端末より
#systemctl start ntpd.service # NTP機能動作開始

#systemctl enable ntpd.service # サービスに登録(起動時自動実行)

$ ntpq -p # 時刻の同期状態の確認
先頭に「*」マークが付いていれば同期中。

以上、NTP機能の実装でした。

その後、サーバを再起動したら
# systemctl enable ntpd.service でサービスに登録しているのに
起動時に自動実行されない事が判明[バッド(下向き矢印)]

調べてみると、Chronyというサービスが実行されていて、これと競合している様子。

端末より
# systemctl stop chrony.service # Chrony停止
# systemctl disable chrony.service # Chronyをサービスから削除

これで、無事NTPの起動時自動実行ができた。


しかし、このChrony、機能はNTPと同様の時刻合わせでCentOS7ではChronyが標準らしい[たらーっ(汗)]
だから、自分でインストールした覚えが無いのにOSインストール時に自動でインストール&サービス登録されているようだ。


なので、Chronyの設定について
まずNTP機能の停止とサービスから削除

端末より
# systemctl stop ntpd.service # NTP停止
# systemctl disable ntpd.service # NTPをサービスから削除

続いて
/etc/chrony.conf 設定ファイルを自分の環境に合わせて変更

 # Use public servers from the pool.ntp.org project.
 # Please consider joining the pool (http://www.pool.ntp.org/join.html).
 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
      # ここに同期するNTPサーバを指定する


 # Allow NTP client access from local network.
 allow 192.168.11/24 # コメントを外してLAN内のクライアントとの同期を許可する

変更内容を保存する。

そして動作させる。
端末より
#systemctl start chronyd.service # NTP機能動作開始

#systemctl enable chronyd.service # サービスに登録(起動時自動実行)


$ chronyc sources # 時刻の同期状態の確認
先頭に「*」マークが付いていれば同期中。

以上、NTP機能の実装の追記でした。
タグ:linux CentOS7 NTP
nice!(0)  コメント(0)  トラックバック(0) 
共通テーマ:日記・雑感

nice! 0

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。

トラックバック 0

トラックバックの受付は締め切りました
Google Play で手に入れよう

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。