CentOS 7 からntpdの他にchronyが新しく導入されたのでRHELの公式ドキュメントを参照して簡単にメモ。
日付と時刻
タイプ | 内容 |
リアルタイムクロック (RTC)(ハードウェアクロック) | システムボード上の集積回路 |
システムクロック(ソフトウェアクロック) | 初期値はリアルタイムクロックに基づいている。 システムが起動するとシステムクロックは初期化され、リアルタイムクロックとは完全に独立したものになる。 |
RHEL 7 の日時設定コマンド
- timedatectl(RHELで導入)
- date
- hwclock
現在時刻の表示
# timedatectl Local time: Mon 2018-01-15 09:41:05 JST Universal time: Mon 2018-01-15 00:41:05 UTC RTC time: Mon 2018-01-15 00:41:04 Time zone: Asia/Tokyo (JST, +0900) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: n/a
サービス再起動
# systemctl restart systemd-timedated.services
日時の変更
# timedatectl set-time HH:MM:SS # timedatectl set-time YYYY-MM-DD # timedatectl set-time '2013-06-02 23:26:00'
システムクロックとNTPサーバの自動同期有効
# timedatectl set-ntp yes
chrony
インストール
# yum install chrony
chronyd コマンド
# systemctl status chronyd # systemctl start chronyd # systemctl stop chronyd # systemctl is-enabled chronyd # systemctl enable chronyd # systemctl disable chronyd
chronyc コマンド(クライアントソフト)
トラッキング確認
# chronyc tracking Reference ID : 7566B0CA (hachi.paina.net) Stratum : 3 Ref time (UTC) : Mon Jan 15 00:55:48 2018 System time : 0.000036912 seconds fast of NTP time Last offset : -0.000021247 seconds RMS offset : 0.000118794 seconds Frequency : 1.365 ppm fast Residual freq : -0.010 ppm Skew : 0.396 ppm Root delay : 0.010405293 seconds Root dispersion : 0.024321284 seconds Update interval : 64.3 seconds Leap status : Normal
同期しているNTPサーバの確認(ntpdのntpq -pにあたる)
# chronyc sources 210 Number of sources = 4 MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^- mzh.io 2 6 377 56 +220us[ +525us] +/- 179ms ^* hachi.paina.net 2 6 377 55 -965us[ -660us] +/- 36ms ^+ li1701-26.members.linode> 3 6 377 55 -1021us[-1021us] +/- 71ms ^+ v157-7-235-92.z1d6.stati> 2 6 365 55 +1051us[+1356us] +/- 25ms
chrony設定ファイル
特に何もいじっていない。
# 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.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 # Record the rate at which the system clock gains/losses time. driftfile /var/lib/chrony/drift # Allow the system clock to be stepped in the first three updates # if its offset is larger than 1 second. makestep 1.0 3 # Enable kernel synchronization of the real-time clock (RTC). rtcsync # Enable hardware timestamping on all interfaces that support it. #hwtimestamp * # Increase the minimum number of selectable sources required to adjust # the system clock. #minsources 2 # Allow NTP client access from local network. #allow 192.168.0.0/16 # Serve time even if not synchronized to a time source. #local stratum 10 # Specify file containing keys for NTP authentication. #keyfile /etc/chrony.keys # Specify directory for log files. logdir /var/log/chrony # Select which information is logged. #log measurements statistics tracking
必要になったら、また詳しく調べる
参考
https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/7/html/system_administrators_guide/chap-configuring_the_date_and_time
https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-configuring_ntp_using_the_chrony_suite