サーバーの内部時計を、ネットワークを介して正しく調整するプロトコルです。
NTPのインストールをします。
# apt-get install ntp
外部サーバーと時刻合わせを行います。
# /usr/sbin/ntpdate NTP_SERVER_NAME
同期させます
# /usr/sbin/hwclock --systohc
起動時に自動的に同期するように/etc/ntp.confを編集します。
# vi /etc/ntp.conf
#restrict default noquery notrust nomodify ← 行頭に#を入れます。
#restrict 127.0.0.1 ← 行頭に#を入れます。
#restrict 192.168.1.0 mask 255.255.255.0 ← 行頭に#を入れます。
#fudge 127.127.1.0 stratum 3 ← 行頭に#を入れます。
#server 127.127.1.0 ← 行頭に#を入れます。
server xxx.xxx.xxx.xxx ← NTPサーバーのIPアドレスを記述します。
server xxx.xxx.xxx.xxx ← 複数のIPを記入できます。
driftfile /etc/ntp.drift ← と書きます。
logfile /var/log/ntp.log ← と書きます。
サービスを起動します。
# /etc/rc.d/init.d/ntpd start
自動起動を設定します。
# /sbin/chkconfig ntpd on
10分ほど待ってから同期の状態をチェックします。行頭に*がついているかを見ます。
# /usr/sbin/ntpq -p
このままでは、再起動時に/etc/ntpd.confが書き換わってしまうので、/etc/rc.d/rc.localを編集しておきます。
cp /etc/ntp.conf /etc/ntp.conf.bak
#vi /etc/rc.d/rc.local
cat /etc/ntp.conf.bak > /etc/ntp.conf ← と書きます。
/etc/rc.d/init.d/ntpd condrestart ← と書きます。