Chrony 설치 및 설정하는 방법
Chrony는 리눅스 시스템에서 시간 동기화를 담당하는 프로그램 중 하나입니다. 이 프로그램을 설치하고 설정하는 방법을 알아보겠습니다.
1. Chrony 설치
Chrony를 설치하기 위해서는 먼저 패키지 관리자를 이용해 설치해야 합니다. 다음 명령어를 사용해 Chrony를 설치합니다.
- Debian 계열
sudo apt-get update
sudo apt-get install -y chrony
- RHEL 계열
sudo yum install -y chrony
2. Chrony 설정
Chrony는 기본적으로 /etc/chrony.conf 파일을 사용하여 설정합니다. 이 파일을 열어 다음과 같이 수정합니다.
vim /etc/chrony.conf
# 서버 설정
server [NTP 서버 주소] iburst
# 로컬 서버와의 시간 차이를 보정하기 위한 옵션
driftfile /var/lib/chrony/drift
# 시간 정보를 로그에 기록하는 옵션
log tracking measurements statistics
위 예시에서 [NTP 서버 주소]는 동기화에 사용할 NTP 서버의 주소입니다. 대부분의 경우 NTP 서버는 인터넷에서 무료로 제공되는 공개 서버를 사용하면 됩니다.
3. Chrony 실행
설정이 완료되면 Chrony를 실행해야 합니다. 다음 명령어를 사용해 Chrony를 시작합니다.
sudo systemctl start chronyd
시스템이 재부팅될 때마다 Chrony가 자동으로 실행되도록 하려면 다음 명령어를 실행합니다.
sudo systemctl enable chronyd
이제 Chrony가 시스템 시간 동기화를 담당하게 됩니다. 시간 동기화가 잘 되는지 확인하려면 다음 명령어를 사용합니다.
chronyc tracking
위 명령어를 실행하면 NTP 서버와의 시간 차이 등 시간 정보가 출력됩니다. 이를 통해 Chrony가 시스템 시간을 제대로 동기화하는지 확인할 수 있습니다.
4. Chrony 설정 추가
만약 시간 동기화를 위한 NTP 서버가 여러 개 있다면 다음과 같이 설정을 추가할 수 있습니다.
# 서버 설정
server [NTP 서버1 주소] iburst
server [NTP 서버2 주소] iburst
server [NTP 서버3 주소] iburst
또한, 만약 시스템이 로컬 네트워크 안에 있다면 로컬 네트워크 안에 있는 NTP 서버를 사용하는 것이 좋습니다. 다음과 같이 로컬 네트워크에 있는 NTP 서버를 추가할 수 있습니다.
# 로컬 네트워크에 있는 NTP 서버 추가
server [로컬 NTP 서버 주소] iburst
5. Chrony 시간 동기화 강제
만약 Chrony가 시간 동기화를 수행하지 않는다면 수동으로 시간 동기화를 강제할 수 있습니다. 다음 명령어를 사용하면 됩니다.
sudo chronyc -a makestep
위 명령어를 사용하면 시간 동기화가 바로 이루어집니다. 하지만 이렇게 강제로 시간을 변경하는 것은 시스템 안정성을 위해서는 좋지 않습니다. 따라서 최대한 자동으로 시간 동기화가 이루어지도록 Chrony를 설정하는 것이 좋습니다.
6. Chrony 설정 파일 재로드
만약 Chrony 설정 파일을 수정했다면 이를 적용하기 위해서는 다음 명령어를 사용해 설정 파일을 다시 로드해야 합니다.
sudo systemctl restart chronyd
이제 Chrony가 재시작되면 새로운 설정이 적용됩니다.
위와 같이 Chrony를 설치하고 설정하는 방법을 알아보았습니다. Chrony를 잘 활용하면 시스템의 시간 동기화를 효과적으로 수행할 수 있습니다.
Chrony 환경 설정 편집
타임 서버(time server) 추가
- 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
Chrony 재실행
$ systemctl restart chronyd
$ 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
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
200 OK
$ 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
'Linux Distributions' 카테고리의 다른 글
파이썬 가상 환경을 구성하고 설정하는 방법 (0) | 2024.02.28 |
---|---|
Redis의 다양한 운영 모드 종류(Operation Modes) (0) | 2024.02.28 |
우분투에 Python 3 및 pip를 설치하는 방법 (0) | 2024.02.26 |
macOS에 Zulu JDK 11을 다운로드하고 설치하는 방법(java 11) (0) | 2024.02.26 |
macOS에 JDK 11을 다운로드하고 설치하는 방법(java 11) (0) | 2024.02.26 |