Chrony is an open source free software that keeps the system clock synchronized with the clock server (NTP) to keep time accurate.
It consists of two programs: Chronyd and CHRONYC.
Chronyd is a daemon that runs in the background to tune the system clock and clock server synchronization running in the kernel. It determines the ratio of the time the computer increases or decreases, and compensates for this.
The CHRONYC provides a user interface for monitoring performance and for a variety of configurations. It can work on a computer that is controlled by an chronyd instance, or on a different remote computer.
Installing, configuring Chrony
# Systemctl Enable chronyd.service# systemctl restart chronyd.service# systemctl status Chronyd.service View time synchronization Source: # Chronyc sources-v AboutNumber of sources =1 .--Source mode'^'= Server,'='= Peer,'#'=local clock./.-Source State'*'= Current synced,'+'= Combined,'-'=Not combined,| /'?'= Unreachable,'x'= Time MayinchError'~'=Time too variable.|| .-xxxx [YYYY] +/-zzzz|| /xxxx =adjusted offset,|| LOG2 (Polling interval)-. | yyyy =measured offset,|| \ | zzzz =estimated error.|| | |MS Name/IP address stratum Poll Reach Lastrx last sample===============================================================================^? Ys-ad1.ys.com3 6 3 1+12ms[+12ms] +/-268ms View time sync source Status: # Chronyc sourcestats-v AboutNumber of sources =1 .-Number of sample pointsinchMeasurementSet. / .-Number of residual runs with same. | /.-Length of measurementSet(Time). | | / .-Est. Clock freq error (ppm). | | | /.-Est. Errorinchfreq. | | | | / .-Est. Offset. | | | | | | On the-. | | | | | |samples. | | | | | | |Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev==============================================================================Ys-ad1.ys.com4 3 6-939.214 56272.109-4371us 5267us
Configure Chrony
When Chrony starts, it reads the settings in the/etc/chrony.conf configuration file
Parameter file Description:
# cat/etc/chrony.conf # This parameter can be used multiple times to add a clock server, which must be"Server"format used. Generally, you can add as many servers as you want to add. Server0. rhel.pool.ntp.org Iburstserver1. rhel.pool.ntp.org Iburstserver2. rhel.pool.ntp.org Iburstserver3. rhel.pool.ntp.org iburst# Ignore stratuminchThe source selection.# stratumweight directive sets how much distance each layer should add to the synchronization distance when Chronyd selects the synchronization source from the available sources. By default, set to 0 to let Chronyd ignore the source hierarchy when selecting a source. Stratumweight0# Record The rate at which the system clock gains/one of the main behaviors of the losses time.# Chronyd program is to calculate the ratio of the computer's increase or decrease time according to the actual time, it is most reasonable to record it in a file, it will compensate for the system clock after the reboot, and even get a better estimate from the clock server if possible. Driftfile/var/lib/chrony/The drift# enable kernel RTC synchronization.# rtcsync directive enables a kernel mode in which the system time is copied to the real-time clock (RTC) every 11 minutes. Rtcsync# in first three updates step the system clock instead of slew#ifThe adjustment isLarger thanTenseconds. Typically, the chronyd will reduce or accelerate the clock as needed, allowing the system to progressively correct all time deviations. In some specific cases, the system clock may drift too fast, causing the adjustment process to take a long time to correct the system clock. This directive forces chronyd to adjust the system clock when the adjustment period is greater than a certain threshold, but only when there are no more clock updates because the CHRONYD boot time exceeds the specified limit (a negative value can be used to disable the limit). MakestepTen 3# Allow NTP Client Access fromLocal network.# Here you can specify a host, subnet, or network to allow or deny NTP to connect to the machine that plays the clock server. #allow192.168.56.6#deny192.168/ -# Listen forcommands only on localhost.# This directive allows you to limit the command packet (executed by CHRONYC) of which network interface the Chronyd listens to. This directive provides an additional level of access control that is available in addition to the above limitations through the cmddeny mechanism. Bindcmdaddress127.0.0.1bindcmdaddress::1# Serve Time evenifNot synchronized to any NTP server. #local stratumTenkeyfile/etc/chrony.keys# Specify the key used asPassword forChronyc.commandkey1# Generate Command keyifmissing.generatecommandkey# Disable Logging of client accesses.noclientlog# Send a message to SyslogifA clock adjustment isLarger than0.5Seconds.logchange0.5LogDir/var/log/Chrony#log measurements Statistics Tracking
Command Keys
In the/etc/chrony.conf configuration file, the parameter generatecommandkey specifies a password that generates a SHA1 or MD5 encryption, which is stored in/etc/chrony.keys:
# cat/etc/chrony.keys1 MD5 Hex:bd359b2633cd6105ab8820e47a8d8eab
The password is "Hex:bd359b2633cd6105ab8820e47a8d8eab" and contains the prefix "HEX:"
You can specify your own password, such as:
# cat/etc/chrony.keys1 xyzzy
In the/etc/chrony.conf configuration file, the parameter commandkey specifies the password file that is used. Default is 1
Configure the time synchronization server on the client
1. Using the command line tool: Chronyc
2. Graphical interface tool: System_config_date
RHEL7--Synchronize with clock server using Chrony setup time