2. Synchronize time across the cluster

CentOS uses by default chronyd to synchronize time. It’s primary use case is for systems which have sporadic internet access like laptops. For long running systems with permanent internet access we will use the ntpd daemon instead.

2.1. NTP server installation

The master node will serve as NTP server for the rest of the cluster.

  1. Disable chronyd, stop it and uninstall if it exists

    [root@master ~]# systemctl disable chronyd
    [root@master ~]# systemctl stop chronyd
    [root@master ~]# yum remove chrony
    

    Avoid installing it on any compute nodes too by ensuring it is not part of the packages listed in your Kickstart files.

  2. Install the ntp daemon

    [root@master ~]# yum install ntp
    
  3. Edit the /etc/ntp.conf file

    Allow the subnets of your cluster to query your NTP server by adding the following lines:

    restrict 192.168.0.0  mask 255.255.240.0 nomodify notrap
    restrict 192.168.16.0 mask 255.255.240.0 nomodify notrap
    

    The following lines ensure that the NTP server uses the CentOS NTP servers as reference clocks.

    server 0.centos.pool.ntp.org iburst
    server 1.centos.pool.ntp.org iburst
    server 2.centos.pool.ntp.org iburst
    server 3.centos.pool.ntp.org iburst
    

    For the Temple HPC training cluster, your master nodes are not directly connected to the internet. Use the following NTP server instead by adding the following line and comment out all other server lines:

    server 172.16.1.1 prefer
    
  4. Enable and start the ntpd server

    [root@master ~]# systemctl enable ntpd
    [root@master ~]# systemctl start ntpd
    
    1. Verify your NTP server is synchronized with a reference clock

      Use the ntpstat command to query the current status of your system:

      [root@master ~]# ntpstat
      synchronised to NTP server (52.0.56.137) at stratum 3
         time correct to within 63 ms
         polling server every 256 s
      

      You can obtain more details using the ntpq -pn command:

      [root@master ~]# ntpq -pn
           remote           refid      st t when poll reach   delay   offset  jitter
      ==============================================================================
      +52.53.178.201   204.11.201.10    3 u  192  256  377   69.418    1.070   1.120
      -69.164.202.202  198.58.105.63    3 u  117  256  377   36.520   -1.316   0.779
      *52.0.56.137     216.239.35.4     2 u  211  256  377    5.523   -1.064   0.488
      +69.36.182.57    40.139.41.69     2 u  141  256  377    4.275    1.317   0.560
      
    2. Add ntp.hpc as CNAME entry for master.hpc in our DNS server

      ...
      master                  IN      A       192.168.16.1
      ntp                             CNAME   master
      ...
      

      This should allow any cluster node to access the NTP server via ntp.hpc

2.2. NTP Client Installation

Each compute node will act as a NTP client. They run the same daemon as the server, however, only to synchronize their clocks with our own local NTP server.

Warning

Before you can do any software installation, delete all CentOS repo files in /etc/yum.repos.d/.

[root@c01 ~]# rm /etc/yum.repos.d/CentOS*
  1. Disable chronyd, stop it and uninstall if it exists

    [root@c01 ~]# systemctl disable chronyd
    [root@c01 ~]# systemctl stop chronyd
    [root@c01 ~]# yum remove chrony
    

    Avoid installing it on any compute nodes too by ensuring it is not part of the packages listed in your Kickstart files.

  2. Install the ntp daemon

    [root@c01 ~]# yum install ntp
    
  3. Edit the /etc/ntp.conf file

    Add the following line to the NTP configuration file

    server ntp.hpc prefer
    

    And remove or comment all other server lines.

  4. Enable and start the ntpd daemon

    [root@c01 ~]# systemctl enable ntpd
    [root@c01 ~]# systemctl start ntpd
    
    1. Verify your NTP client is synchronized with the reference clock from ntp.hpc

      Use the ntpstat command to query the current status of your system:

      [root@c01 ~]# ntpstat
      synchronised to NTP server (192.168.16.1) at stratum 4
         time correct to within 69 ms
         polling server every 128 s
      

      You can obtain more details using the ntpq -pn command:

      [root@c01 ~]# ntpq -pn
           remote           refid      st t when poll reach   delay   offset  jitter
      ==============================================================================
      *192.168.16.1    69.36.182.57     3 u   83  128  377    0.087   -2.282   0.643