概述:
pacemaker是heartbeat到了v3版本后拆分出来的资源管理器,所以pacemaker并不提供心跳信息,我们这个集群还需要corosync(心跳信息)的支持才算完整。pacemaker的功能是管理整个HA的控制中心,客户端通过pacemaker来配置管理整个集群。还有一款帮助我们自动生成配置文件,并且进行节点配置文件同步的crmshell是我们搭建集群的时候的一个利器。
1.安装集群软件
yum install pacemaker corosync -y
直接通过yum安装pacemaker和corosync
crmsh-1.2.6-0.rc2.2.1.x86_64.rpm
pssh-2.3.1-2.1.x86_64.rpm
安装以上两个rpm包,其中crmsh对pssh有依赖性。
2.通过crm配置集群
[root@ha1 ~]# crm
crm(live)#
直接输入crm(cluster resource manager)进入集群资源管理器
crm(live)#
? cib exit node ra status
bye configure help options resource up
cd end history quit site
输入tab键可以看到相关的管理项
我们现在需要配置集群,所有进入configure。
ERROR: running cibadmin -Ql: Could not establish cib_rw connection: Connection refused (111)
Signon to CIB failed: Transport endpoint is not connected
Init failed, could not perform requested operations
出现了如上的错误,这应该是没有开启corosync服务造成的。就算没有看到错误,我们连心跳层都没有开更不要谈开启更高层的集群管理了,所以现在先配置corosync。
[root@ha1 ~]# rpm -ql corosync
/etc/corosync
/etc/corosync/corosync.conf.example
使用rpm命令查找到corosync的配置文件的位置。
将配置文件后的example去掉,配置文件内容修改成如下即可:
# Please read the corosync.conf.5 manual page
compatibility: whitetank
totem {
version: 2
secauth: off
threads: 0
interface {
ringnumber: 0
bindnetaddr: 192.168.5.0 #集群管理信息所传送的网段
mcastaddr: 226.94.1.1 #确定多播地址
mcastport: 5405 #确定多播端口
ttl: 1 #只向外多播ttl为1的报文,防止发生环路
}
}
logging {
fileline: off
to_stderr: no
to_logfile: yes
to_syslog: yes
logfile: /var/log/cluster/corosync.log
debug: off
timestamp: on
logger_subsys {
subsys: AMF
debug: off
}
}
amf {
mode: disabled
}
service {
#让corosync去加载pacemaker
name: pacemaker
ver: 0 #版本号,如果版本号是1的话这个插件不会去启动pacemaker,如果为0就会自动启用pacemaker
}
接下来启动corosync如果启动成功,而且日志中没有报错,那么就成功了。
现在crm应该可以正常使用了。
crm(live)# configure
crm(live)configure# show
node ha1.mo.com
node ha2.mo.com
property $id="cib-bootstrap-options" \
dc-version="1.1.10-14.el6-368c726" \
cluster-inf