LoginSignup
24

More than 5 years have passed since last update.

CentOS7の時刻をChronyを使ってNICTと同期する

Last updated at Posted at 2015-12-10

はじめに

CentOSのisoでminimal版をダウンロードしてくると、何も入っていなくて色々勉強になる。

時刻が狂ってることに気付き、ntpdで同期しようとしたけど、
興味本位で今っぽくChronyを使い、同期先は日本の標準時を作っているNICTにしてみた。

そもそもChronyってなんだ?

CentOS7から導入されたntp兼サーバ。
OS上にntpdもchronyも共存させることは可能だが、
排他的な関係になっていて、どちらか一方が起動すると、もう片方は停止する。

Chronyのインストール

# yum install -y chrony

NICTと同期する設定

/etc/chrony.conf
# 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 ntp.nict.jp iburst

# Ignore stratum in source selection.
stratumweight 0

# Record the rate at which the system clock gains/losses time.
省略

尚、iburstを指定すると、短い間隔で4回問い合わせをするので、
妥当性の判断と同期が早くなるとのこと。

自動起動設定

# systemctl enable chronyd

起動, 同期確認

[root@localhost ~]# systemctl start chronyd
[root@localhost ~]# systemctl status chronyd
chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled)
   Active: active (running) since 火 2015-12-08 10:11:15 JST; 3s ago
  Process: 817 ExecStartPost=/usr/libexec/chrony-helper add-dhclient-servers (code=exited, status=0/SUCCESS)
  Process: 814 ExecStart=/usr/sbin/chronyd -u chrony $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 816 (chronyd)
   CGroup: /system.slice/chronyd.service
           └─816 /usr/sbin/chronyd -u chrony

12月 08 10:11:15 localhost.localdomain chronyd[816]: chronyd version 1.29.1 starting
12月 08 10:11:15 localhost.localdomain chronyd[816]: Linux kernel major=3 minor=10 patch=0
12月 08 10:11:15 localhost.localdomain chronyd[816]: hz=100 shift_hz=7 freq_scale=1.00000000 nominal_tick=10000 sl...ll=2
12月 08 10:11:15 localhost.localdomain chronyd[816]: Frequency 380.740 +/- 3.765 ppm read from /var/lib/chrony/drift
12月 08 10:11:15 localhost.localdomain systemd[1]: Started NTP client/server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]#
[root@localhost ~]# date
2015年 12月 10日 木曜日 23:11:48 JST

参考

Chrony本家

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24