All nodes must be sure that you have installed ntpd (in Step 4 is installed)
1. First select a time server as a server.
Assume selected as node1.sunny.cn server time server.
2.ntp server configuration
Modify the ntp.conf file:
vi /etc/ntp.conf
A total of three modify the contents of the # removed, and modify the network correctly.
restrict 192.168.2.2 mask 192.168.2.255 nomodify notrap
The following four server will be # commented out.
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
Finally, add two sentences:
server 127.127.1.0 #local clock
fudge 127.127.1.0 stratum 10
3. Edit / etc / sysconfig / ntpd file is replaced with the following
vim /etc/sysconfig/ntpd
# Drop root to id 'ntp:ntp' by default.
SYNC_HWCLOCK=yes
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
4. Set the correct time, start ntpd service, and set the boot
This step can be ignored
date -s ‘2017-01-01 01:01:01’
Start Serviceservice ntpd start
Add the following command line to start ntp server in the /etc/rc.local
/etc/init.d/ntpd start
Write crontab task in each child node to be synchronized at 5.root account.
command:
crontab -e
Enter the following:
0-59/10 * * * * /usr/sbin/ntpdate node1.sunny.cn
In this sense the task is synchronized every 10 minutes and node1 time.
6. Perform / usr / sbin / ntpdate node1.sunny.cn time synchronization server immediately.