Setting up NTP Client in Rocky Linux 8.5

Prerequisites Step 1: Endure you are in the correct time zone

# timedatectl
               Local time: Wed 2022-04-20 10:04:44 +08
           Universal time: Wed 2022-04-20 02:04:44 UTC
                 RTC time: Wed 2022-04-20 02:04:44
                Time zone: Asia/Singapore (+08, +0800)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no

Prerequisites Step 2: List Time Zone

# timedatectl list-timezones
.....
Asia/Singapore
.....

Prerequisites Step 3: Set Time Zone

# timedatectl set-timezone Asia/Singapore

In Rocky Linux 8.5, the ntp package is no longer supported and it is implemented by the chronyd (a daemon that runs in user-space) which is provided in the chrony package.

chrony works both as an NTP server and as an NTP client, which is used to synchronize the system clock with NTP servers.

To install the chrony suite, use the DNF Package Manager.

# dnf install chrony

Enable the Service

# systemctl start chronyd
# systemctl status chronyd
# systemctl enable chronyd

Check it is synchronised

[root@h00 etc]# timedatectl
               Local time: Wed 2022-04-20 10:19:56 +08
           Universal time: Wed 2022-04-20 02:19:56 UTC
                 RTC time: Wed 2022-04-20 02:19:56
                Time zone: Asia/Singapore (+08, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

Setting up NTP Client Using Chrony in Rocky Linux 8.5

# vim /etc/chrony.conf
.....
pool sg.pool.ntp.org iburst
.....
# systemctl restart chronyd

Show the current time sources that chronyd is accessing

# chronyc sources
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^? 178.128.223.142               0   6     0     -     +0ns[   +0ns] +/-    0ns
.....
.....
.....

References:

Configuring NTP Server and Client on CentOS 5.x

The Network Time Protocol (NTP) is a protocol for synchronizing the clocks of computer systems over packet-switched, variable-latency data networks. NTP uses UDP on port 123 as its transport layer. The ntp package includes ntpdate package (for retrieving the date and time from remote machines via a network) and ntpd (a daemon which continuously adjusts system time).

For this blog entry, we are looking at a typical HPC Setup with Local Head Nodewith access to Internet and with Clients with no access to internet.

Step 1: Install the ntp package

# yum install ntp

Step 2: Configuration at /etc/ntp.conf
(The Basic Configuration is sufficient. A few things to note)

# vim /etc/ntp.conf
(Inside the /etc/ntp.conf)

restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
(This statement is to allow local network to access the Server)

restrict 127.0.0.1
(Ensure the localhost has full access without any restricting password)

server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
(server xxxx.pool.ntp.org represent remote NTP servers that your local NTP Server want to sync to)

Step 3: Start the NTP Service
(Synchronise the local NTP Server with Remote NTP Server)

# chkconfig --levels 235 ntpd on
# ntpdate 0.centos.pool.ntp.org
# service ntpd start

Step 4: Check whether the NTP Server is working

# ntpq -p

Setting Up NTP Clients to sync with the local NTP Server and NTP Client

Step 1: Install NTP Client

# yum install ntp

Step 2: Configure the /etc/ntp.conf

# vim /etc/ntp.conf
(Inside the /etc/ntp.conf)

server 192.168.10.1
(where 192.168.10.1 is the local NTP Server)

Step 3: Configure /etc/ntp/ntpservers and /etc/ntp/step-tickers to point to the local NTP Servers

192.168.10.1
(where 192.168.10.1 is the local NTP Server where the NTP Clients will sync with)

Step 4: Start the Services

# chkconfig --levels 235 ntpd on
# ntpdate 192.168.10.1
# service ntpd start

Step 5: Check whether it is working

# ntpq -p

For more information, go to

  1. NTP.org
  2. ntpdate no server suitable for synchronization found (Linux Toolkit)
  3. Setting up NTP Server for Local Network (Linux Toolkit)