When a program runs on multiple servers, the clock on these servers is sometimes the same. However, when the server runs for a certain period of time, the clock on each server may be different, in this case, all servers need to automatically calibrate their respective clocks.
NTP is a convenient clock service, which can be used for clock synchronization.
(The following solutions apply to local networks that do not connect to the Internet. The requirement is to synchronize all server clocks .)
1. select one of the servers as the benchmark server to provide the clock service.
(1) first, check whether ntp exists. If it does not exist, run the following command to install it:
Yum install ntp
(2) modify the configuration file/etc/ntp. conf and insert:
Restrict 192.168.20.0 mask 255.255.255.0 nomodify notrap
Where:
Use restrict to control permissions
Nomodify-the user end cannot change the time parameter of the ntp server
Noquery-the user end cannot use commands such as ntpq and ntpc to query the ntp server
Notrap-remote trap login not provided
(3) at this time, you can provide the time service to the machine 192.168.20.0/24. Enable the ntp service:
/Etc/rc. d/init. d/ntp start // start the ntp service <br/> chkconfig ntpd on // start the ntp service
(4) check whether the ntp port is Enabled:
Netstat-unlnp
If it is normal, you can see that port 123 is enabled.
2. Client synchronization (using ntpd service)
You can also use ntpdate for manual synchronization, but I recommend using the ntpd service for automatic synchronization here, for more information, see: http://hi.baidu.com/seeseeabc/blog/item/0df2136746fd5c2eaa184c62.html
(1) Modify/etc/ntp. conf and insert:
Server 192.168.255.91
(2) Enable ntpd service to start
Chkconfig ntpd on
(3) Start the client ntpd service
/Etc/rc. d/init. d/ntpd start
Reference: http://hi.baidu.com/seeseeabc/blog/item/0df2136746fd5c2eaa184c62.html