時刻設定を確認:
[user@CENTOS72 ~]$ timedatectl
Local time: 木 2018-03-08 18:26:59 JST
Universal time: 木 2018-03-08 09:26:59 UTC
RTC time: 木 2018-03-08 09:26:59
Time zone: Asia/Tokyo (JST, +0900)
NTP enabled: n/a
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
NTPは無効のためchronyをインストール
chronyを検索
[root@CENTOS72 user]# yum search chrony
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.usonyx.net
* extras: ftp.iij.ad.jp
* updates: centos.usonyx.net
====================================== N/S matched: chrony ======================================
chrony.x86_64 : An NTP client/server
Name and summary matches only, use "search all" for everything.
chronyをインストール
[root@CENTOS72 user]# yum install chrony.x86_64
(以下略)
chronyを起動し状況を確認
[root@CENTOS72 user]# systemctl start chronyd
[root@CENTOS72 user]# systemctl status chronyd
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: active (running) since 木 2018-03-08 19:03:36 JST; 8s ago
Docs: man:chronyd(8)
man:chrony.conf(5)
Process: 2450 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
Process: 2446 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 2448 (chronyd)
CGroup: /system.slice/chronyd.service
mq2448 /usr/sbin/chronyd
3月 08 19:03:36 CENTOS72 systemd[1]: Starting NTP client/server...
3月 08 19:03:36 CENTOS72 chronyd[2448]: chronyd version 3.1 starting (+CMDMON +NTP +R...G)
3月 08 19:03:36 CENTOS72 chronyd[2448]: Could not change ownership of /var/run/chrony...ed
3月 08 19:03:36 CENTOS72 chronyd[2448]: Could not access /var/run/chrony : No such fi...ry
3月 08 19:03:36 CENTOS72 chronyd[2448]: Disabled command socket /var/run/chrony/chron...ck
3月 08 19:03:36 CENTOS72 systemd[1]: Started NTP client/server.
Hint: Some lines were ellipsized, use -l to show in full.
(追記):chronyを開始する時に、「Could not change・・・」と「Could not access・・・」というメッセージが出力された。このままでも同期できることを確認済みだが、SELinuxをDisabledに変更したところ、このエラーも発生しないことを確認した。
timedatactlでNTPが有効になっているが同期していないためchronyの設定を変更
timedatactlでNTPが有効になっているが同期していないことを確認
[root@CENTOS72 user]# timedatectl
Local time: 木 2018-03-08 18:58:38 JST
Universal time: 木 2018-03-08 09:58:38 UTC
RTC time: 木 2018-03-08 09:58:38
Time zone: Asia/Tokyo (JST, +0900)
NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
chronyのソースがないことを確認してソースを追加
[root@CENTOS72 user]# chronyc sourcestats
210 Number of sources = 0
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
==============================================================================
chronyの設定ファイルに適当なインターネット時刻サーバ(会社専用のサーバなど)を追加
/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 company.timeserver.jp iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
(以下略)
設定を有効にするためにchronyを再起動してソースの状況を確認
[root@CENTOS72 user]# systemctl restart chronyd
[root@CENTOS72 user]# chronyc sourcestats
210 Number of sources = 1
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
==============================================================================
company.timerserver.jp 4 3 6 -0.000 217.709 -0ns 37us
timedatectlの状況を再確認
[root@CENTOS72 user]# timedatectl
Local time: 木 2018-03-08 10:27:40 JST
Universal time: 木 2018-03-08 01:27:40 UTC
RTC time: 木 2018-03-08 01:27:40
Time zone: Asia/Tokyo (JST, +0900)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a