Linux高可用之Corosync+Pacemaker详解(2)

查看配置所有信息:
crm(live)configure# show
node marvin
node sherry
property cib-bootstrap-options: \
    have-watchdog=false \
    dc-version=1.1.14-8.el6-70404b0 \
    cluster-infrastructure="classic openais (with plugin)" \
    expected-quorum-votes=2 \
    stonith-enabled=false
        no-quorum-policy=ignore

定义资源:
定义一个ip:
crm(live)configure# primitive webip ocf:heartbeat:IPaddr params ip=192.168.1.199
crm(live)configure# verify
crm(live)configure# commit
crm(live)configure# show
node marvin
node sherry
primitive webip IPaddr \
    params ip=192.168.1.199
property cib-bootstrap-options: \
    have-watchdog=false \
    dc-version=1.1.14-8.el6-70404b0 \
    cluster-infrastructure="classic openais (with plugin)" \
    expected-quorum-votes=2 \
    stonith-enabled=false

[root@marvin ~]# ip addr show eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:0c:34:2c brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.220/24 brd 192.168.1.255 scope global eth1
    inet 192.168.1.199/24 brd 192.168.1.255 scope global secondary eth1
    inet6 fe80::20c:29ff:fe0c:342c/64 scope link 
      valid_lft forever preferred_lft forever

后期定义监控:kill后会自动启动
crm(live)configure# monitor webserver 30s:15s    #删除可直接edit  30s监控一次15s延迟
crm(live)configure# verify
crm(live)configure# commit
 
crm(live)configure# show
primitive webserver lsb:nginx \
    meta target-role=Stopped \
    op monitor interval=30s timeout=15s

nfs:(定义监控) (定义正确,未提交)

crm(live)configure# primitive webstore ocf:heartbeat:Filesystem params device="sherry:/nfsshared/node1" directory="/mnt/nfs/node1"  fstype='nfs' op monitor interval=20s timeout=40s op start timeout=60s op stop timeout=60s  on-fail=restart
crm(live)configure# verify

nginx:(定义监控)

crm(live)configure# primitive webserver lsb:nginx op monitor interval=30s timeout=15s  on-fail=restart 
crm(live)configure# verify
crm(live)configure# commit
crm(live)configure# show
node marvin
node sherry
primitive webip IPaddr \
    params ip=192.168.1.199
primitive webserver lsb:nginx
property cib-bootstrap-options: \
    have-watchdog=false \
    dc-version=1.1.14-8.el6-70404b0 \
    cluster-infrastructure="classic openais (with plugin)" \
    expected-quorum-votes=2 \
    stonith-enabled=false

status:
crm(live)# status
Last updated: Wed Jun  1 20:38:32 2016      Last change: Wed Jun  1 20:36:32 2016 by root via cibadmin on sherry
Stack: classic openais (with plugin)
Current DC: marvin (version 1.1.14-8.el6-70404b0) - partition with quorum
2 nodes and 2 resources configured, 2 expected votes
 
Online: [ marvin sherry ]
 
Full list of resources:
 
 webip (ocf::heartbeat:IPaddr):    Started marvin
 webserver (lsb:nginx):    Started sherry

资源停止:
crm(live)# resource
crm(live)resource# stop webserver
 
crm(live)resource# status
 webip (ocf::heartbeat:IPaddr):    Started
 webserver (lsb:nginx):    (target-role:Stopped) Stopped

清理资源状态:
crm(live)resource# cleanup webserver
Cleaning up webserver on marvin, removing fail-count-webserver
Cleaning up webserver on sherry, removing fail-count-webserver
 
* The configuration specifies that 'webserver' should remain stopped
 
Waiting for 2 replies from the CRMd.. OK

组操作:

先定义好资源,在加入组

crm(live)# status
Last updated: Wed Jun  1 20:38:32 2016      Last change: Wed Jun  1 20:36:32 2016 by root via cibadmin on sherry
Stack: classic openais (with plugin)
Current DC: marvin (version 1.1.14-8.el6-70404b0) - partition with quorum
2 nodes and 2 resources configured, 2 expected votes
Online: [ marvin sherry ]
Full list of resources:
 webip (ocf::heartbeat:IPaddr):    Started marvin
 webserver (lsb:nginx):    Started sherry
crm(live)# configure
crm(live)configure# group webservice webip webserver
crm(live)configure# verify
crm(live)configure# commit
crm(live)configure# show
node marvin
node sherry
primitive webip IPaddr \
    params ip=192.168.1.199
primitive webserver lsb:nginx
group webservice webip webserver
property cib-bootstrap-options: \
    have-watchdog=false \
    dc-version=1.1.14-8.el6-70404b0 \
    cluster-infrastructure="classic openais (with plugin)" \
    expected-quorum-votes=2 \
    stonith-enabled=false

删除组:
crm(live)resource# stop webservice
 
crm(live)configure# delete webservice    #组下面的资源还是存在

节点操作:

节点离线:
crm(live)# node
crm(live)node# standby marvin  #资源自动转移

节点上线:
crm(live)node# online marvin

节点清理:(节点上资源信息清理)

crm(live)node# clearstate marvin

位置约束:

绑定在一起:
crm(live)configure# colocation webserver_and_webip inf: webserver webip
crm(live)configure# verify
crm(live)configure# commit

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/4f796ab667f90182b458f48de4978eaf.html