从HeartBeat3 开始 分为三个项目 Heartbeat 、 Cluster Glue 、 Resource Agents。
一、Heartbeat安装
For example to install on RHEL5.3 for i386, you'd run:
su -c 'rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-3.noarch.rpm'
Now add the Cluster Labs repo:
wget -O /etc/yum.repos.d/pacemaker.repo http://clusterlabs.org/rpm/epel-5/clusterlabs.repo
And finally, install Pacemaker:
yum install -y pacemaker corosync heartbeat
虽然安装了 corosync 但 此配置中仅仅使用heartbeat
二、配置Heartbeat
cp /usr/share/doc/heartbeat-3.0.3/ha.cf /etc/ha.d/
cp /usr/share/doc/heartbeat-3.0.3/authkeys /etc/ha.d/
2.1配置节点
vi /etc/ha.d/ha.cf
2.2 配置节点通信加密方式
vi
/etc/ha.d/authkeys
auth 1
1 crc
# chmod 600 authkeys
启动heartbeat
# service heartbeat start
2.3配置节点资源(服务)
# crm configure show error
# cibadmin --upgrade --force
# crm configure show xml
# crm_verify -L
error 我们将 stonith-enabled设置为 false 来关闭STONITH
# crm configure property stonith-enabled=false
# crm_verify -L
2.3.1添加一个资源 浮动IP
# crm configure primitive ClusterIP ocf:heartbeat:IPaddr2 \
params ip=192.168.122.101 cidr_netmask=32 \
op monitor interval=30s
找到OCF中Pacemaker和Heartbeat提供的资源脚本,运行下面的命令
# crm ra list ocf pacemaker
# crm ra list ocf heartbeat
现在检查下IP 资源是不是已经添加了,并且看看是否处在可用状态。
# crm configure shownode pcmk-1
# crm_mon
首先,找到IP资源现在在哪个节点上运行
# crm resource status ClusterIP
防止资源在节点恢复后移动
# crm configure rsc_defaults resource-stickiness=100
# crm configure show
2.3.2增加新资源Apache
# crm configure primitive WebSite ocf:heartbeat:apache params configfile=/etc/httpd/conf/httpd.conf op monitor interval=1min
# crm configure show
# crm_mon
确保资源在同一个节点运
# crm configure colocation website-with-ip INFINITY: WebSite ClusterIP
# crm configure show
# crm_mon
控制资源的启动停止顺序
# crm configure order apache-after-ip mandatory: ClusterIP WebSite
# crm configure show
在集群中手工地移动资源
# crm resource move WebSite pcmk-1
# crm_mon # crm configure show
自动生成 location cli-prefer-WebSite WebSite \ rule $id="cli-prefer-rule-WebSite" inf: #uname eq pcmk-1
把控制权交还给集群
# crm resource unmove WebSite
# crm configure show
指定优先的 Location
# crm configure location prefer-pcmk-1 WebSite 50: pcmk-1
# crm configure show
如果要看现在的分值,可以用ptest这个命令
ptest -sL