Search
Duplicate

chrony를 통한 시간동기화

chrony 란?

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

최초 VM 구성 시, chrony 설정

1. vi /etc/chrony.conf

[AS-IS] # 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 [TO-BE] # 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 10.64.237.49 iburst
Bash
복사

2. 서버 재부팅 시, chronyd 데몬이 자동으로 실행되도록 설정

[root@svr ~]# systemctl enable chronyd
Bash
복사

3. chronyd 데몬 재기동 후 상태 확인

[root@svr ~]# systemctl status chronyd; systemctl restart chronyd; systemctl status chronyd
Bash
복사

4. NTP 동기화 여부 체크

[root@svr ~]# timedatectl Local time: Tue 2021-11-09 10:16:13 KST Universal time: Tue 2021-11-09 01:16:13 UTC RTC time: Tue 2021-11-09 01:16:13 Time zone: Asia/Seoul (KST, +0900) NTP enabled: yes <==== NTP 활성화 여부 확인 NTP synchronized: yes <==== NTP 동기화 여부 확인 RTC in local TZ: no DST active: n/a
Bash
복사

5. 마스터 노드와의 동기화 여부 확인

[root@svr ~]# chronyc sources -v 210 Number of sources = 1 .-- 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 =============================================================================== ^* 10.64.237.49 3 6 37 29 +129ns[ +161us] +/- 4722us <==== 만약 마스터 노드와 통신이 되지 않는다면 0으로 표기됨
Bash
복사

6. 마스터 노드와 동기화한 시간을 하드웨어 시간으로 설정 (중요!)

[root@svr ~]# chronyc -a makestep; hwclock -w
Bash
복사