Ntp Howto

提供:あべたけの覚書
ナビゲーションに移動 検索に移動

Network Time Protocol(ネットワーク・タイム・プロトコル)は、ネットワークに接続される機器において、機器が持つ時計を正しい時刻へ同期するための通信プロトコル。

目的

時刻の同期。

インストール

# yum install ntp

設定

  1. ntp.confの修正
    [root@hoge ~]# vi /etc/ntp.conf
    
     #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
    restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap ← 追加(内部からの時刻同期を許可)
    server 0.rhel.pool.ntp.org
    server 1.rhel.pool.ntp.org
    server 2.rhel.pool.ntp.org
    ↓
    時刻同期先NTPサーバーを変更
    server -4 ntp.nict.jp # 日本標準時を提供しているNTPサーバー(stratum 1)
    server -4 ntp.jst.mfeed.ad.jp # 上記サーバーと直接同期しているNTPサーバー(stratum 2)
    server -4 プロバイダのNTPサーバー名 # プロバイダのNTPサーバー


  2. 手動で時刻合わせ。
    NTPサーバー起動時に大幅に時刻がずれているとNTPサーバーが起動できないので、いったん、手動で時刻を合わせる。
    [root@hoge ~]# ntpdate ntp.nict.jp ← 手動で時刻を合わせる


  3. 起動、自動起動の設定
    [root@hoge ~]# /etc/rc.d/init.d/ntpd start ← NTPサーバー起動
    ntpd を起動中:                                             [  OK  ]
    
    [root@hoge ~]# chkconfig ntpd on ← NTPサーバー自動起動設定
    
    [root@hoge ~]# chkconfig --list ntpd ← NTPサーバー自動起動設定確認
    ntpd            0:off   1:off   2:on    3:on    4:on    5:on    6:off ← ランレベル2~5のonを確認