安装配置
[root@node-120 ~]# yum install crmsh pcs corosync pacemaker -y # crmsh已经独立为一个项目,使用它需要独立安装,centos7自带的还是pcs. [root@node-120 ~]# cat /etc/hosts 127.0.0.1localhostlocalhost.localdomainlocalhost4 ::1localhostlocalhost.localdomain 192.168.199.120 node-120 192.168.199.123 node-123 192.168.199.124 node systemctl start pcsd ; systemctl enable pcsd # 每个节点都执行 echo "hacluster:openstack" | chpasswd # 每个节点都执行 [root@node-120 ~]# pcs cluster auth -u hacluster -p openstack node-120 node-123 [root@node-120 ~]# pcs cluster setup –name controller node-120 node-123 --transport udpu --force # 自动生成corosync配置文件 [root@node-120 ~]# pcs clsuter start --all # 启动集群 [root@node-120 ~]# pcs cluster enable --all # 集群中的节点自动启动 # 如果pacemaker服务启动失败,报连接cib失败的错误,解决方法如下: 拷贝好的节点以下目录覆盖坏的节点的目录。 这里有个关于pacemaker的bug: https://bugs.launchpad.net/ubuntu/+source/pacemaker/+bug/1439649 corosync默认data目录:/var/lib/corosync pacemaker默认data目录:/var/lib/pacemaker # 这里有cib集群配置信息 pcs默认data目录:/var/lib/pcs # 这里存放认证用户信息 [root@node-120 ~]# pcs resource defaults resource-stickiness=100 # 防止故障恢复后资源迁移 [root@node-120 ~]# pcs property set no-quorum-policy=ignore [root@node-120 ~]# pcs property set stonith-enabled=false [root@node-120 ~]# pcs status Cluster name: controller Last updated: Fri Jul 31 10:32:04 2015 Last change: Thu Jul 30 21:42:13 2015 via cibadmin on node-120 Stack: corosync Current DC: node-120 (1) - partition with quorum Version: 1.1.10-32.el7_0.1-368c726 2 Nodes configured 2 Resources configured 注:使用pcs创建集群方便多了,而且centos7支持pcs也比较好。 [root@node-120 ~]# pcs resource create rs_mount_glance Filesystem device=localhost:/glance directory=/glance_gfs fstype=glusterfs # 创建一条自动挂载gluster volume的资源 [root@node-120 ~]# pcs resource clone rs_mount_glance # 成为克隆资源 [root@node-120 ~]# pcs resource meta rs_mount_glance-clone failure-timeout=30 # 每隔30s对失败资源进行restart [root@node-120 ~]# pcs config Cluster Name: controller Corosync Nodes: node-120 node-123 Pacemaker Nodes: node-120 node-123 Resources: Clone: rs_mount_glance-clone Meta Attrs: failure-timeout=30 Resource: rs_mount_glance (class=ocf provider=heartbeat type=Filesystem) Attributes: device=localhost:/glance directory=/glance_gfs fstype=glusterfs Operations: start interval=0s timeout=60 (rs_mount_glance-start-timeout-60) stop interval=0s timeout=60 (rs_mount_glance-stop-timeout-60) monitor interval=20 timeout=40 (rs_mount_glance-monitor-interval-20) Stonith Devices: Fencing Levels: Location Constraints: Ordering Constraints: Colocation Constraints: Cluster Properties: cluster-infrastructure: corosync dc-version: 1.1.10-32.el7_0.1-368c726 last-lrm-refresh: 1438347821 no-quorum-policy: ignore stonith-enabled: false [root@node-120 ~]# pcs resource update rs_mount_glance meta requires=nothing # requires=nothing表示无论如何cluster都会启动这个resource
pcs提供了web UI界面
参考链接
Red_Hat_Enterprise_Linux-7-High_Availability_Add-On_Reference-en-US.pdf