Installing and configuring NTP

In this section, we will install and configure NTP on Ubuntu and CentOS/Red Hat.

First, we will look at the steps to install and configure NTP on Ubuntu. Ubuntu comes preinstalled with ntpdate, and this service runs automatically and updates time data at system startup. If we need a more frequent update, we can set up a cron job for the same. For this, we can create a script file such as updateTimeDate.sh and include the following lines:

#!bin/sh
ntpdate ntp.ubuntu.com

Set this as a crontab job to update the system date more frequently, keep in mind that this file must be the same, and note that the frequency of crontab must be the same for all the nodes in the cluster.

We can use the sudontpq –np command to check if the NTP service is running properly.

It can also be installed using the following commands, if it is not already installed:

sudo aptitude update
sudo aptitude install ntp

Note

The aptitude command was formerly used as apt-get.

On CentOS or Red Hat, we need to install the NTP client and set an NTP server to keep the time and date updated throughout the cluster. The following are the commands using which we can install and configure an NTP client service on nodes:

sudo yum install ntp
sudo /sbin/chkconfigntpd on

The first command will install an NTP service, and the second command will enable it to run on the boot-up process. If needed to be more frequent, a cron can be written for the same. Once the setup is complete, verify them as follows:

  • Java: Use the java -version command. This must give a JDK version that we installed.
  • SSH: Test SSH by connecting to all machines, for example, ssh <hostname>. If you can connect to the machine without using a password, the SSH setup is successful. If you get any errors, delete the .ssh directory in the home directory, regenerate the key again using the aforementioned method, and reboot your machine once.
  • NTP: Check the time of all the systems. There must not be more than a 30-second difference between the times of the different machines.
  • DNS/host file: Use commands such as nslookup, dig, and ping for correctness and reachability of the machines in the cluster. Check this using both the IP and hostname.

Tip

Verify twice, and let's move forward.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.239.118