作業日記@HatenaBlog

各種の作業メモ

NTPによる時刻同期

rc.confに設定追加

/etc/defaults/rc.conf から、設定ファイルをコピーする。

# grep ntpd_ /etc/defaults/rc.conf >> /etc/rc.conf

ntpd_conf="NO"をYESに変更。

# vi /etc/rc.conf
ntpd_enable="YES"               # Run ntpd Network Time Protocol (or NO).
ntpd_program="/usr/sbin/ntpd"   # path to ntpd, if you want a different one.
ntpd_config="/etc/ntp.conf"     # ntpd(8) configuration file
ntpd_sync_on_start="NO"         # Sync time on ntpd startup, even if offset is high
ntpd_flags="-p /var/run/ntpd.pid -f /var/db/ntpd.drift"

/etc/ntp.confを作成

# vi /etc/ntp.conf
server 210.173.160.27 # ntp1.jst.mfeed.ad.jp
server 210.173.160.57 # ntp2.jst.mfeed.ad.jp
server 210.173.160.87 # ntp3.jst.mfeed.ad.jp

ntpdateコマンドで同期

# ntpdate 210.173.160.27

ntpd起動

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

同期確認

# ntpq -p
同期中
      remote           refid      st t when poll reach   delay   offset  jitter
 ==============================================================================
  ntp1.jst.mfeed. 210.173.160.56   2 u    7   64    3   18.523   -9.362   0.171
  ntp2.jst.mfeed. 210.173.160.56   2 u    7   64    3   18.486   -9.268   1.219
  ntp3.jst.mfeed. 210.173.160.86   2 u    5   64    3   19.010   -9.754   0.704
同期完了(左端に*が付けば完了)
      remote           refid      st t when poll reach   delay   offset  jitter
 ==============================================================================
 *ntp1.jst.mfeed. 210.173.176.251  2 u  196  256   17   17.467  -16.066   1.981
 +ntp2.jst.mfeed. 210.173.160.86   2 u  195  256   17   17.337  -14.714   2.458
 +ntp3.jst.mfeed. 210.173.160.56   2 u  194  256   17   16.943  -16.279   2.428
参考URL(NTPサーバを構築する場合)

http://www.kishiro.com/FreeBSD/ntp.html