本環境では、サーバーをNTPサーバとしてではなく
NTPクライアントとして機能させる
①chrony パッケージをインストール
yum install chrony
yum install chrony
yum install chrony
②chrony設定
cp /etc/chrony.conf{,.org}
vi /etc/chrony.conf
#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 ntp.jst.mfeed.ad.jp iburst
#NTPクライアントとして動作させる(123番ポートをリッスンしなくなる)
port 0
cp /etc/chrony.conf{,.org}
vi /etc/chrony.conf
#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 ntp.jst.mfeed.ad.jp iburst
#NTPクライアントとして動作させる(123番ポートをリッスンしなくなる)
port 0
cp /etc/chrony.conf{,.org} vi /etc/chrony.conf #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 ntp.jst.mfeed.ad.jp iburst #NTPクライアントとして動作させる(123番ポートをリッスンしなくなる) port 0
デフォルトのserver0~3をコメントアウトし、ntp.nict.jpとntp.jst.mfeed.ad.jpを追記する
また、本サーバーはNTPクライアントとして機能させるのでport0を追記する
③NTPサーバー起動
chronyc makestep
systemctl restart chronyd
systemctl enable chronyd
systemctl status chronyd
chronyc makestep
systemctl restart chronyd
systemctl enable chronyd
systemctl status chronyd
chronyc makestep systemctl restart chronyd systemctl enable chronyd systemctl status chronyd
ステータス確認し、正常に起動していることを確認
④時刻同期確認
chronyc sources
210 Number of sources = 2
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* ntp-k1.nict.jp 1 10 377 313 -20us[ -18us] +/- 5356us
^- ntp3.jst.mfeed.ad.jp 2 10 377 435 -9805ns[-7744ns] +/- 81ms
# ss -taun | grep 123
chronyc sources
210 Number of sources = 2
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* ntp-k1.nict.jp 1 10 377 313 -20us[ -18us] +/- 5356us
^- ntp3.jst.mfeed.ad.jp 2 10 377 435 -9805ns[-7744ns] +/- 81ms
# ss -taun | grep 123
chronyc sources 210 Number of sources = 2 MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^* ntp-k1.nict.jp 1 10 377 313 -20us[ -18us] +/- 5356us ^- ntp3.jst.mfeed.ad.jp 2 10 377 435 -9805ns[-7744ns] +/- 81ms # ss -taun | grep 123
いずれかのNTPサーバーに*がついていれば同期ができている
ss -taun | grep 123のコマンド結果が特に表示されず、プロンプトが返ってくれば123番portをリッスンしていない状態なのでOK
■参考
https://centossrv.com/chrony.shtml
https://www.server-world.info/query?os=CentOS_7&p=ntp&f=3
https://server.etutsplus.com/centos-7-chrony-ntp-client/
コメント