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機能の実装の追記でした。
まずインストール
端末より
# 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機能の実装の追記でした。
コメント 0