本文介绍下corosync的资源监控功能:
node1 node1.luojianlong.com 192.168.30.116 OS: Centos 6.4 x86_64
node2 node2.luojianlong.com 192.168.30.117 OS: Centos 6.4 x86_64
1.定义corosync资源:
1
2
3
4
5
6
7
8
9
10
11
|
[root@node1 ~]
# crm configure primitive WebIP ocf:heartbeat:IPaddr params ip=192.168.30.230 op monitor interval=20 timeout=15 on-fail=restart
[root@node2 ~]
# crm status
Last updated: Tue Mar 25 13:22:25 2014
Last change: Tue Mar 25 13:17:52 2014 via cibadmin on node1.luojianlong.com
Stack: classic openais (with plugin)
Current DC: node1.luojianlong.com - partition with quorum
Version: 1.1.10-14.el6_5.1-368c726
2 Nodes configured, 2 expected votes
1 Resources configured
Online: [ node1.luojianlong.com node2.luojianlong.com ]
WebIP (ocf::heartbeat:IPaddr): Started node1.luojianlong.com
|
发现WebIP已经在node1自动启动
2.验证corosync在其中一个节点启动失败时,会在另外一个节点启动
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#在node1和node2上分别安装nginx
[root@node1 ~]
# yum -y install nginx
[root@node2 ~]
# yum -y install nginx
#在node2上启动httpd,模拟80端口被占用,使nginx无法启动
[root@node2 ~]
# service httpd start
Starting httpd: [ OK ]
#创建nginx资源
[root@node2 ~]
# crm configure primitive nginx lsb:nginx op monitor interval=20 timeout=20 on-fail=restart
[root@node2 ~]
# crm status
Last updated: Tue Mar 25 13:40:30 2014
Last change: Tue Mar 25 13:37:07 2014 via cibadmin on node2.luojianlong.com
Stack: classic openais (with plugin)
Current DC: node1.luojianlong.com - partition with quorum
Version: 1.1.10-14.el6_5.1-368c726
2 Nodes configured, 2 expected votes
2 Resources configured
Online: [ node1.luojianlong.com node2.luojianlong.com ]
WebIP (ocf::heartbeat:IPaddr): Started node1.luojianlong.com
nginx (lsb:nginx): Started node1.luojianlong.com
#在node1上发现nginx服务已经启动:
[root@node1 ~]
# ss -antpl | grep nginx
LISTEN 0 128 *:80 *:*
users
:((
"nginx"
,29510,6),(
"nginx"
,29512,6))
|
本文转自ljl_19880709 51CTO博客,原文链接http://blog.51cto.com/luojianlong/1383768,如需转载请自行联系原作者