CentOSに日本時間設定する
CentOSに日本時間設定する
環境
CentOS6
手順
現在の日時確認
[root@lb01 ~]# date 2017年 1月 15日 日曜日 01:50:05 PST
実際は「2017年 1月 15日 日曜日 09:54:05」
約8時間ずれてる。
CentOSのタイムゾーンを設定しているファイルlocaltimeファイルに日本時間用ファイルを適用
[root@lb01 ~]# cp -p /usr/share/zoneinfo/Japan /etc/localtime
NTPサーバーのインストール
[root@lb01 ~]# yum -y install ntp
NTPサーバーの日付を設定
[root@lb01 ~]# ntpdate ntp.nict.jp 15 Jan 09:57:44 ntpdate[2389]: step time server 133.243.238.163 offset -32182.482955 sec
ntp.confの編集
[root@lb01 ~]# vi /etc/ntp.conf
「centos.pool.ntp.org」の行をコメントアウトし、「server -4 ntp 〜」の行を追加する。
#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
追記
server -4 ntp.nict.jp server -4 ntp1.jst.mfeed.ad.jp server -4 ntp2.jst.mfeed.ad.jp server -4 ntp3.jst.mfeed.ad.jp
ntpdデーモン起動
[root@lb01 ~]# /etc/init.d/ntpd start
設定後は、日本時間がずれなく表示されてる
[root@lb01 ~]# date 2017年 1月 15日 日曜日 10:00:36 JST
※2017年1月29日追記
上記設定は簡易版なので、NTPの設定は下記記事より。