Introduction
For proper cluster functionality, all nodes in the cluster need to have their clocks synchronized, even when the cluster is isolated from the Internet and global time sync servers. To accomplish this, we installed NTP on Ubuntu/Linux and configured one node to act as the main time server, while the other nodes act as clients to main time server. This how-to tutorial describes how to set up your machine as a local Network Time Protocol (NTP) server and how to use the NTP daemon to regularly maintain an accurate system time across the cluster. We hope you find the below information useful in building your own clusters.
Install NTP on all Nodes
On all nodes install NTP and set the timezone to UTC.
1 2 3 4 |
sudo apt-get install ntp sudo dpkg-reconfigure tzdata pick etc --> UTC |
NTP Server
Choose one node as the main time server and set it up to run properly even if it is not connected to the Internet.
1 2 |
sudo nano /etc/ntp.conf |
Add the following to provide your current local time as a default should you temporarily (or permanently) lose Internet connectivity:
1 2 3 |
server 127.127.1.0 fudge 127.127.1.0 stratum 10 |
Restart NTP:
1 2 |
sudo /etc/init.d/ntp restart |
NTP Clients
On all the remaining nodes in your cluster, set them up to sync clocks with the node which was designated as the main time server in the cluster.
1 2 |
sudo nano /etc/ntp.conf |
Add:
1 |
server <main time server> iburst |
, where <main time server>
is the ip address of the node designated as the main time server.
Remove the following lines in the con
file by commenting out with a #
character at the beginning of the line:
1 2 3 4 5 6 7 8 9 10 11 |
# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board # on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for # more information. #server 0.ubuntu.pool.ntp.org #server 1.ubuntu.pool.ntp.org #server 2.ubuntu.pool.ntp.org #server 3.ubuntu.pool.ntp.org # Use Ubuntu's ntp server as a fallback. #server ntp.ubuntu.com |
Restart NTP:
1 2 |
sudo /etc/init.d/ntp restart |
Check Connectivity to main time server:
1 2 |
ntpq -c lpeer |
3 Comments