시간 동기화(크로니)
정확한 시스템 시간은 로그 상관 관계, TLS 인증서 유효성 검사, 데이터베이스 일관성 및 분산 시스템에 필수적입니다. 신선한 Ubuntu 26.04 설치 시 Chrony는 기본 네트워크 시간 동기화 데몬입니다.
Chrony 대 systemd-timesyncd
Ubuntu은 두 가지 시간 동기화 구현을 제공합니다. 이들의 관계를 이해하면 실수를 피할 수 있습니다.
| 특징 | systemd-timesyncd | 크로니 |
|---|---|---|
| 역할 | 경량 SNTP 클라이언트 | 모든 기능을 갖춘 NTP 클라이언트/서버 |
| 26.04 기본값 | 업그레이드/최소 시스템을 위한 대체 | 새 설치 시 기본값 |
| NTP 서버 역할을 합니다. | 아니요 | 예(다른 호스트에게 시간을 제공할 수 있음) |
| 간헐적인 연결/VM 시계 드리프트 | 평균 | 더 나은 |
| 관리명령 | timedatectl | chronyc |
Note
두 개가 동시에 실행될 수는 없습니다. Chrony를 설치하면 systemd-timesyncd이 자동으로 비활성화됩니다. 이 시점에서 timedatectl set-ntp true/false은 더 이상 실제 동기화를 제어하지 않습니다. 대신 chronyc 및 systemctl ... chrony을 사용하십시오.
현재 동기화 상태 확인
# Overall time status
timedatectl
# Confirm which service is handling sync
systemctl status chrony
# If Chrony is not installed and timesyncd is in use
timedatectl show-timesync설치 및 활성화
# A fresh 26.04 install usually has Chrony pre-installed and enabled
sudo apt update
sudo apt install chrony
# Enable and start immediately
sudo systemctl enable --now chrony업스트림 시간 소스 구성
기본 구성 파일은 /etc/chrony/chrony.conf입니다.
sudo nano /etc/chrony/chrony.conf일반적인 구성:
# Use the Ubuntu NTP pool (default)
pool ntp.ubuntu.com iburst maxsources 4
# Record the offset of the system clock vs. the hardware clock to speed up future sync
driftfile /var/lib/chrony/chrony.drift
# Step the clock in one go when the initial offset is large (first 3 updates)
makestep 1.0 3편집 후 서비스를 다시 시작합니다.
sudo systemctl restart chrony일반적인 chronyc 명령
# View time sources and their status
chronyc sources -v
# View sync statistics (offset, jitter)
chronyc tracking
# View per-source measurement statistics
chronyc sourcestats
# Force an immediate step toward the server
sudo chronyc makestep
# Check whether the clock is synchronized
chronyc tracking | grep "Leap status"Chrony를 NTP 서버로 실행
LAN의 다른 호스트에 시간을 제공하려면 chrony.conf에서 클라이언트 서브넷을 허용하십시오.
# Allow LAN clients to query this host's time
allow 192.168.1.0/24sudo systemctl restart chrony
# Open the NTP firewall port (UDP 123)
sudo ufw allow 123/udpTip
장기간 일시 중지된 가상 머신과 노트북은 클럭 드리프트가 발생하기 쉽습니다. Chrony의 makestep 및 드리프트 파일 메커니즘은 대규모 오프셋을 더 빠르게 수정하므로 timesyncd보다 이러한 시나리오에 더 적합합니다.
Last updated on