chrony
Dieser Artikel wurde für die folgenden Ubuntu-Versionen getestet:
Ubuntu 24.04 Noble Numbat
Du möchtest den Artikel für eine weitere Ubuntu-Version testen? Mitarbeit im Wiki ist immer willkommen! Dazu sind die Hinweise zum Testen von Artikeln zu beachten.
Zum Verständnis dieses Artikels sind folgende Seiten hilfreich:
chrony 🇬🇧 ist eine Implementierung des Network Time Protocol (NTP). Mit Hilfe dieses Protokolls können Computersysteme die Zeiten ihrer Uhren untereinander synchronisieren.
Ubuntu nutzt seit Version 16.04 timesyncd als vorinstallierte Lösung für diesen Zeitabgleich, die eine vereinfachte Spezifikation des Protokolls (Simple Network Time Protokol (SNTP)) implementiert und die für einen Client oder einen einzelnen Server ausreicht.
Ist jedoch eine höhere Genauigkeit gefragt, der Abgleich mit mehreren unterschiedlichen Quellen gleichzeitig, die Bereitstellung eigener Zeitdienste oder auch die Integration von Referenzuhren, bietet sich die Nutzung von chrony an.
Installation¶
Hinweis:
Die Installation von chrony ersetzt timesyncd als Zeitdienst.
Chrony kann aus den Ubuntu-Paketquellen installiert werden[1]:
chrony
Befehl zum Installieren der Pakete:
sudo apt-get install chrony
Konfiguration¶
Die Konfiguration erfolgt über die Datei /etc/chrony/chrony.conf. Mit der Installation wird bereits eine arbeitsfähige Konfiguration mitgeliefert, die chrony als NTP-Client arbeiten lässt.
Erklärungen für die zahlreichen Konfigurationsoptionen von chrony gibt es auf der Projektseite in der umfassenden Dokumentation 🇬🇧.
Da die Anforderungen für den Betrieb eines eigenen Zeitservers sehr unterschiedlich sein können, wird an dieser Stelle zugunsten der Beispiele in der Dokumentation verzichtet.
Bedienung¶
chrony besteht aus den zwei Programmen
chronyc – Command Line Interface für chrony (Client) und
chronyd – Hintergrunddienst (Daemon)
Chrony-Client¶
chronyc ist das Client-Programm zu chronyd, welches Befehle für einen chronyd-Prozess entweder direkt auf der Kommandozeile annimmt oder nach dem Aufbau einer Verbindung eine interaktive Shell bereitstellt.
Die Kommandozeilenhilfe von chronyc gibt Aufschluss über die Syntax des Befehls[2]:
chronyc --help
Usage: chronyc [-h HOST] [-p PORT] [-n] [-4|-6] [-a] [-f FILE] [-m] [COMMAND]
Ohne Angabe von Optionen verbindet sich chronyc mit dem lokalen chronyd und startet die interaktive Shell. Nachfolgend eine beispielhafte Sitzung unter Ubuntu 16.04 zur Abfrage von Statusinformationen (hier mit den Befehlen activity, sources und tracking):
chronyc
chrony version 2.1.1 Copyright (C) 1997-2003, 2007, 2009-2015 Richard P. Curnow and others chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See the GNU General Public License version 2 for details. chronyc> activity 200 OK 4 sources online 0 sources offline 0 sources doing burst (return to online) 0 sources doing burst (return to offline) 0 sources with unknown address chronyc> sources 210 Number of sources = 4 MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^+ ntp1.hetzner.de 2 6 377 18 -3007us[-2457us] +/- 52ms ^+ tirpitz.netzkontrollstell 2 6 377 17 -658us[ -658us] +/- 30ms ^+ curiosity.weesky.be 2 6 377 17 -1665us[-1665us] +/- 46ms ^* stratum2-3.NTP.TechFak.NE 2 6 377 17 +2852us[+3402us] +/- 18ms chronyc> tracking Reference ID : 129.70.132.36 (stratum2-3.NTP.TechFak.NET) Stratum : 3 Ref time (UTC) : Sat Apr 11 13:50:08 2020 System time : 50622.625000000 seconds slow of NTP time Last offset : +0.000549936 seconds RMS offset : 0.000961328 seconds Frequency : 37.426 ppm fast Residual freq : +0.236 ppm Skew : 3.850 ppm Root delay : 0.030706 seconds Root dispersion : 0.003080 seconds Update interval : 59.6 seconds Leap status : Normal chronyc>
Anschließend kann man chronyc durch die Eingabe von exit wieder verlassen.
chronyc beinhaltet auch ein Hilfe-Kommando zur Ausgabe aller erlaubter Befehle:
chronyc help
System clock:
tracking Display system time information
makestep Correct clock by stepping immediately
makestep <threshold> <updates>
Configure automatic clock stepping
maxupdateskew <skew> Modify maximum valid skew to update frequency
waitsync [<max-tries> [<max-correction> [<max-skew> [<interval>]]]]
Wait until synchronised in specified limits
Time sources:
sources [-v] Display information about current sources
sourcestats [-v] Display statistics about collected measurements
reselect Force reselecting synchronisation source
reselectdist <dist> Modify reselection distance
NTP sources:
activity Check how many NTP sources are online/offline
ntpdata [<address>] Display information about last valid measurement
add server <address> [options]
Add new NTP server
add peer <address> [options]
Add new NTP peer
delete <address> Remove server or peer
burst <n-good>/<n-max> [<mask>/<address>]
Start rapid set of measurements
maxdelay <address> <delay> Modify maximum valid sample delay
maxdelayratio <address> <ratio>
Modify maximum valid delay/minimum ratio
maxdelaydevratio <address> <ratio>
Modify maximum valid delay/deviation ratio
minpoll <address> <poll> Modify minimum polling interval
maxpoll <address> <poll> Modify maximum polling interval
minstratum <address> <stratum>
Modify minimum stratum
offline [<mask>/<address>] Set sources in subnet to offline status
online [<mask>/<address>] Set sources in subnet to online status
onoffline Set all sources to online or offline status
according to network configuration
polltarget <address> <target>
Modify poll target
refresh Refresh IP addresses
Manual time input:
manual off|on|reset Disable/enable/reset settime command
manual list Show previous settime entries
manual delete <index> Delete previous settime entry
settime <time> Set daemon time
(e.g. Sep 25, 2015 16:30:05 or 16:30:05)
NTP access:
accheck <address> Check whether address is allowed
clients Report on clients that have accessed the server
serverstats Display statistics of the server
allow [<subnet>] Allow access to subnet as a default
allow all [<subnet>] Allow access to subnet and all children
deny [<subnet>] Deny access to subnet as a default
deny all [<subnet>] Deny access to subnet and all children
local [options] Serve time even when not synchronised
local off Don't serve time when not synchronised
smoothtime reset|activate Reset/activate time smoothing
smoothing Display current time smoothing state
Monitoring access:
cmdaccheck <address> Check whether address is allowed
cmdallow [<subnet>] Allow access to subnet as a default
cmdallow all [<subnet>] Allow access to subnet and all children
cmddeny [<subnet>] Deny access to subnet as a default
cmddeny all [<subnet>] Deny access to subnet and all children
Real-time clock:
rtcdata Print current RTC performance parameters
trimrtc Correct RTC relative to system clock
writertc Save RTC performance parameters to file
Other daemon commands:
cyclelogs Close and re-open log files
dump Dump all measurements to save files
rekey Re-read keys from key file
shutdown Stop daemon
Client commands:
dns -n|+n Disable/enable resolving IP addresses to hostnames
dns -4|-6|-46 Resolve hostnames only to IPv4/IPv6/both addresses
timeout <milliseconds> Set initial response timeout
retries <retries> Set maximum number of retries
keygen [<id> [<type> [<bits>]]]
Generate key for key file
exit|quit Leave the program
help Generate this helpChrony-Server¶
chronyd ist der Dienst, der im Hintergrund die Synchronisierung mit den konfigurierten Zeitquellen durchführt und auch die Abfragen anderer Systeme beantwortet - falls zulässig.
Mit den nachfolgenden Befehlen lässt sich der Dienst starten, stoppen und dessen Status abfragen[2]:
systemctl status chronyd systemctl start chronyd systemctl stop chronyd
Links¶