Wednesday, January 30, 2008

NTP installation and Date Synchronization

NTP stands for Network Time Protocol, and it is an Internet protocol used to synchronize the clocks of computers to some time reference. SNTP (Simple Network Time Protocol) is basically also NTP, but lacks some internal algorithms that are not needed for all types of servers.

Why should Time be synchronized?
-----------------------------------

Time usually just advances. If you have communicating programs running on different computers, time still should even advance if you switch from one computer to another. Obviously if one system is ahead of the others, the others are behind that particular one. From the perspective of an external observer, switching between these systems would cause time to jump forward and back, a non-desirable effect.

As a consequence, isolated networks may run their own wrong time, but as soon as you connect to the Internet, effects will be visible. Just imagine some EMail message arrived five minutes before it was sent, and there even was a reply two minutes before the message was sent.

Even on a single computer some applications have trouble when the time jumps backwards. For example, database systems using transactions and crash recovery like to know the time of the last good state.

What are the basic features of NTP?
-------------------------------------

There exist several protocols to synchronize computer clocks, each having distinguished features. Here is a list of NTP's features:

NTP needs some reference clock that defines the true time to operate. All clocks are set towards that true time. (It will not just make all systems agree on some time, but will make them agree upon the true time as defined by some standard.)

NTP uses UTC as reference time

  • NTP is a fault-tolerant protocol that will automatically select the best of several available time sources to synchronize to. Multiple candidates can be combined to minimize the accumulated error. Temporarily or permanently insane time sources will be detected and avoided.

  • NTP is highly scalable: A synchronization network may consist of several reference clocks. Each node of such a network can exchange time information either bidirectional or unidirectional. Propagating time from one node to another forms a hierarchical graph with reference clocks at the top.

  • Having available several time sources, NTP can select the best candidates to build its estimate of the current time. The protocol is highly accurate, using a resolution of less than a nanosecond



Install ntp
--------------

You can easily install NTP (Network Time Protocol, a means of transmitting time signals over a computer network) using yum command under Redhat or CentOS/Fedora core Linux.

# yum install ntp
# chkconfig ntpd on
# ntpdate pool.ntp.org
# /etc/init.d/ntpd start

Make sure that you have opened the ports 13 and 123


OR

*download ntp files from

http://www.ntp.org/downloads.html

*untar
*cd
*./configure --prefix=/usr --bindir=/usr/sbin \
--sysconfdir=/etc &&

*make
make check
*make install

configurajtion file

/etc/ntp.conf


?Set dat and time in different time zone


date
vi /usr/share/zoneinfo/Singapore
ln -s /usr/share/zoneinfo/Singapore /etc/localtime
unlink /etc/localtime
ln -s /usr/share/zoneinfo/Singapore /etc/localtime
date monthdatetime



Synchronizing the Time
----------------------

There are two options. Option one is to run ntpd continuously and allow it to synchronize the time in a gradual manner. The other option is to run ntpd periodically (using cron) and update the time each time ntpd is scheduled.

If you choose Option one, then install the /etc/rc.d/init.d/ntp init script included in the blfs-bootscripts-6.1 package.


make install-ntp

If you prefer to run ntpd periodically, add the following command to root's crontab:

ntpd -q


Contents
--------
Installed Programs: ntp-keygen, ntp-wait, ntpd, ntpdate, ntpdc, ntpq, ntptime, ntptrace, and tickadj
Installed Libraries: None
Installed Directory: /usr/share/doc/ntp-4.2.0


Short Descriptions
------------------
ntp-keygen

generates cryptographic data files used by the NTPv4 authentication and identification schemes.

ntp-wait

is useful at boot time, to delay the boot sequence until ntpd has set the time.

ntpd

is a NTP daemon that runs in the background and keeps the date and time synchronized based on response from configured NTP servers. It also functions as a NTP server.

ntpdate

is a client program that sets the date and time based on the response from an NTP server. This command is deprecated.

ntpdc

is used to query the NTP daemon about its current state and to request changes in that state.

ntpq

is an utility program used to monitor ntpd operations and determine performance.
ntptime

reads and displays time-related kernel variables.

ntptrace

traces a chain of NTP servers back to the primary source.

tickadj

reads, and optionally modifies, several timekeeping-related variables in older kernels that do not have support for precision timekeeping.

No comments: