文書更新:2019年06月18日(火) 午後1時17分08秒

Home > 備忘録 > 時刻同期 > chrony のインストール( 66 )

Feora18に chrony をインストールすることに関する記録です。

chrony のインストール

  1. ネットワークアドレスを「192.168.64」と仮定する
  2. chrony のインストール
  3. [root@server]# yum install chrony
  4. /etc/chrony.conf の設定
  5. chrony.conf を編集する
    [root@server]# vi /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.fedora.pool.ntp.org iburst	←以下4行をコメントアウトする
    #server 1.fedora.pool.ntp.org iburst
    #server 2.fedora.pool.ntp.org iburst
    #server 3.fedora.pool.ntp.org iburst
    
    server ntp1.jst.mfeed.ad.jp	←ここにntpサーバーを追記する(3行追加)
    server ntp2.jst.mfeed.ad.jp
    server ntp3.jst.mfeed.ad.jp
    
    # Ignore stratum in source selection.
    stratumweight 0
    
    # Record the rate at which the system clock gains/losses time.
    driftfile /var/lib/chrony/drift
    
    # Enable kernel RTC synchronization.
    rtcsync
    
    # In first three updates step the system clock instead of slew
    # if the adjustment is larger than 100 seconds.
    makestep 100 3
    
    # Allow client access from local network.
    #allow 192.168/16
    allow 192.168.64/24	←内部からの時刻同期を許可する範囲(追加)
    
    # Serve time even if not synchronized to any NTP server.
    #local stratum 10
    
    keyfile /etc/chrony.keys
    
    # Specify the key used as password for chronyc.
    commandkey 1
    
    # Disable logging of client accesses.
    noclientlog
    
    # Send a message to syslog if a clock adjustment is larger than 0.5 seconds.
    logchange 0.5
    
    logdir /var/log/chrony
    #log measurements statistics tracking
  6. 手動による時刻合わせ
  7. [root@server]# ntpdate ntp1.jst.mfeed.ad.jp
    20 Feb 10:48:51 ntpdate[10942]: adjust time server 210.173.160.27 offset -0.005203 sec
  8. chronyd の起動
  9. [root@server]# systemctl start chronyd.service
  10. chronyd の自動起動設定
  11. [root@server]# systemctl enable chronyd.service

動作確認

  1. systemctl status chronyd.service の実行
  2. [root@server]# systemctl status chronyd.service
    chronyd.service - NTP client/server
    	  Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled)
    	  Active: active (running) since 木 2013-02-21 12:28:30 JST; 10min ago
    	 Process: 3999 ExecStartPost=/usr/libexec/chrony-helper add-dhclient-servers (code=exited, status=0/SUCCESS)
    	 Process: 3996 ExecStart=/usr/sbin/chronyd -u chrony $OPTIONS (code=exited, status=0/SUCCESS)
    	 Process: 3988 ExecStartPre=/usr/libexec/chrony-helper generate-commandkey (code=exited, status=0/SUCCESS)
    	Main PID: 3998 (chronyd)
    	  CGroup: name=systemd:/system/chronyd.service
    		  └─3998 /usr/sbin/chronyd -u chrony
    	~~~~~以下省略~~~~~
  3. chronyc sources -v の実行
  4. ntpq -p に当たるものです
    [root@server]# chronyc sources -v
    210 Number of sources = 3
    
      .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
     / .- Source state '*' = current synced, '+' = OK for sync, '?' = unreachable,
    | /                'x' = time may be in error, '~' = time is too variable.
    ||                                                 .- xxxx [ yyyy ] +/- zzzz
    ||                                                /   xxxx = adjusted offset,
    ||         Log2(Polling interval) -.             |    yyyy = measured offset,
    ||                                  \            |    zzzz = estimated error.
    ||                                   |           |
    MS Name/IP address         Stratum Poll Reach LastRx Last sample
    ===============================================================================
    ^+ ntp1.jst.mfeed.ad.jp          2   6     7    21  +4153us[  +51us] +/-   31ms
    ^+ ntp2.jst.mfeed.ad.jp          2   6     7    21  +3662us[ -440us] +/-   31ms
    ^* ntp3.jst.mfeed.ad.jp          2   6     7    21   -562us[-4664us] +/-   30ms
  5. chronyc tracking の実行
  6. [root@server]# chronyc tracking
    	Reference ID    : 850BCC62 (ntp0.nc.u-tokyo.ac.jp)
    Stratum         : 2
    Ref time (UTC)  : Wed Apr 01 04:26:19 2026
    System time     : 0.001139870 seconds fast of NTP time
    Last offset     : +0.001427283 seconds
    RMS offset      : 0.000811916 seconds
    Frequency       : 2.917 ppm slow
    Residual freq   : +0.011 ppm
    Skew            : 0.124 ppm
    Root delay      : 0.038363539 seconds
    Root dispersion : 0.004379333 seconds
    Update interval : 1025.4 seconds
    Leap status     : Normal

chronyc のエラー(506 Cannot talk to daemon)

  1. 「506 Cannot talk to daemon」が出る
  2. [root@server]# chronyc tracking
    506 Cannot talk to daemon
  3. /etc/chrony.conf に追加する
  4. [root@server]# vi /etc/chrony.conf
    cmdallow 192.168.64/24		←cmdallow entry を追加