본문 바로가기

리눅스

CentOS 7에서 chrony를 설치하고 설정하는 방법(ntpd 대체)

728x90

CentOS 7에서 chrony를 설치하고 설정하는 방법

chrony 설치

yum install -y chrony

chrony 서비스 활성화(enable) 및 서비스 시작(start)

systemctl --now enable chronyd

(또는)

systemctl enable chronyd
systemctl start chronyd

chrony 설정(chrony.conf) 파일  편집

  • NTP 서버 설정
    • time.bora.net 추가
    • times.postech.ac.kr 추가
vim /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 time.bora.net iburst
server times.postech.ac.kr 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

서비스 재기동

systemctl restart chronyd
$ systemctl restart chronyd
728x90

 

서비스 확인

ntp 소스 서버 상태 확인

chronyc sourcestats -v
$ chronyc sourcestats -v
210 Number of sources = 2
                             .- Number of sample points in measurement set.
                            /    .- Number of residual runs with same sign.
                           |    /    .- Length of measurement set (time).
                           |   |    /      .- Est. clock freq error (ppm).
                           |   |   |      /           .- Est. error in freq.
                           |   |   |     |           /         .- Est. offset.
                           |   |   |     |          |          |   On the -.
                           |   |   |     |          |          |   samples. \
                           |   |   |     |          |          |             |
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
time.bora.net               9   5   327     -0.836      7.884    -47us   448us
121.125.77.167              0   0     0     +0.000   2000.000     +0ns  4000ms

시간 동기화 확인

chronyc sources -v
$ chronyc sources -v         
210 Number of sources = 2

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* time.bora.net                 3   6   377    11    +99us[  +75us] +/-   33ms
^? 121.125.77.167                0   8     0     -     +0ns[   +0ns] +/-    0ns

동기화 명령

chronyc -a makestep
$ chronyc -a makestep
200 OK

tracking

chronyc tracking
$ chronyc tracking  
Reference ID    : CBF8F08C (time.bora.net)
Stratum         : 4
Ref time (UTC)  : Mon Nov 16 12:45:16 2020
System time     : 0.081910394 seconds slow of NTP time
Last offset     : -0.000361153 seconds
RMS offset      : 0.000361153 seconds
Frequency       : 17.039 ppm slow
Residual freq   : -102.455 ppm
Skew            : 0.066 ppm
Root delay      : 0.025002619 seconds
Root dispersion : 0.016522199 seconds
Update interval : 1.9 seconds
Leap status     : Normal

 

위의 단계를 따라 chrony를 설치하고 설정하면 CentOS 7에서 시간 동기화를 관리할 수 있습니다. chrony는 NTP 서버와의 동기화를 통해 정확한 시간을 유지하는 데 도움을 줍니다.

 

728x90