How to Configure and Monitoring chronyd in CentOS/RHEL 7 and 8
The chronyd service keeps the usually-inaccurate local hardware clock (RTC) on track by synchronizing it to the conﬁgured NTP servers. If no network connectivity is available, chronyd calculates the RTC clock drift, which is recorded in the driftfile speciﬁed in the /etc/chrony.conf conﬁguration ﬁle. By default, the chronyd service uses servers from the NTP Pool Project for the time synchronization and does not need additional conﬁguration. It may be useful to change the NTP servers when the machine in question is on an isolated network.
The stratum of the NTP time source determines its quality. The stratum determines the number of hops the machine is away from a high-performance reference clock. The reference clock is a stratum 0 time source. An NTP server directly attached to it is a stratum 1, while a machine synchronizing time from the NTP server is a stratum 2 time source. The server and peer are the two categories of time sources that you can in the /etc/chrony.conf conﬁguration ﬁle. The server is one stratum above the local NTP server, and the peer is at the same stratum level. More than one server and more than one peer can be speciﬁed, one per line.
The ﬁrst argument of the server line is the IP address or DNS name of the NTP server. Following the server IP address or name, a series of options for the server can be listed. It is recommended to use the iburst option, because, after the service starts, four measurements are taken in a short time period for a more accurate initial clock synchronization.
The following server classroom.example.com iburst line in the /etc/chrony.conf ﬁle causes the chronyd service to use the classroom.example.com NTP time source.
# Use public servers from the pool.ntp.org project. ...output omitted... server classroom.example.com iburst ...output omitted...
After pointing chronyd to the local time source, classroom.example.com, you should restart the service.
[[email protected] ~]# systemctl restart chronyd
The chronyc command acts as a client to the chronyd service. After setting up NTP synchronization, you should verify that the local system is seamlessly using the NTP server to synchronize the system clock using the chrony sources command. For more verbose output with additional explanations about the output, use the chronyc sources -v command.
[[email protected] ~]# 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 || / xxxx = adjusted offset, || Log2(Polling interval) -. | yyyy = measured offset, || \ | zzzz = estimated error. || | | MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^* classroom.example.com 8 6 17 23 -497ns[-7000ns] +/- 956us
The * character in the S (Source state) ﬁeld indicates that the classroom.example.com server has been used as a time source and is the NTP server the machine is currently synchronized to.