时间同步:
1、date -s "2015-06-08 22:08:06" // 设置系统时间。
2、配置时间服务器,集群的其他机器都跟其中一台机器同步时间。
定时任务执行时间同步的操作
时间同步服务器需要安装ntp服务
例如将node01作为主服务器,其他节点都同步该节点的时间,在node01上执行如下操作:
1、yum list | grep ntp
2、yum -y install ntp.x86_64
3、修改配置文件:
vi /etc/ntp.conf
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.149.0 mask 255.255.255.0 nomodify notrap #加入这一行,表示允许这个网段的ip来同步时间
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#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
server 127.127.1.0 #先禁用4个自带的服务,添加server 127.127.1.0
客户端(需要做时间同步的机器)需要安装ntpdate
1、yum list | grep ntp
2、yum -y install ntpdate.x86_64