takafumi blog

日々の勉強メモ

CentOS7 NTPの設定をchronyで行う

環境   CentOS 7.0

なんかファイルのタイムスタンプがおかしいと思っていたらNTPを設定してなかった。

CentOS7はChronyがntpdに代わり標準とになっている。
ntpdを入れてもいいが、せっかくなので使ってみる。

# インストール
$ yum install chrony

# 設定ファイル編集
$ vi /etc/chrony.conf
$ diff -u /etc/chrony.conf.ORI /etc/chrony.conf
--- /etc/chrony.conf.ORI        2015-03-15 16:45:34.726610119 +0900
+++ /etc/chrony.conf    2015-03-15 16:44:48.485682916 +0900
@@ -1,9 +1,10 @@
 # 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
+#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 ntp.nict.jp iburst

 # Ignore stratum in source selection.
# chronyd起動
$ systemctl start chronyd.service
# 確認
$ lsof -nPi | grep chronyd
chronyd   3516 chrony    1u  IPv4  27304      0t0  UDP *:123
chronyd   3516 chrony    2u  IPv6  27305      0t0  UDP *:123
chronyd   3516 chrony    3u  IPv4  27306      0t0  UDP 127.0.0.1:323
chronyd   3516 chrony    5u  IPv6  27307      0t0  UDP [::1]:323

# 自動起動設定
$ systemctl enable chronyd.service