리눅스 기초 다지기 - 04. 시간 동기화 NTP/Chrony

 

Chrony

 

NTP(Network Time Protocol)

: 인터넷에서 라우터 및 기타 하드웨어 디바이스의 클럭을 동기화하는 데 널리 사용되는 프로토콜

 

Chrony

: NTP(Network Time Protocol) 을 구현한 server/client 로 기존 리눅스의 ntpd 를 대체하며

RedHat Enterprise Linux 8 부터는 기본 NTP 제품으로 채택되었다.

 

chrony 상태 확인

systemctl is-active chronyd
active

 

NTP 서버 설정

vi /etc/chrony.conf
server time.bora.net iburst
allow 172.17.0.0/24

firewall-cmd --permanent --add-service=ntp
# or firewall-cmd --permanent --add-port=123/udp
firewall-cmd --reload

systemctl restart chronyd

 

NTP 클라이언트 설정

vi /etc/chrony.conf
pool 172.17.0.100 iburst

systemctl restart chronyd

chronyc sources -v
.-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current best, '+' = combined, '-' = not combined,
| /             'x' = may be in error, '~' = too variable, '?' = unusable.
||                                                 .- 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
===============================================================================
^* control                       4   6    17    25    -11us[  +22us] +/-   59ms

 

 

System clock synchronized 부분이 ‘yes’로 변경된 걸 확인할 수 있다. (동기화)

timedatectl
Local time: Tue 2023-08-01 11:03:54 KST
           Universal time: Tue 2023-08-01 02:03:54 UTC
                 RTC time: Tue 2023-08-01 02:03:54
                Time zone: Asia/Seoul (KST, +0900)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

 

NTP service: inactive 으로 되어 있다면 아래 명령어를 한다.

timedatectl set-ntp yes