Don't Miss

Howto Synchronize Time using NTP

By on January 21, 2013

Network time protocol (NTP), NTP lets you automatically sync your system time with a remote server. Setting up an NTP server to regularly adjust your machine’s clock is pretty easy by default. And its useful when your machine battery turns low. It’s also possible to make it a bit more complicated if you need your clock accurate down to the millisecond instead of just to the second.

This tutorial shows, how to install and do Time synchronization on CentOS or Fedora using NTP (Network Time Protocol) manually. The NTP is used to synchronize a pc’s time with a reference time source. Under CentOS / Fedora / RHEL you can use NTP or OpenNTPD server software. Both package provides client and server software programs for time synchronization.

Installation
The first thing to do is install the NTP server. Grab the package by running:
$ yum install ntp

Configure NTP to start on boot
$ chkconfig ntpd on

Edit ntp.conf file
$ vi /etc/ntp.conf

The default for CentOS looks like:

# 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

If your in malaysia then it should be:

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 2.my.pool.ntp.org
server 3.asia.pool.ntp.org
server 2.asia.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 function, 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.

Type below command:
$ vi /etc/sysconfig/iptables

Add the following rules

-I INPUT -p udp –dport 123 -j ACCEPT
-I OUTPUT -p udp –sport 123 -j ACCEPT

Restarting iptables
Type below command:
$ /etc/rc.d/init.d/iptables restart

Starting NTPD
Type below command:
$ /etc/rc.d/init.d/ntpd start

To sync:
$ ntpd -pn

View date:
$ date

Error
When your ntp can not sync, you might need to look it at /var/log/messages.

The error “ntp: unable to bind to wildcard socket address 0.0.0.0 – another process may be running – EXITING”

Its obvious that ntpd is runing on the background before you start it. All you have to do is kill it with command:
$ killall -9 ntpd
$ service ntpd start

Problem still not solve. You might try these command:
$ killall -9 ntpdate
$ killall -9 ntpd
$ service ntpd start
$ ntpdate -d 2.my.pool.ntp.org (replace it with your pool)

Have fun~

About jonboy60

Contact Me for computer repair services, mobile repair services, website repair services, website maintenance, creating website, domain name, hosting services, career opportunities, business offers, Linux solutions for business or home, web and email server solutions, Linux consulting, wordpress web consulting & development and expertise requests. Currently reside in Rawang, Selangor. Email to me on jonboy60{@}gmail.com

Leave a Reply

Your email address will not be published. Required fields are marked *