Server Technical Memo

TOPに戻る

ntpサーバーの設定

サーバーの正確な時間をセットする為にNTPクライアントを使ってNTPタイムサーバーに情報を取りに行く様に設定します。

(1)まず最初にntp.confを修正します


#vi /etc/ntp.conf

ファイルを開いたら



#
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available. The
# default stratum is usually 3, but in this case we elect to use stratum
# 0. Since the server line does not have the prefer keyword, this driver
# is never used for synchronization, unless no other other
# synchronization source is available. In case the local host is
# controlled by some external source, such as an external oscillator or
# another protocol, the prefer keyword would cause the local host to
# disregard all other synchronization sources, unless the kernel
# modifications are in use and declare an unsynchronized condition.
#
#server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10

#
# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
#
driftfile /etc/ntp/drift
multicastclient # listen on default 224.0.1.1
broadcastdelay 0.008

#
# Keys file. If you want to diddle your server at run time, make a
# keys file (mode 600 for sure) and define the key number to be
# used for making requests.
#
# PLEASE DO NOT USE THE DEFAULT VALUES HERE. Pick your own, or remote
# systems might be able to reset your clock at will. Note also that
# ntpd is started with a -A flag, disabling authentication, that
# will have to be removed as well.
#
#keys /etc/ntp/keys


このファイルの最後に各プロバイダでも公開されているntpサーバーまたは、
国内公開 ntp サイト一覧
などを参考にして

server ***.***.***.***

の行を追加します。(***はntpサーバーアドレス)


(2)ntp.confを修正して保存したら、ntpサーバーと同期をとるために
ntpdateコマンドで時計を合わせ直します。

#/etc/rc.d/init.d/ntpd stop
#/usr/sbin/ntpdate 210.173.160.57

(3)NTPDを起動します。


#/etc/rc.d/init.d/ntpd start

(4)動作確認


#/usr/sbin/ntpq -p
 remote  refid      st t when poll  reach delay offset  jitter
==============================================================================
*ntp2.jst.mfeed. 210.173.160.86  2 u  3 64 1 39.731 21.946 0.002


しばらくして*が表示されたら同期完了です。(ローカルの時計との誤差が+-1分ぐらいでないと同期できません。)

(5)再起動後自動起動するように設定します。


#/sbin/chkconfig ntpd on

投稿者 yuuya : 21:41 | コメント (0) | トラックバック