How to Set up Chrony as NTP Server and Client
- 4 minsWhat is Chrony?
- Chrony is a solution for time synchronization before it, We could know about legacy NTP ,Network Time Protocol, is one of the oldest and most established time synchronization protocols. It is highly accurate and can achieve sub-millisecond synchronization in a well-configured network. NTP relies on a hierarchical model of time servers, with a primary reference source (stratum 0) such as a GPS clock or atomic clock.
- Chrony is a more modern time synchronization solution that was designed to improve upon NTP’s accuracy and reliability. It utilizes a different algorithm that can quickly synchronize a system’s clock, even if it has been offline or has experienced significant time drift. Chrony can achieve better accuracy than NTP in certain scenarios.
- Chrony is better for some of ways like If your system not active 7/24 or If you use lower power mode.
- Better response to rapid changes in the clock frequency, which is useful for virtual machines that have unstable.
Chrony Server and client
- We will configure chrony server and client advantage of using server and client is We can have same time for our network so When we want to trouble shoot any error It would help us for RCA or any log analysis.
Install chrony and start service
- If you don’t have chrony you can install with your packer manager (apt, apt-get, yum. dnf …)
- After Chrony is installed, start and enable the Chronyd service using the systemctl command below.
Configure chrony server
- In this step I will cnfigure node1 as a NTP server and I will use open NTP server which is closest to me.
- You can use ntp pool servers.
- I will use option ‘iburst’ that allows the Chronyd service to make the first update of the clock shortly after the start.
- Another important option is ‘allow’ that is for our clinets can use the NTP server as reference.
- you need to edit chrony.conf file.
- Now, let’s run the following chronyc command below to verify the sources of the NTP server pool that is currently used. You should see the list of current NTP server sources that are used by your server.
- You can also get detailed information via the ‘-v’ option as verbose.
Setting up Chrony as NTP Client
- We will configure chrony client, Intallation process is same as chrony server, only the difference will be configuration.
- Install chrony to client
- After Chrony is installed, start and enable the Chronyd service using the systemctl command below.
- We are ready to edit chrony config file
- On the server directive, change the NTP server source with your NTP server. In this example, the NTP Server is running the server with IP address ‘192.168.64.15’.
- Also, you can see additional options on the server directive”
- The iburst option allows the Chronyd service to make the first update of the clock shortly after the start.
- The prefer option will prioritize the NTP Server source among other servers without prefer option.
-
Save the file and exit the editor when you’re done.
-
Now, run the following command to restart the Chrony service and apply new configurations.
- Finally, run the following chronyc command to verify the current status of NTP on the ‘node2’ machine.
-
You should see the ‘node2’ machine is connected and synchronized the time to the NTP Server ‘node1.local’, which is the server IP address ‘192.168.64.15’.
-
You can also verify the detailed NTP data via the chronyc command below.
Thanks for reading and do not forget set your watch correct time
Guneycan Sanli.