General operation is the direct use of NTP, the synchronization with the default time server, but it is best for all nodes in the cluster with a time table as a node synchronization server.
Steps of:
selecting a server as a time server.
Root user, see if a server is installed ntp service
rpm -qa | grep ntp
not already installed using
yum install -y ntpd
modify the file /etc/ntp.conf, a total of three modified content:
① the # removed. And modify the network correctly.
192.168.0.0 mask 255.255.255.0 nomodify notrap the restrict
② the following four server will be # commented
#server 0.centos.pool.ntp.org iBurst
#server 1.centos.pool.ntp.org iBurst
#server 2.centos. iBurst pool.ntp.org
#server 3.centos.pool.ntp.org iBurst
③ Finally add two words:
Server 127.127.1.0 #local Clock
Fudge 127.127.1.0 a Stratum 10
edit etc / sysconfig / ntpd file
Drop root to the above mentioned id # 'ntp: ntp' by default.
SYNC_HWCLOCK = yes
the OPTIONS = "- U ntp: ntp -p /var/run/ntpd.pid -g"
to start the ntpd service, and set the boot
systemctl start ntpd.service
systemctl enable ntpd.service
child nodes for each need to be synchronized to confirm there is no ntp. If not, then on installation.
write crontab tasks under the root account in each child node to be synchronized (crontab -e). In this sense the task is next synchronization server and master01 time every 10 minutes.
0-59 / 10 * * * * / usr / sbin / ntpdate 192.168.xx.xx
set time zone Shanghai
RM -rf / etc / localtime
LN -s / usr / report this content share / zoneinfo / Asia / on Shanghai / etc / localtime
then by timing of the task, and the time server aliyun ntp1.aliyun.com
iptables -I -p UDP --dport the INPUT 123 -j ACCEPT
Other commands:
1. Installation tool ntpdate
# -Y yum the install NTP ntpdate
2. setting the system time with network time synchronization
# / usr / sbin / ntpdate ntp1.aliyun.com
3. hardware time to write the system time
# hwclock --systohc
4. compulsory CMOS system time is written in the failure to prevent the restart
hwclock -w
Clock -w