一、corosync+pacemaker集群前提准备
集群前提准备 --> HA-web
承接上文 --> corosync+pacemaker使用crmsh构建高可用集群
二、准备pcs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
[root@node1 ~] # yum install pcs
禁用stonith设备 [root@node1 ~] # pcs property set stonith-enable=false
[root@node1 ~] # pcs property set no-quorum-policy=ignore
查看集群状态 [root@node1 ~] # 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支持的资源代理类型
1
2
3
4
5
|
[root@node1 ~] # pcs resource standards
ocf lsb service stonith |
2、查看ocf资源代理类型的子类型
1
2
3
|
[root@node1 ~] # pcs resource providers
heartbeat pacemaker |
3、查看可以被代理的资源
1
2
3
|
[root@node1 ~] # pcs resource agents
[root@node1 ~] # pcs resource agents lsb
[root@node1 ~] # pcs resource agents ocf:heartbeat
|
4、查看资源代理的详细信息
1
2
|
[root@node1 ~] # pcs resource describ ocf:heartbeat:IPaddr
[root@node1 ~] # pcs resource describ ocf:heartbeat:httpd
|
5、定义ip httpd 资源(接上文,httpd提供页面,禁止开机启动)
1
2
|
[root@node1 ~] # pcs resource create webip ocf:heartbeat:IPaddr params ip=192.168.0.17 op monitor interval=20s timeout=40s
[root@node1 ~] # pcs resource create webserver lsb:httpd op monitor interval=20s timeout=40s
|
6、查看资源运行情况
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[root@node1 ~] # 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、定义排列约束
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
[root@node1 ~] # pcs constraint colocation add webserver with webip
[root@node1 ~] # 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
|
测试
1
2
|
[root@node1 ~] # curl 192.168.0.17
This is node2 |
8、定义顺序约束
1
2
|
[root@node1 ~] # pcs constraint order webip then webserver
Adding webip webserver (kind: Mandatory) (Options: first-action=start then -action=start)
|
9、定义位置约束
1
|
[root@node1 ~] # pcs constraint location webip prefers node2=100
|
本文转自 元婴期 51CTO博客,原文链接:http://blog.51cto.com/jiayimeng/1875369