- 积分
- 16843
在线时间 小时
最后登录1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?开始注册
x
使用pcs shell配置corosync & pacemaker群集
% g( k, Y/ ?! @& l* t+ s
0 H5 @' A/ A2 q* z' W/ `& q6 Z/ } {9 P. t$ P4 S- l! J9 {
Pacemaker
% V' F' r8 r1 l% H6 ?! z& g. `Pacemaker,即Cluster Resource Manager(CRM),管理整个HA,客户端通过pacemaker管理监控整个集群。3 Q9 J; E Z2 h6 D9 E
8 k: G! _$ n+ ^1 `, L
CRM支持ocf和lsb两种资源类型:$ L0 z R$ O5 b& e/ t/ G
4 H9 J# a7 v U8 n4 Z& S
ocf格式的启动脚本在/usr/lib/ocf/resource.d/下面。8 d9 T% ~* S2 Q! n0 q8 {
lsb的脚本一般在/etc/rc.d/init.d/下面。' c; X/ q/ ^" Y& k
7 g7 y5 O' t# B) `, L, M7 Y
* g3 E- c$ v$ g8 r2 w/ y- j* R: P6 R9 g x; ]4 ^+ Q
1、常用的集群管理工具:7 y q4 W) n: ], S
(1)基于命令行
+ R) w! F1 _; o% k' fcrm shell/pcs
" c8 d9 w, k8 E
0 W$ [" v. I ?4 |(2)基于图形化: Q4 M( r4 k0 D: e
pygui/hawk/lcmc/pcs
" ~7 p6 l1 k9 ~+ {! B# y9 ~$ p- h/ o4 f( m1 z$ k, s
f, n9 N+ \$ i, a0 `7 Q4 i. y
2、相关的资源文件:
. i: d$ Q/ N C$ ~, l& ~(1)/usr/lib/ocf/resource.d,pacemaker资源库文件位置,可安装资源包:resource-agents 获取更多ocf格式的资源。) j+ V' G. _* _! C) {5 `! W# ~ y2 Q
(2)/usr/sbin/fence_***,Fencing设备的执行脚本名称,可安装资源包:fence-agents 获取更多Fencing设备资源。* Q$ k# \( Z% K$ ?/ X; I
O* Q+ U1 g1 u
3、查看使用说明:
. _( h& S) g" W1 j8 V7 V. G$ \ S [shell]# man ocf_heartbeat_*** ## 查看OCF资源说明,man ocf_heartbeat_apache- h" ]& p9 }0 Y) z' }& t) w
[shell]# man fence_*** ## 查看Fencing设备说明,man fence_vmware! U/ L' A/ X* A' r7 R" h+ W: {
, H* s* q- j2 C$ ~# V4 E* Z4、参考文档
) J0 d/ s5 @: O6 S) S/ l: O6 @https://github.com/ClusterLabs- C. B0 |: X0 t& m9 }- O# ^/ N
http://clusterlabs.org/doc/
+ p2 K, k4 \; Y- h1 F2 ^; c6 `, phttp://www.linux-ha.org/doc/man-pages/man-pages.html/ M4 i8 c; R( q
https://access.redhat.com/docume ... acemaker/index.html) }: Q7 a3 G" j" _
9 n" ^9 V% l: H% T) W1 D2 y+ E在群集配置过程中参考了互联网上众多优秀文章,在此感谢原作者!!!2 S/ K: Z4 B ?; A* A4 C
$ z7 O# W4 a( U c4 ]' ]以下记录整理了在vmware esxi5.5 + centos6.6环境中使用PCS命令配置corosync & pacemaker群集的一些操作,由于本人水平有限,仅供参考:
/ b# G; H6 I7 [5 L; y2 e. c' [4 ^! ]6 q; ~$ w% v9 i6 v
--------------------------------------------------
. L1 I3 i; d L4 R
/ A% j6 L: ^* k# X& }& C
| D5 p$ K4 ~4 u) I4 h3 F1 H1.安装群集软件:1 g( L1 A8 ]8 ?7 _
[shell]# yum -y install corosync pacemaker pcs$ E1 g( D" X# r8 F% T: q
[shell]# yum -y install fence-agents resource-agents
( u/ x3 W. W* B( }6 i+ n; ?" N6 g" w' _+ o3 Y! r z' A1 b
2.拷贝配置文件、启动脚本; u* j e- ]4 ^+ ]9 S
[shell]# mkdir -p /etc/cluster/
6 V2 G2 }) T. O# P. f; u% R [shell]# ln -s /etc/rc.d/init.d/corosync /etc/rc.d/init.d/cman; i/ e, a+ r2 G2 P I/ x; r
[shell]# ln -s /usr/sbin/corosync-cmapctl /usr/sbin/corosync-objctl: f: `2 @6 c R. x+ H: R
[shell]# cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf
! e8 W$ L+ c1 Z) z8 d
5 h: m; e% g7 J0 x9 {% b8 r! Y6 u1 `/ m# u2 q; b
注意:群集需要严格的时间同步机制,如果启用了防火墙需要开放相应的端口。2 B5 T1 \5 M$ K, J- u7 @1 X3 s
$ x' _$ E; n. h5 N7 Y; p
--------------------------------------------------: U6 t. ? d w; T$ B9 i
# f: h6 s. O1 r
PCS(Pacemaker/Corosync configuration system)命令配置群集示例:
( F7 r2 F' ]# V7 I; y* s" f' J! ~1 o- A5 j9 }
# @# Z3 C* e" {
一、建立群集:/ ], U# P" ]& T5 u8 h# L
5 ~ j9 w7 h! {6 W1、配置群集节点的认证as the hacluster user:) K( p9 F% b, t) { |; r4 w
[shell]# pcs cluster auth node11 node12
% o" ?, n9 h' E' ~3 O0 |& m# A! m+ C+ w) d" G2 f3 k5 w
2、创建一个二个节点的群集' ]2 ~$ y9 i, @; R% c
[shell]# pcs cluster setup --name mycluster node11 node126 K1 d" e5 D3 ~- c2 e& G
[shell]# pcs cluster start --all ## 启动群集4 G% D& C" d( s; ]
* L7 A, `. q ^& ?
3、设置资源默认粘性(防止资源回切)& v, {( T8 z( p" H8 Z; x: o
[shell]# pcs resource defaults resource-stickiness=100 Y9 a8 J' @3 i0 Y; I1 w0 L$ c2 m
[shell]# pcs resource defaults
+ Z6 y' E$ r. V, u/ O/ Q5 p8 f! b& |9 W, e Y4 Z( K3 C J
4、设置资源超时时间
6 n+ n% \6 }# c, e2 H1 B7 P2 J! A [shell]# pcs resource op defaults timeout=90s/ Z9 D$ P8 y2 ~& N$ K
[shell]# pcs resource op defaults. H. c; ?9 N# c/ Q* z% j
h1 L1 U: G* T' e) h( T
5、二个节点时,忽略节点quorum功能1 o2 d# q, W7 w& b6 v- C9 \! y: A
[shell]# pcs property set no-quorum-policy=ignore
6 ]6 ]9 t+ A# A( g3 C+ g" J7 B! k2 Q, g- X* d; }( t$ T5 Z C
6、没有 Fencing设备时,禁用STONITH 组件功能
* Q/ x$ R$ C( ?1 v2 V' B8 \6 H在 stonith-enabled="false" 的情况下,分布式锁管理器 (DLM) 等资源以及依赖DLM 的所有服务(例如 cLVM2、GFS2 和 OCFS2)都将无法启动。3 i# U/ Q% H2 q
[shell]# pcs property set stonith-enabled=false
# ^1 y" y! H/ P" Y% ~( | [shell]# crm_verify -L -V ## 验证群集配置信息6 p6 s2 ?# s' n
: e$ H% n: R; f+ W3 ?# T4 d9 E( [( `/ n+ i8 _( j K# r
" |( O$ m# W J& m! Q3 j. m
二、建立群集资源% }+ ]% e0 }5 a- Q1 b
) o% h1 B2 k3 M% V9 l4 s0 P9 [
1、查看可用资源
6 |% C5 H, Z" t. T [shell]# pcs resource list ## 查看支持资源列表,pcs resource list ocf:heartbeat5 s+ [6 J4 h& e% @; S& O
[shell]# pcs resource describe agent_name ## 查看资源使用参数,pcs resource describe ocf:heartbeat:IPaddr2
( n; ~3 ?6 A2 L! W
0 }) t( t+ W4 |8 P7 V2、配置虚拟IP
; _) V+ W) p4 P0 Y* [$ w4 x [shell]# pcs resource create ClusterIP ocf:heartbeat:IPaddr2 \
& _/ w5 C7 K1 p: ^ ip="192.168.10.15" cidr_netmask=32 nic=eth0 op monitor interval=30s
; K- G' c% k B7 P/ D6 ?
+ {/ |5 s" B9 s3、配置Apache(httpd)
% h; M! r# S/ Q7 I! y% a$ P1 C [shell]# pcs resource create WebServer ocf:heartbeat:apache \" A! f8 j1 @- V7 d
httpd="/usr/sbin/httpd" configfile="/etc/httpd/conf/httpd.conf" \8 j# F# s, ^& z- K# S) L$ \
statusurl="http://localhost/server-status" op monitor interval=1min
+ u p5 ~# u, _8 O1 i. v% k* ?
8 e4 v/ q" H1 X# T4、配置Nginx L0 o d' Z8 ], [) G, A! K& W& ^% \
[shell]# pcs resource create WebServer ocf:heartbeat:nginx \0 L1 n! p3 F; _
httpd="/usr/sbin/nginx" configfile="/etc/nginx/nginx.conf" \
! {2 Y) b# E i7 i6 c statusurl="http://localhost/ngx_status" op monitor interval=30s
R& y+ v Q9 i o+ V0 v6 _5 C* ]# w: l3 B8 l
5.1、配置FileSystem
$ s0 |( E: ?* c# _! I [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
1 e3 ~* D: k$ o& m* E/ a9 c device="/dev/sdb1" directory="/var/www/html" fstype="ext4"- H, L8 p$ C/ o
' w7 F# B1 N2 t v
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \ w- R! M& J3 c+ z( l
device="-U 32937d65eb" directory="/var/www/html" fstype="ext4"
8 M0 w; ~8 ~, T6 Q" F, B5 o$ f2 x9 b9 F2 Y% K, Z- a4 @% K7 k; X6 f1 e
5.2、配置FileSystem-NFS3 ~; L& B `5 t3 Q {
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \& G$ T$ F, F# I; u
device="192.168.10.18:/mysqldata" directory="/var/lib/mysql" fstype="nfs" \) L% n% B7 }2 V. j
options="-o username=your_name,password=your_password" \( r% t: F) i* E2 M+ R% s1 V! G
op start timeout=60s op stop timeout=60s op monitor interval=20s timeout=60s7 @- n) p$ _6 s' S
F$ ?( I. i, a" U4 u0 a: s. C6、配置Iscsi5 v9 _. G3 k0 y6 I1 W
[shell]# pcs resource create WebData ocf:heartbeat:iscsi \
, y' M0 D* o7 u9 o0 W! W portal="192.168.10.18" target="iqn.2008-08.com.starwindsoftware:" \
8 x3 g- t0 y2 E op monitor depth="0" timeout="30" interval="120"! C5 H5 ~) M- q! v- E
5 Q" c* K/ u4 A' H6 H [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \/ y7 k- p' v5 c, p
device="-U 32937d65eb" directory="/var/www/html" fstype="ext4" options="_netdev"
& _5 k" I4 F' Z/ Z3 J" _. L' M& E2 w! M) m* V
7、配置DRBD
+ ~3 n$ |( N0 B, i7 j, A0 ^0 W [shell]# pcs resource create WebData ocf:linbit:drbd \" U( k) W" x- [2 h
drbd_resource=wwwdata op monitor interval=60s0 b; \7 i" |% w+ p4 @) z
% f; m1 A0 `5 d; U6 H4 G, l/ s
[shell]# pcs resource master WebDataClone WebData \
" |- B+ k9 e3 }, j1 w/ N) U master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true
* U0 W4 ?5 [. g) g/ X! h V c/ L- r# f8 X
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \. d" e+ b; l, M: p: h8 K( ~9 j0 U
device="/dev/drbd1" directory="/var/www/html" fstype="ext4"
}# E% F" N2 `
+ b6 o9 l' E9 H2 p8、配置MySQL; G/ c9 g8 f3 ~1 n+ g
[shell]# pcs resource create MySQL ocf:heartbeat:mysql \
1 A( Y# b. M2 `' B1 M1 h binary="/usr/bin/mysqld_safe" config="/etc/my.cnf" datadir="/var/lib/mysql" \
u9 M/ U) D. K pid="/var/run/mysqld/mysql.pid" socket="/tmp/mysql.sock" \" X' x3 Q1 s7 \$ g- t
op start timeout=180s op stop timeout=180s op monitor interval=20s timeout=60s! I( M1 N: | o$ O$ T
( U$ x' A n! F0 T: Z
9、配置Pingd,检测节点与目标的连接有效性
* R+ ]) M( [9 t2 p+ i6 q% {' Y [shell]# pcs resource create PingCheck ocf:heartbeat:pingd \
4 ]! g: h3 f( E5 W) a dampen=5s multiplier=100 host_list="192.168.10.1 router" \
( X4 k+ h; D" r* ^( d& `7 l( u op monitor interval=30s timeout=10s
- q6 y; @, K4 c( v) B9 W7 z- b; `
10、创建资源clone,克隆的资源会在全部节点启动
# c. k* l& i- b0 u, g7 O [shell]# pcs resource clone PingCheck1 R+ J$ F. c9 l4 Z2 O+ j. a5 Y; ?
[shell]# pcs resource clone ClusterIP clone-max=2 clone-node-max=2 globally-unique=true ## clone-max=2,数据包分成2路7 {3 B. @2 c# W8 F& h
[shell]# pcs resource update ClusterIP clusterip_hash=sourceip ## 指定响应请求的分配策略为:sourceip
3 l* K3 T$ Y' z" \2 c: g0 t4 S y( C1 p# H& |. p
$ ~% _$ H+ K+ n) y1 D* C
, A5 x, H$ l4 t1 N/ ^. o
三、调整群集资源
+ Y5 O: X& G& d) a
6 }" X: N8 [$ x0 R! q2 z) k1、配置资源约束
- S8 \3 ~) y. n [shell]# pcs resource group add WebSrvs ClusterIP ## 配置资源组,组中资源会在同一节点运行( g# \9 U d9 P: Q, K4 Z f
[shell]# pcs resource group remove WebSrvs ClusterIP ## 移除组中的指定资源* b$ Y* c3 B" H) r
[shell]# pcs resource master WebDataClone WebData ## 配置具有多个状态的资源,如 DRBD master/slave状态
3 G8 [% N O% I/ E: N+ X [shell]# pcs constraint colocation add WebServer ClusterIP INFINITY ## 配置资源捆绑关系
" d4 A- j8 G+ P5 S! ? Z [shell]# pcs constraint colocation remove WebServer ## 移除资源捆绑关系约束中资源
: s. g0 B2 `1 A) n [shell]# pcs constraint order ClusterIP then WebServer ## 配置资源启动顺序; [+ b& v9 T4 w3 E8 V
[shell]# pcs constraint order remove ClusterIP ## 移除资源启动顺序约束中资源 y* G1 _) w+ N4 t8 n
[shell]# pcs constraint ## 查看资源约束关系, pcs constraint --full/ X z: ~! } i3 Y
+ U* k) g& ]/ l; [
2、配置资源位置6 ?4 t- D& \+ O5 g# R. C. j l$ l3 S
[shell]# pcs constraint location WebServer prefers node11 ## 指定资源默认某个节点,node=50 指定增加的 score
& i7 u* s. u% [ [shell]# pcs constraint location WebServer avoids node11 ## 指定资源避开某个节点,node=50 指定减少的 score; M Z5 |7 I- D3 p/ X
[shell]# pcs constraint location remove location-WebServer ## 移除资源节点位置约束中资源ID,可用pcs config获取
; a6 U9 g: Q- M7 X/ M [shell]# pcs constraint location WebServer prefers node11=INFINITY ## 手工移动资源节点,指定节点资源的 score of INFINITY
$ e: S0 g' W/ ^' F" f [shell]# crm_simulate -sL ## 验证节点资源 score 值/ z+ y! @# `" s/ y
% ], z* q; ]1 {3、修改资源配置
% ]7 u7 P, l+ U& D [shell]# pcs resource update WebFS ## 更新资源配置 T/ G% O3 q3 ]
[shell]# pcs resource delete WebFS ## 删除指定资源* U7 v3 q' L: ^3 a' [( ?
, _) m* t- |- _% k4、管理群集资源
3 z& j& f+ D9 o. _' B0 u X4 I [shell]# pcs resource disable ClusterIP ## 禁用资源
4 w* c3 d. L6 j# @% i/ K/ O [shell]# pcs resource enable ClusterIP ## 启用资源
; e3 @- r( P L3 K* d) M [shell]# pcs resource failcount show ClusterIP ## 显示指定资源的错误计数# t8 ?- x! y% t0 g6 B" z
[shell]# pcs resource failcount reset ClusterIP ## 清除指定资源的错误计数
1 U3 D2 ^% J+ @( s+ u6 B" f [shell]# pcs resource cleanup ClusterIP ## 清除指定资源的状态与错误计数
7 L; P8 i% `5 B* W7 F% p. G4 `/ [- g* u4 `
' Q0 C8 Q! T# t+ U
# a2 v9 u* f4 {3 m9 b" y* m3 C
3 O6 r1 o) l" q; T9 \. f四、配置Fencing设备,启用STONITH
! ], p/ `: D: d# D# p% Q4 T; a7 N) ^
1、查询Fence设备资源% u2 T+ U4 Y+ Y C5 n+ ~; `. k
[shell]# pcs stonith list ## 查看支持Fence列表
+ l" l" ]! e" c2 J [shell]# pcs stonith describe agent_name ## 查看Fence资源使用参数,pcs stonith describe fence_vmware_soap8 D. x* ]9 j. I+ |9 v* m5 B+ `
0 d0 W! W. c# A1 ]2、配置fence设备资源
5 v6 C8 D1 r: F" B [shell]# pcs stonith create ipmi-fencing fence_ipmilan \( n# k# B, F; S" ^# M# Y+ i3 S- a/ A
pcmk_host_list="pcmk-1 pcmk-2" ipaddr="10.0.0.1" login=testuser passwd=acd123 \
- s0 r! L( u2 Y5 e( T- i op monitor interval=60s
7 z. G$ z# h* h$ F$ @6 ?) H4 d& a1 b# p# v) D& W* n& e1 S
mark:/ G! Y3 E) F; M% f: i( J0 I1 ?" }! J
If the device does not support the standard port parameter or may provide additional ones, you may also need to set the special pcmk_host_argument parameter. See man stonithd for details.
, q" F+ m F$ }8 eIf the device does not know how to fence nodes based on their uname, you may also need to set the special pcmk_host_map parameter. See man stonithd for details.9 O3 ~; p8 e' y$ o6 Y0 f- v' k. a
If the device does not support the list command, you may also need to set the special pcmk_host_list and/or pcmk_host_check parameters. See man stonithd for details.) g8 o$ o, ^* M* B
If the device does not expect the victim to be specified with the port parameter, you may also need to set the special pcmk_host_argument parameter. See man stonithd for details.
# ^7 a1 Z0 u2 ~" t+ Y0 ?example: pcmk_host_argument="uuid" pcmk_host_map="node11:4;node12:5;node13:6" pcmk_host_list="node11,node12" pcmk_host_check="static-list"4 A) E9 `) W: {7 O
$ W1 W- Y( ~" W9 E* i+ d6 z
3、配置VMWARE (fence_vmware_soap)
# b: C( z) O! l0 G 特别说明:本次实例中使用了第3项(pcs stonith create vmware-fencing fence_vmware_soap)这个指定pcmk配置参数才能正常执行Fencing动作。, m& {4 B9 [1 z& ]! g% v
! I% g; S) H: S* J: e3.1、确认vmware虚拟机的状态:
1 H$ U* b8 O/ i# Q/ X# w [shell]# fence_vmware_soap -o list -a vcenter.example.com -l cluster-admin -p <password> -z ## 获取虚拟机UUID
: A. P. u; `, u a [shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -U <UUID> ## 查看状态* Y2 c, H$ G, R/ s2 _3 L/ Z2 i* C
[shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -n <vm name>1 h& A* I9 ]1 p( Q+ F7 A1 d
3 X8 D1 Y; H3 | v9 ]$ A/ `
3.2、配置fence_vmware_soap
. I* G( y. W6 z* t( k6 z8 _ J* c [shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \+ n* B( l S, ~1 |; Z; ^8 i
action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \5 d) a- K8 L, b$ z" l3 n
port="node11" shell_timeout=60s login_timeout=60s op monitor interval=90s
8 o9 z# ?; r. T% A+ p1 w# v; C
8 f4 b; \' K8 n7 _2 s2 k4 _ [shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \
: H0 D; h( U1 M action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \
; D* D# t) W2 u$ R4 @; M6 O. X+ W uuid="421dec5f-c484-3d69-ddfb-65af46530581" shell_timeout=60s login_timeout=60s op monitor interval=90s
) X; W0 Q) O# D0 s
$ Z/ ?! W* c) D/ e( ~ [shell]# pcs stonith create vmware-fencing fence_vmware_soap \4 c2 d m: Q/ W) v/ u
action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \( b: b- {" _3 m# C3 i" }4 n
pcmk_host_argument="uuid" pcmk_host_check="static-list" pcmk_host_list="node11,node12" \& T. |+ k2 t5 H+ ]
pcmk_host_map="node11:421dec5f-c484-3d69-ddfb-65af46530581;node12:421dec5f-c484-3d69-ddfb-65af46530582" \$ ~4 R1 V j; l7 h
shell_timeout=60s login_timeout=60s op monitor interval=90s1 { B w v$ ~! {* i) X% @4 m
2 k' l, S& _! X4 q, ?
注:如果配置fence_vmware_soap设备时用port=vm name在测试时不能识别,则使用uuid=vm uuid代替;3 S% u9 N3 E; _" w
建议使用 pcmk_host_argument、pcmk_host_map、pcmk_host_check、pcmk_host_list 参数指明节点与设备端口关系,格式:3 e! H* i, |4 @* \
pcmk_host_argument="uuid" pcmk_host_map="node11:uuid4;node12:uuid5;node13:uuid6" pcmk_host_list="node11,node12,node13" pcmk_host_check="static-list"+ k- y p2 E0 w; i' G# L+ _
2 d3 s% `: Q* Q3 R4、配置SCSI
6 D' v, Q7 B! m7 B# k [shell]# ls /dev/disk/by-id/wwn-* ## 获取Fencing磁盘UUID号,磁盘须未格式化
6 t# ? W7 _0 ~8 x$ M9 T' r [shell]# pcs stonith create iscsi-fencing fence_scsi \, c1 I$ n' t+ p( |
action="reboot" devices="/dev/disk/by-id/wwn-0x600e002" meta provides=unfencing+ b( Y$ x4 F3 B" _
, P, N2 [: b: x
5、配置DELL DRAC! y0 m/ L2 q& i% Z9 M! q
[shell]# pcs stonith create dell-fencing-node11 fence_drac" f' j5 A% G% N/ l2 Z! u* W+ F" B
.....# {; v* I0 J5 m1 p+ R) }% d' ]
! M0 O! L% c4 l' k6 t
! _7 |% V3 e0 q, k/ T
6、管理 STONITH$ [; F5 B, s, ]9 @ B3 g
[shell]# pcs resource clone vmware-fencing ## clone stonith资源,供多节点启动
+ |' p: P4 g& B. Z& t [shell]# pcs property set stonith-enabled=true ## 启用 stonith 组件功能$ Q" A+ j2 S' N! `; a( m
[shell]# pcs stonith cleanup vmware-fencing ## 清除Fence资源的状态与错误计数3 g0 \: j1 p9 z9 h. [
[shell]# pcs stonith fence node11 ## fencing指定节点8 m. i; Z2 O3 `- _; h
3 f6 {" t1 P6 D2 u2 f
* [9 ]1 N% x( m. ^2 V$ {% p% b( h
1 p: I. J' M& A( I5 |* r, s* v& r4 W. A7 K$ {% q! J9 t5 i8 O
五、群集操作命令* E3 D0 b: I9 ?! X: n
9 M$ n8 S1 w% R1、验证群集安装
" o! o) H1 Q& |3 e$ q# u/ x [shell]# pacemakerd -F ## 查看pacemaker组件,ps axf | grep pacemaker, x" b& p% |6 e T# g P
[shell]# corosync-cfgtool -s ## 查看corosync序号3 q- X6 H6 Z+ \2 e0 F
[shell]# corosync-cmapctl | grep members ## corosync 2.3.x
/ z( q; o; C% G0 Y4 N [shell]# corosync-objctl | grep members ## corosync 1.4.x D9 L' b& N6 @
, b1 i% V. o2 A
2、查看群集资源
: D: T4 H" f* O: S* k+ ^7 H [shell]# pcs resource standards ## 查看支持资源类型
$ i% I# }: ~& ]; q [shell]# pcs resource providers ## 查看资源提供商, o* i- c7 G% z7 _- [0 `
[shell]# pcs resource agents ## 查看所有资源代理
0 A& F+ d6 H% ~: S8 C, ^2 | [shell]# pcs resource list ## 查看支持资源列表& P' Q+ H! L0 T6 E# e% |
[shell]# pcs stonith list ## 查看支持Fence列表8 ?$ _# a3 Z7 T1 Y/ p. F
[shell]# pcs property list --all ## 显示群集默认变量参数
# h0 Y1 _! J: K ` [shell]# crm_simulate -sL ## 检验资源 score 值
+ _0 W. x( p4 r+ J: |+ j6 Q2 L! }2 o8 B& Z. t9 K6 s
3、使用群集脚本
8 y1 }/ Q A3 H8 @5 t5 H" j" B [shell]# pcs cluster cib ra_cfg ## 将群集资源配置信息保存在指定文件
4 g# p0 g) Q4 ]3 A* V- T [shell]# pcs -f ra_cfg resource create ## 创建群集资源并保存在指定文件中(而非保存在运行配置)2 c- F# N9 x2 U' T# I0 o
[shell]# pcs -f ra_cfg resource show ## 显示指定文件的配置信息,检查无误后: t7 u6 w9 P, R: x3 F" o/ i/ q
[shell]# pcs cluster cib-push ra_cfg ## 将指定配置文件加载到运行配置中; d( H* n4 Q7 n9 ~
! Q0 ~# K/ i r4、STONITH 设备操作
7 ]. I2 X' \% J0 z [shell]# stonith_admin -I ## 查询fence设备+ r: N" f6 y; o1 E4 f8 U
[shell]# stonith_admin -M -a agent_name ## 查询fence设备的元数据,stonith_admin -M -a fence_vmware_soap
( ?- ]$ A( K3 V- b3 w7 A# x6 g/ i [shell]# stonith_admin --reboot nodename ## 测试 STONITH 设备( v' o8 E1 P4 v, C+ I/ c
1 E9 ^* b! h- `4 q( m4 {* n
5、查看群集配置 J) j4 _3 J! k
[shell]# crm_verify -L -V ## 检查配置有无错误5 U3 X4 k! {& @* P0 N4 P4 v
[shell]# pcs property ## 查看群集属性! H3 ` }, E* c! u* |: _% M
[shell]# pcs stonith ## 查看stonith
4 a2 G: e% a- H6 D) J: } [shell]# pcs constraint ## 查看资源约束. P% T( d9 b2 ]) s+ Q( o
[shell]# pcs config ## 查看群集资源配置# q/ l5 y% t+ W: z
[shell]# pcs cluster cib ## 以XML格式显示群集配置7 a; W' ]/ w% F1 o9 y2 j& v
* d. ~* n: H9 }- t' c( T' d
6、管理群集
& Z7 H% }4 k! O: W) [ [shell]# pcs status ## 查看群集状态
1 x1 O. g) [- L- q4 \* f1 D d [shell]# pcs status cluster
* p, z5 l- `3 ]/ `. b [shell]# pcs status corosync
1 \" t* E) ^- F5 i [shell]# pcs cluster stop [node11] ## 停止群集7 C$ C3 v3 c, G2 \+ q, A7 ?, R
[shell]# pcs cluster start --all ## 启动群集
0 {" _+ p5 R$ H# J [shell]# pcs cluster standby node11 ## 将节点置为后备standby状态,pcs cluster unstandby node11
: s. \/ A- F5 T, r8 } [shell]# pcs cluster destroy [--all] ## 删除群集,[--all]同时恢复corosync.conf文件2 D( r2 \6 i- G2 @: p0 Z+ u$ o
[shell]# pcs resource cleanup ClusterIP ## 清除指定资源的状态与错误计数9 l. y. U/ L, l) \2 _
[shell]# pcs stonith cleanup vmware-fencing ## 清除Fence资源的状态与错误计数
: `+ o* m2 X5 ]5 E- q: e4 M
/ B& |6 [9 \! X
% g- G8 C; `! R, U8 p |
|