[Linux] CentOSの時刻同期設定
今回はCentOSの時刻同期設定です。
時刻同期っていうのは、Windowsで言うところのインターネット時刻ってやつです。
Windowsと違ってCentOSではNTPサーバーを構築してから設定することになっているようです。
端末を開いたら管理者権限に切り替えてntpをインストールします。
# yum -y install ntp
# yum -y install ntp Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: ftp.nara.wide.ad.jp * extras: ftp.nara.wide.ad.jp * updates: ftp.nara.wide.ad.jp Setting up Install Process Package ntp-4.2.4p8-2.el6.centos.x86_64 already installed and latest version Nothing to do #
今回はインストール済みでした。
ntp.confファイルを開きいて、18行目の「# restrict 192.168.1.0~の」#を取り除いたら、22~24行目のServerのアドレスを書き換えます。
vim /etc/ntp.conf
# Hosts on local network are less restricted. restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap ←コメントアウトされているので#を取り除く # Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). server ntp.nict.jp ←┐ server ntp1.jst.mfeed.ad.jp ←┼ntpサーバーアドレスに書き換える server ntp2.jst.mfeed.ad.jp ←┘
手動で時刻を合わせます。
# ntpdate ntp.nict.jp
# ntpdate ntp.nict.jp 24 Sep 05:05:00 ntpdate[4105]: step time server 133.243.238.244 offset 13.631124 sec #
ntpdを起動します。
/etc/rc.d/init.d/ntpd start
# /etc/rc.d/init.d/ntpd start Starting ntpd: [ OK ] #
OS起動時のntpd自動起動も設定して、ntpdのステータスを確認します。
# chkconfig ntpd on
# ntpq -p
#chkconfig ntpd on #ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== ntp-b2.nict.go. .NICT. 1 u 13 64 1 20.517 1.662 0.000 ntp1.jst.mfeed. 210.173.176.251 2 u 12 64 1 18.535 2.192 0.000 ntp2.jst.mfeed. 210.173.176.4 2 u 11 64 1 18.330 1.852 0.000 #
起動してから同期が取れるまでに10~20分程度かかりますが、同期が取れるとサーバー名の前に*や+が表示されます。
# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== *ntp-a2.nict.go. .NICT. 1 u 50 64 177 19.071 2.285 0.525 +ntp1.jst.mfeed. 210.173.160.56 2 u 47 64 177 17.168 2.031 0.779 +ntp2.jst.mfeed. 210.173.176.251 2 u 54 64 177 16.980 1.706 0.875 #
以上で時刻同期の設定が完了となります。
ディスカッション
コメント一覧
まだ、コメントがありません