How to make two or more servers linux time synchronization

origin

Sometimes we have to let our needs time keeping multiple servers, then how can we do it? Roughly divided into the following steps

  1. Set up a time server
  2. The other servers in the server time and this time is consistent and regularly updated

Stands server

To set up a time server handwritten need to install ntp service that some versions of linux on by default on installation, we can see by following command if there is installed

rpm -qa | grep ntp

Here Insert Picture Description
I appeared on the red box on the drawing instructions already installed
If not, then you need to install, the installation is divided into online and offline installation installation, installation is very simple online, offline installation need to download the corresponding rpm installation package, this package is very easy to find, I am here to give a
ntp rpm installation package
download down after installed, you need to configure the

vi /etc/ntp.conf

Enter the following and save

# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10

Wherein restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap 192.168 network server for the allowed time synchronization with this server

Open ntp service

service ntpd start

Set ntp boot from the start

chkconfig ntpd on

After also need to default port 123 ntp were released, this must be equipped with, unless you turn off the firewall, otherwise it will error, no server suitable for synchronization found

iptables -I INPUT -p tcp --dport 123 -j ACCEPT

iptables -I INPUT -p udp --dport 123 -j ACCEPT

At this point of time the server set up is completed, then we need to configure your server to synchronize

Configure the server needs to synchronize time

As the installation is in accordance with claim ntp
begin after installing the configuration

vi /etc/ntp.conf

Enter the following and save

server 10.0.3.42
fudge 10.0.3.42 stratum 10

Remember to replace is the address of your time server that's

start up

service ntpd start

Set boot from the start

chkconfig ntpd on

Try to manually synchronize at

ntpdate -d 10.0.3.42

The following message appears your synchronization success
Here Insert Picture Description
last can be viewed via the following command whether the timing synchronization

ntpq -p

Here Insert Picture Description
when here represents the last synchronization time from now, through this long period of time it can determine whether there is in sync automatically.

Published 114 original articles · won praise 146 · Views 350,000 +

Guess you like

Origin blog.csdn.net/qq32933432/article/details/102461086