9:NTPサーバーの設定

Date 2014-5-5 21:32:22 | Topic: Linux (サーバー制作)

ntpサーバーはインストールされていたので、その設定ファイルの /etc/ntp.conf の設定
restrict 192.168.xx.xx mask 255.255.255.0 nomodify notrap ← 18行目位、先頭の#を外し、IPレンジを自分に合わせる
**ここから(20行目位)
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
**ここまで消去、centosのntpは使わない。代わりに次を挿入
server 133.100.10.8 iburst # NTPサーバー(stratum 1)
server 210.173.160.27 iburst # 上記サーバーと直接同期しているNTPサーバー(stratum 2)
server 202.224.32.4 iburst # プロバイダのNTPサーバー※

サーバーをIPアドレスで設定しているのはDNSを引かなくて済むから
一度手動で時刻を合わせる
# ntpdate 133.243.238.163
 6 May 06:08:25 ntpdate[17950]: step time server 133.243.238.163 offset -29.735837 sec

ntpを起動する
# service ntpd start
# chkconfig ntpd on
NTPサーバーへの時刻同期状態確認
# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
 ==============================================================================
*ntp-b2.nict.go. .NICT.           1 u    2   64    1    5.517    0.712   0.098
 ntp1.jst.mfeed. 172.29.2.50      2 u    1   64    1  258.952  -126.97  45.508
 orion.asahi-net 133.243.238.244  2 u    -   64    1    3.856    0.853   0.466

行の最初に * や + がついて入ればOK、ない時は数分後に再度行うと表示される筈。
CentOSはシステム終了時にハードウェアクロックの時刻をシステムクロックの時刻に合わせるようになっているらしいが、このサーバーは原則、動きっぱなしなのでハードウェアのクロックとも同期をさせるが、週に1度ぐらいでいいと思うので、/etc/cron.weeklyにsethcと言う名で
#!/bin/bash
hwclock -- systohc
実行フラグを付ける
# chmod +x /etc/cron.weekly/sethc
これで一週間に1回システム時間とハードウェアのクロックを同期する。


This article comes from 錦稜会 KINRYOKAI
https://www.kinryokai.net

The URL for this story is:
https://www.kinryokai.net/article.php?storyid=213