The NTP is used to synchronize a pc’s time with a reference time source. Under CentOS / RHEL you can use NTP or OpenNTPD server software. Both package provides client and server software programs for time synchronization.
Install NTP on RHEL
To install the ntp, just enter this command at the terminal:
[root@server ~]$ yum install ntp
To make the ntpd start at boot time, use this commands:
[root@server ~]$ chkconfig ntpd on
Set your own time zone
After installation, edit the default ntp configuration:
[root@server ~]$ nano /etc/ntp.conf
Commented out/remove the default CentOS servers,you can add your own time-servers here to synchronize with, lists:
http://www.pool.ntp.org/en/
http://www.pool.ntp.org/zone/europe or
http://www.pool.ntp.org/zone/north-america
Default NTP time-servers
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org
This is a really good idea which uses round-robin DNS to return an NTP server from a pool, spreading the load between several different servers. Even better, they have pools for different regions – for instance, if you are in India, you can use
server 0.in.pool.ntp.org
server 1.in.pool.ntp.org
server 2.in.pool.ntp.org
server 3.in.pool.ntp.org
instead of use default one.
Adjusting iptables
NTP uses UDP port 123 to conduct its business, either connecting out to another NTP server or accepting incoming connections. If you have iptables filtering incoming traffic on the main NTP server in your cluster you’ll need to open port 123 to UDP traffic to allow the other servers to connect to it.
You can open port 123 for UDP traffic with the following arguments for iptables:
[root@server ~]# vi /etc/sysconfig/iptables
Add the following rules
-I INPUT -p udp –dport 123 -j ACCEPT
-I OUTPUT -p udp –sport 123 -j ACCEPT
After you are done with the configuration, just start the ntp service:
[root@server ~]# service ntpd start
To check if the NTP service is synchronizing:
[root@server ~]# ntpq -pn
To check the synchronization log:
[root@server ~]# tail -f /var/log/messages
Now compare your time with your systems time
[root@server ~]# date
No comments:
Post a Comment