Setup NTP Server and Sync Time with Client

I show you how to setup and sync time with your client to a server for example when you want to have successful master/slave MySQL replication. Most of replication or client/server services should have time sync and identical to make sure no duplicate or backdated data.

In this case we will using 2 servers. Variables as follow:

Server1 = 192.168.1.1
Client1 = 192.168.1.2

Now we setup NTP server in Server1:

1. Install NTP via yum:

yum install ntp -y
									

2. Enable NTP services to be auto start upon boot:

chkconfig ntpd on
									

3. Open /etc/ntp.conf via text editor and add following line:

restrict 192.168.1.0 mask 255.255.255.0
									

4. Save the file and allow the port 123 in your firewall in iptables:

iptables -A INPUT -s 192.168.1.0/24 -m state --state NEW -p udp --dport 123 -j ACCEPT
									

5. Start NTP service:

service ntpd start
									

Now we need to configure Client1 to sync time with our NTP server. Login to your client and as follow:

1. Install NTP service:

yum install ntp -y
									

2. Sync the time with Server1:

ntpdate -u 192.168.1.1
									

3. Start the NTP service:

service ntpd start
									

4. Verify the synchronization with command date:

date
									

Leave a comment

Leave a Reply

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