corosync+pacemaker使用pcs构建高可用集群
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了corosync+pacemaker使用pcs构建高可用集群相关的知识,希望对你有一定的参考价值。
一、corosync+pacemaker集群前提准备
集群前提准备 --> HA-web
承接上文 --> corosync+pacemaker使用crmsh构建高可用集群
二、准备pcs
[[email protected] ~]# yum install pcs 禁用stonith设备 [[email protected] ~]# pcs property set stonith-enable=false [[email protected] ~]# pcs property set no-quorum-policy=ignore 查看集群状态 [[email protected] ~]# pcs status Cluster name: Last updated: Tue Nov 22 12:20:59 2016 Last change: Tue Nov 22 11:57:08 2016 by root via cibadmin on node1 Stack: classic openais (with plugin) Current DC: node1 (version 1.1.14-8.el6_8.2-70404b0) - partition with quorum 2 nodes and 0 resources configured, 2 expected votes Online: [ node1 node2 ] Full list of resources: PCSD Status: Error: Unable to read /etc/cluster/cluster.conf: No such file or directory
这里有一个报错,提示为没有集群配置文件。但此处的配置文件需要cman插件提供,所以,暂不理会。
三、配置corosync+pacemaker+pcs高可用web
1、查看pcs支持的资源代理类型
[[email protected] ~]# pcs resource standards ocf lsb service stonith
2、查看ocf资源代理类型的子类型
[[email protected] ~]# pcs resource providers heartbeat pacemaker
3、查看可以被代理的资源
[[email protected] ~]# pcs resource agents [[email protected] ~]# pcs resource agents lsb [[email protected] ~]# pcs resource agents ocf:heartbeat
4、查看资源代理的详细信息
[[email protected] ~]# pcs resource describ ocf:heartbeat:IPaddr [[email protected] ~]# pcs resource describ ocf:heartbeat:httpd
5、定义ip httpd 资源(接上文,httpd提供页面,禁止开机启动)
[[email protected] ~]# pcs resource create webip ocf:heartbeat:IPaddr params ip=192.168.0.17 op monitor interval=20s timeout=40s [[email protected] ~]# pcs resource create webserver lsb:httpd op monitor interval=20s timeout=40s
6、查看资源运行情况
[[email protected] ~]# pcs status Cluster name: Last updated: Tue Nov 22 13:07:16 2016 Last change: Tue Nov 22 13:06:45 2016 by root via cibadmin on node1 Stack: classic openais (with plugin) Current DC: node1 (version 1.1.14-8.el6_8.2-70404b0) - partition with quorum 2 nodes and 2 resources configured, 2 expected votes Online: [ node1 node2 ] Full list of resources: webip (ocf::heartbeat:IPaddr): Started node1 webserver (lsb:httpd): Started node2 PCSD Status: Error: Unable to read /etc/cluster/cluster.conf: No such file or directory
7、定义排列约束
[[email protected] ~]# pcs constraint colocation add webserver with webip [[email protected] ~]# pcs status Cluster name: Last updated: Tue Nov 22 13:13:18 2016 Last change: Tue Nov 22 13:12:28 2016 by root via cibadmin on node1 Stack: classic openais (with plugin) Current DC: node1 (version 1.1.14-8.el6_8.2-70404b0) - partition with quorum 2 nodes and 2 resources configured, 2 expected votes Online: [ node1 node2 ] Full list of resources: webip (ocf::heartbeat:IPaddr): Started node2 webserver (lsb:httpd): Started node2 Failed Actions: * webserver_start_0 on node1 ‘unknown error‘ (1): call=20, status=complete, exitreason=‘none‘, last-rc-change=‘Tue Nov 22 13:12:29 2016‘, queued=0ms, exec=508ms
测试
[[email protected] ~]# curl 192.168.0.17 This is node2
8、定义顺序约束
[[email protected] ~]# pcs constraint order webip then webserver Adding webip webserver (kind: Mandatory) (Options: first-action=start then-action=start)
9、定义位置约束
[[email protected] ~]# pcs constraint location webip prefers node2=100
本文出自 “linux启航” 博客,请务必保留此出处http://jiayimeng.blog.51cto.com/10604001/1875369
以上是关于corosync+pacemaker使用pcs构建高可用集群的主要内容,如果未能解决你的问题,请参考以下文章
LINUX集群学习二——pacemaker+corosync+pcs实验
http高可用+负载均衡 corosync + pacemaker + pcs
http高可用+负载均衡 corosync + pacemaker + pcs
pcs+pacemaker+corosync+nfs配置高可用