UnixGuys

Got a little geek in you?
Subscribe

Archive for September, 2008

Configuring CentOS to use NTP

September 11, 2008 By: HKP30 Category: CentOS 4042 Comments →

There are a number of reasons you might want a server to use NTP not the least of which is a desire to synchronize the clocks on multiple systems so that times/dates in logs line up.  I finally got around to configuring NTP on our H-Sphere server.  The process is pretty simple on CentOS.

First Install the NTP Package on your server as root.

[root@cp ~]# yum install ntp

Loading “fastestmirror” plugin
Loading mirror speeds from cached hostfile
* base: mirror.steadfast.net
* updates: mirrors.liquidweb.com
* addons: pubmirrors.reflected.net
* extras: pubmirrors.reflected.net
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
–> Running transaction check
—> Package ntp.i386 0:4.2.2p1-8.el5.centos.1 set to be updated
–> Finished Dependency Resolution

Dependencies Resolved

=================================================================
Package                 Arch       Version          Repository        Size
=================================================================
Installing:
ntp                     i386       4.2.2p1-8.el5.centos.1  base              1.3 M

Transaction Summary
=================================================================
Install      1 Package(s)
Update       0 Package(s)
Remove       0 Package(s)

Total download size: 1.3 M
Is this ok [y/N]: y
Downloading Packages:
(1/1): ntp-4.2.2p1-8.el5. 100% |=========================| 1.3 MB    00:19
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: ntp                          ######################### [1/1]

Installed: ntp.i386 0:4.2.2p1-8.el5.centos.1
Complete!

Next set it to start automatically on a reboot

[root@cp ~]# chkconfig ntpd on

Tell it which NTP server it should update it’s time from

[root@cp ~]# ntpdate pool.ntp.org
4 Aug 12:32:43 ntpdate[9540]: step time server 64.202.112.75 offset 1256.453048 sec

Verify that the Time & Date are correct

[root@cp ~]# date
Mon Aug  4 12:33:04 EDT 2008

Finally start the service

[root@cp ~]# service ntpd start
Starting ntpd:                                             [  OK  ]

Easy as could be.  If you set all of your servers to update their time from the same pool server your time will be accurate within two seconds or better.  If you update one server to the pool, and tell all the rest to update from your own NTP server time can be even more accurate.  I don’t need that level of accuracy and tend to just use the pool.