Configure Time Sync (Chrony) on CentOS 7

구성 목표
1. timezone은 Asia/Seoul로 설정
2. chrony를 이용하여 시간 동기화 서버 구성
3. 외부 타임서버는 time.bora.net을 메인으로 구성하고, time.google.com을 보조로 등록

현재 timezone 설정 확인

[root@172-16-11-7 /]# timedatectl
      Local time: Thu 2019-01-03 10:30:23 KST
  Universal time: Thu 2019-01-03 01:30:23 UTC
        RTC time: Thu 2019-01-03 01:10:46
       Time zone: Asia/Seoul (KST, +0900)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

timezone list 확인

[root@172-16-11-7 /]# timedatectl list-timezones

timezone 설정

[root@172-16-11-7 /]# timedatectl set-timezone Asia/Seoul

chrony 설치

[root@172-16-11-7 /]# yum install -y chrony

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 time.bora.net iburst
server time.google.com 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

systemd 데몬 등록 및 재시작

[root@172-16-11-7 /]# systemctl enable chronyd
[root@172-16-11-7 /]# systemctl restart chronyd

시간 동기화 실행

[root@172-16-11-7 /]# timedatectl set-ntp true

확인

[root@172-16-11-7 /]# timedatectl
      Local time: Thu 2019-01-03 10:51:11 KST
  Universal time: Thu 2019-01-03 01:51:11 UTC
        RTC time: Thu 2019-01-03 01:31:40
       Time zone: Asia/Seoul (KST, +0900)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

[root@172-16-11-7 /]# chronyc sources
210 Number of sources = 2
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* time.bora.net                 3   6   177    57  +3569us[+3316us] +/-   40ms
^+ time2.google.com              1   6   177    56  -4572us[-4572us] +/-   43ms

[root@172-16-11-7 /]# chronyc tracking
Reference ID    : CBF8F08C (time.bora.net)
Stratum         : 4
Ref time (UTC)  : Thu Jan 03 01:53:12 2019
System time     : 0.000247355 seconds slow of NTP time
Last offset     : -0.000252764 seconds
RMS offset      : 0.007350641 seconds
Frequency       : 20.539 ppm slow
Residual freq   : +8.213 ppm
Skew            : 40.230 ppm
Root delay      : 0.002380613 seconds
Root dispersion : 0.040031828 seconds
Update interval : 64.7 seconds
Leap status     : Normal

You may also like...