以下で説明する例は、基本的な NTP サーバーとクライアント用です。 NTP は Network Transport Protocol の略で、時刻を取得するための共通の信頼できるソースを使用して、サーバー上の時刻を相互に同期させるために使用されます。
NTP サーバーの構成
1. 必要な ntp パッケージをサーバーにインストールします。
# yum install ntp
2. 次のエントリが ntp 構成ファイル /etc/ntp.conf にあることを確認します。 .
# cat /etc/ntp.conf restrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery restrict 127.0.0.1 restrict -6 ::1 server 0.pool.ntp.org server 1.pool.ntp.org server 2.pool.ntp.org server 3.pool.ntp.org restrict 10.10.10.0 mask 255.255.255.0 nomodify notrap driftfile /var/lib/ntp/drift keys /etc/ntp/keys
構成ファイルによると、NTP サーバーはサブネット 10.10.10.0/24 内の NTP クライアントにのみサーバーを提供します。お住まいの地域に固有の公開 NTP サーバーは、pool.ntp.org から入手できます。
/etc/ntp.conf ファイルで、環境内の NTP サーバーについて言及する必要があります。
3. これで、ntpd サービスを開始できます。
RHEL 5、6 の場合 :
# service ntpd start
RHEL 7 の場合 :
# systemctl start ntpd.service
NTP クライアントの構成
1. クライアントの NTP 構成については、/etc/ntp.conf に以下の構成を追加します。 ファイル。
# cat /etc/ntp.conf restrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery restrict 127.0.0.1 restrict -6 ::1 server ntp.server.com driftfile /var/lib/ntp/drift keys /etc/ntp/keys
ここで、ntp.server.com は、投稿の冒頭で示した例で NTP サーバーとして構成したサーバーです。冗長性のために複数の NTP サーバーを使用できます。 /etc/ntp.conf ファイルに NTP サーバーごとに新しい行を追加します。
2. ntp クライアント サーバーで ntpd サービスを開始します。
RHEL 5、6 の場合 :
# service ntpd start
RHEL 7 の場合 :
# systemctl start ntpd.service