ntp による時刻同期
サーバの時刻を正しい時刻にするために ntp を使用して同期するようにします。
時刻同期用のサーバは
NICT 公開 NTP サービス
というものがあるようなので、 ntp.nict.jp にします。
まずは ntp 関連のコマンドが入っていないので、インストールを行います。
# apt-get install ntp
次に、結構時間がずれているので、ntpupdate コマンドで時刻をざっくりと合わせます。
# ntpdate ntp.nict.jp
次に、/etc/ntp.conf を編集して設定を行い、ntpd を起動します。
# vi /etc/ntp.conf # /etc/init.d ntpd start
/etc/ntp.conf の中身はこんな感じです。ntp.nict.jp を3つ書くのがポイントらしい。
server ntp.nict.jp server ntp.nict.jp server ntp.nict.jpdriftfile /etc/ntp/drift multicastclient broadcastdelay 0.008
サーバ起動時に自動的に起動するようにしておきます。
# chkconfig --add ntpd # chkconfig ntpd on # chkconfig --list | egrep ntpd ntpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
ある程度時間がたったら、ntpq -p コマンドを実行して、時刻が同期されていることを確認します。
remote refid st t when poll reach delay offset jitter
==============================================================================
*ntp-b2.nict.go. .PPS. 1 u 62 64 177 7.328 0.098 0.763
+ntp-a3.nict.go. .PPS. 1 u 57 64 177 6.152 -0.360 0.312
+ntp-b3.nict.go. .PPS. 1 u 59 64 177 7.778 -0.438 0.296
こんな感じで * が頭についていれば時刻の同期ができています。