performance / tuning tips. to the point.
|
Using Network Time Protocol (NTP) to synchronize your Linux system's clocks
The Network Time Protocol (NTP) is a protocol used to help synchronize your Linux system's clocks with an
accurate time source. It is good practice to have at least one server on your network be the local time server
for all your other systems / servers. This makes the correlation of system events on different systems much easier, especially
for a set of machines that act as your production environment where all sorts of tests are conducted. It also reduces
Internet bandwidth usage due to NTP traffic and reduces the need to manage firewall rules for each NTP client on your network.
Sometimes, not all your servers will have Internet access (i.e., they are behind a firewall); in such cases you'll need
a central server that all can access.
A simplest view of how NTP is used is described as follows:
Doing An Initial Synchronization
If the time on the local server is very different from that of its primary time server
your NTP daemon will eventually terminate itself leaving an error message in the
/var/log/messages file. You should run the ntpdate -u command to force your server
to become instantly synchronized with its NTP servers before starting the NTP
daemon for the first time. The ntpdate command doesn't run continuously in the
background, you will still have to run the ntpd daemon to get continuous NTP updates.
* The date was originally set to midnight which was verified by using the date command.
[root@smallfry tmp]# date
Thu Aug 12 00:00:00 PDT 2004
[root@smallfry tmp]#
|
* The ntpdate command is run three times to synchronize smallfry's clock to server 192.168.1.100,
but it must be run while the ntpd process is stopped. So you'll have to stop ntpd, run ntpdate and then
start ntpd again.
root@smallfry tmp]# service ntpd stop
[root@smallfry tmp]# ntpdate -u 192.168.1.100
Looking for host 192.168.1.100 and service ntp
host found : bigboy.my-site.com
12 Aug 08:03:38 ntpdate[2472]: step time server 192.168.1.100 offset 28993.084943 sec
[root@smallfry tmp]# ntpdate -u 192.168.1.100
Looking for host 192.168.1.100 and service ntp
host found : bigboy.my-site.com
12 Aug 08:03:40 ntpdate[2472]: step time server 192.168.1.100 offset 2.467652 sec
[root@smallfry tmp]# ntpdate -u 192.168.1.100
Looking for host 192.168.1.100 and service ntp
host found : bigboy.my-site.com
12 Aug 08:03:42 ntpdate[2472]: step time server 192.168.1.100 offset 0.084943 sec
[root@smallfry tmp]# service ntpd start
[root@smallfry tmp]#
* The date is now corrected.
[root@smallfry tmp]# date
Thu Aug 12 08:03:45 PDT 2004
[root@smallfry tmp]#
|
Click here to download NTP.
|
|
|