Quantcast
Channel: Php2s.com Linux Guide » CentOS 6.2
Viewing all articles
Browse latest Browse all 15

how to Synchronize Time on CentOS 6.2 using NTP

0
0

This tutorial shows, how to install and do Time synchronization on CentOS 6.2 using NTP (Network Time Protocol) manually. 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 CentOS

To install the ntp, just enter this command at the terminal:

[php2s@CentOS ~]$ sudo yum install ntp

To make the ntpd start at boot time, use this commands:

[php2s@CentOS ~]$ sudo chkconfig ntpd on

Set your own time zone

After installation, edit the default ntp configuration:

[php2s@CentOS ~]$ sudo 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.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.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 Australia, you can use

server 0.au.pool.ntp.org
server 1.au.pool.ntp.org
server 2.au.pool.ntp.org
server 3.au.pool.ntp.org

instead of use default one.

Please chose pool zone from http://www.pool.ntp.org/en/
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:

[php2s@CentOS ~]$ 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:

[php2s@CentOS ~]$ sudo service ntpd start

To check if the NTP service is synchronizing:

[php2s@CentOS ~]$  sudo ntpq -pn

To check the synchronization log:

[php2s@CentOS ~]$  sudo tail -f /var/log/messages

Now compare your time with your systems time

[php2s@CentOS ~]$ date

Thanks for visiting Php2s.

Incoming search terms:


Viewing all articles
Browse latest Browse all 15

Latest Images

Trending Articles





Latest Images