|
|
使用pcs shell配置corosync & pacemaker群集
+ p' J7 f; b2 ]3 F+ x- o6 T4 d
# F2 ~& [. g! U0 k A- S% E: ^9 V; l
Pacemaker
7 D1 ]0 j* Y( {) i- pPacemaker,即Cluster Resource Manager(CRM),管理整个HA,客户端通过pacemaker管理监控整个集群。
$ O/ R' O: N9 v0 i8 x
- w. l6 c0 X) y" C$ X8 U& [CRM支持ocf和lsb两种资源类型:
; S& B5 t1 e' j/ o
0 M# ^& I+ l0 |" `4 Vocf格式的启动脚本在/usr/lib/ocf/resource.d/下面。# ~; a; G1 C% M: e
lsb的脚本一般在/etc/rc.d/init.d/下面。% K. E* M7 [8 W4 I' A& J
3 r% |1 X# X: r. u4 D- M7 Z
" Z$ L$ @5 q `5 }# W; \. V. E& A8 y2 v. Z7 R( E0 {- m* d
1、常用的集群管理工具:
$ R1 M" j% o% S2 B: N(1)基于命令行# d- R2 P- y6 K+ _- @; ?
crm shell/pcs
$ R) Z j. Y, O. j, v7 F1 E9 ?
+ ~6 W* A' f' X( l(2)基于图形化: W9 P T' s. @: M% a9 ]
pygui/hawk/lcmc/pcs
7 V1 b. D3 e; F7 m
% w% w* {8 a4 }& E9 o/ K5 |/ E9 i- C1 i. L6 j% c, R
2、相关的资源文件:; |% `# f. J, L7 ?" V3 E, {$ J8 T
(1)/usr/lib/ocf/resource.d,pacemaker资源库文件位置,可安装资源包:resource-agents 获取更多ocf格式的资源。/ |% C) H2 `- I9 @0 L" A; ]7 J& |
(2)/usr/sbin/fence_***,Fencing设备的执行脚本名称,可安装资源包:fence-agents 获取更多Fencing设备资源。% {. W ^2 H9 \$ D
) [4 D# h3 e5 h
3、查看使用说明:3 b$ J4 ^. `- X5 [3 E0 W
[shell]# man ocf_heartbeat_*** ## 查看OCF资源说明,man ocf_heartbeat_apache) k1 O! \0 G* U3 f% R( U0 c
[shell]# man fence_*** ## 查看Fencing设备说明,man fence_vmware
: ^. n# \1 I9 S1 Z+ T1 j
2 Y+ p3 m, e) s, { U4、参考文档
3 n2 [# |( O6 Y% j2 y/ ahttps://github.com/ClusterLabs! d) a4 A# L* c' ^8 y$ [$ N* y
http://clusterlabs.org/doc/8 Z u# Y, B! C) |
http://www.linux-ha.org/doc/man-pages/man-pages.html4 n* L& n$ u8 F8 D
https://access.redhat.com/docume ... acemaker/index.html' |* N0 x6 H& X5 S/ g
+ ~8 ^" C0 J( Z
在群集配置过程中参考了互联网上众多优秀文章,在此感谢原作者!!!) k8 D5 `: G( z% O4 V- Z
. C1 H& {6 M+ G+ D. Z
以下记录整理了在vmware esxi5.5 + centos6.6环境中使用PCS命令配置corosync & pacemaker群集的一些操作,由于本人水平有限,仅供参考:2 w( p4 Q7 h1 i& j
4 W/ R) X, o3 D6 p7 B6 d--------------------------------------------------
- o8 `; b( }# B( u* r$ y# K4 d
) h3 q1 D+ `3 C+ g1 c
4 n8 \/ w/ `$ I( Y! l. ^1.安装群集软件:/ q) p3 x, q0 B! D: p) Q) {, Q
[shell]# yum -y install corosync pacemaker pcs
2 A& [1 ~/ s2 B4 [' p- P, K [shell]# yum -y install fence-agents resource-agents
( T* \7 Q$ n9 B1 P7 [* E7 }- Z3 u$ O- V, n% _( m4 O4 i4 D @
2.拷贝配置文件、启动脚本
" n9 z; r" T4 P4 {. T [shell]# mkdir -p /etc/cluster/4 }, y: v4 W5 k \/ y
[shell]# ln -s /etc/rc.d/init.d/corosync /etc/rc.d/init.d/cman
- M2 d6 ]0 @3 m* A+ i7 H6 M [shell]# ln -s /usr/sbin/corosync-cmapctl /usr/sbin/corosync-objctl
% A5 f* S; V1 @+ L [shell]# cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf
" ^2 C& K$ e1 z/ }1 D Y+ ~( j# ~' z* I0 l, L. q a5 z
; E+ J+ f6 l0 q% x7 C! d注意:群集需要严格的时间同步机制,如果启用了防火墙需要开放相应的端口。
& P$ d! N' H2 q$ s) G
0 S2 l' h* [. R0 u0 a. n--------------------------------------------------) [- g5 I Z1 i/ d2 N0 ?2 A9 I$ X
: v( { P' s; m- d6 o! qPCS(Pacemaker/Corosync configuration system)命令配置群集示例:1 b; m, [1 J( W( w
) e+ H# o9 m- S9 c# {' q9 C" |) k' w5 J0 K) ^ q4 C
一、建立群集:' @ b$ t7 D1 ?. `: U3 p R% ~6 |
( U6 ` x$ S+ h# `5 k* I7 i6 q1、配置群集节点的认证as the hacluster user:& s2 H8 z! E) |8 a$ y3 I- k) L
[shell]# pcs cluster auth node11 node12, i) F! r9 B% Y. J+ V( W; t
% S' i, ?! I1 c L2、创建一个二个节点的群集- x) z1 i+ o- \0 n0 Y2 V' b, B
[shell]# pcs cluster setup --name mycluster node11 node12
# d7 I; R. l2 f [shell]# pcs cluster start --all ## 启动群集
3 q i: W3 i# G' W' _' n
3 R- N7 a5 X W/ m1 f3、设置资源默认粘性(防止资源回切)
5 b4 ]0 \& {$ u7 c9 ~$ G8 \) ~ [shell]# pcs resource defaults resource-stickiness=100) U1 L1 C- x- O" d6 [$ G, X
[shell]# pcs resource defaults
$ k$ @4 l/ E/ d; x# S5 b% i3 F( r* G
4、设置资源超时时间* Y, o& V7 E) U9 e9 c j! c+ f( R
[shell]# pcs resource op defaults timeout=90s
, a5 M+ m- \, r0 A [shell]# pcs resource op defaults a$ P8 Y6 Z0 V* j6 Z" n/ N
7 s3 M, N! g0 Y1 f8 n
5、二个节点时,忽略节点quorum功能
7 {6 ~) }: j6 \- k [shell]# pcs property set no-quorum-policy=ignore
# ^. g: ]1 S, f1 t: }- Y9 L; X) v* U7 R# |
6、没有 Fencing设备时,禁用STONITH 组件功能1 |3 u' c1 c* q8 l
在 stonith-enabled="false" 的情况下,分布式锁管理器 (DLM) 等资源以及依赖DLM 的所有服务(例如 cLVM2、GFS2 和 OCFS2)都将无法启动。
! b, ^7 t* B0 K5 E: D% A [shell]# pcs property set stonith-enabled=false
% ~3 \ M$ W0 U [shell]# crm_verify -L -V ## 验证群集配置信息
, j f7 r5 B; J2 }
3 j' h2 Z0 [' z0 F7 g
7 v% P+ v, ]" _3 W5 c8 R! b0 R$ E9 S2 I1 J& Z2 R$ ^2 i+ }! D
二、建立群集资源, w" E3 n2 w5 g) [# ]. m5 y
- y# p4 u. Y5 c, p/ T" ^' U; Z( M: I1、查看可用资源3 S# J b- L: n( U7 u8 J- e
[shell]# pcs resource list ## 查看支持资源列表,pcs resource list ocf:heartbeat' |, c z( a4 G# L6 @5 ~
[shell]# pcs resource describe agent_name ## 查看资源使用参数,pcs resource describe ocf:heartbeat:IPaddr2
- k. d6 u6 H& A* P5 \' `1 m9 w( j* h5 M
2、配置虚拟IP8 J1 U+ \; H% {/ X# B. Q
[shell]# pcs resource create ClusterIP ocf:heartbeat:IPaddr2 \
; G2 @7 f8 O$ H8 S! S% F ip="192.168.10.15" cidr_netmask=32 nic=eth0 op monitor interval=30s
- x- w6 D. a6 }! C/ b. r7 y \
$ g# t& @" A6 l! t' X5 k3、配置Apache(httpd)/ ?2 Y, Z! g: ?8 b( j8 b0 [# g
[shell]# pcs resource create WebServer ocf:heartbeat:apache \, e' I, F' y& d/ I5 F9 u- @- O
httpd="/usr/sbin/httpd" configfile="/etc/httpd/conf/httpd.conf" \
1 e$ P# T7 g6 ~( G statusurl="http://localhost/server-status" op monitor interval=1min( H3 `$ a+ t$ A
* T2 Y' m- P0 \4、配置Nginx" d% P+ A3 G* g7 x* U: |7 u
[shell]# pcs resource create WebServer ocf:heartbeat:nginx \
, C- S! w' Z$ o( t( X httpd="/usr/sbin/nginx" configfile="/etc/nginx/nginx.conf" \
) W- H" T+ v' E% N: B3 V statusurl="http://localhost/ngx_status" op monitor interval=30s* U+ e+ P8 ^ O7 x4 y( }
+ ? T. b" S& a
5.1、配置FileSystem
# i4 a: W3 ]$ N/ p' _) c: { [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \5 h; O& L% p4 _5 ^3 O/ r
device="/dev/sdb1" directory="/var/www/html" fstype="ext4"
- D! {& l1 T4 a
0 U' w% q( r8 u [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \- c' [0 ]3 d/ |/ g6 i9 \
device="-U 32937d65eb" directory="/var/www/html" fstype="ext4"' u% B2 ^5 u( ~6 ~, r. S
3 T7 H# a' I0 `. C L
5.2、配置FileSystem-NFS3 B2 B6 ?- Z( [! g2 K
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \& \, j7 B$ u, E: f
device="192.168.10.18:/mysqldata" directory="/var/lib/mysql" fstype="nfs" \
/ R j! c O! g$ B options="-o username=your_name,password=your_password" \$ N2 d# ?5 [. c
op start timeout=60s op stop timeout=60s op monitor interval=20s timeout=60s
. \+ c* ]8 i: T. w' E7 C3 @4 g( \, z' Q. e- }# i8 x8 o
6、配置Iscsi# G4 L4 S$ y/ \" n& A; d
[shell]# pcs resource create WebData ocf:heartbeat:iscsi \
! y* ^5 V# T# ^" R& ?+ l; n1 p" F portal="192.168.10.18" target="iqn.2008-08.com.starwindsoftware:" \7 T( F7 q7 O7 a4 ^' m
op monitor depth="0" timeout="30" interval="120"
$ l! b6 m+ c3 K) |) Z$ ~/ ^
& c, h3 b1 \* P; Z/ g& \# i* [ [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
W1 n8 C" ]1 n2 @( a4 {% b device="-U 32937d65eb" directory="/var/www/html" fstype="ext4" options="_netdev"8 f: |% M- z* d# j6 g6 X& m1 R
* {7 l0 Y" s- p( {8 \& {
7、配置DRBD
& v2 J! n7 L& O5 T( m" V: e4 o0 q [shell]# pcs resource create WebData ocf:linbit:drbd \4 H: I& R* x' k- ~4 Y
drbd_resource=wwwdata op monitor interval=60s) j; k& w5 ?! ]" J/ T* @; I
: \+ {5 F* j# e0 ]: ]
[shell]# pcs resource master WebDataClone WebData \) [* c, s5 p# G
master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true
* t1 t3 K: ], M7 T( q: |( a$ w6 R( z. U7 v5 G( ~. u7 ]5 t
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
% }; Q, E" B% C5 |( w# O. ~ device="/dev/drbd1" directory="/var/www/html" fstype="ext4"
9 b+ D, l/ S( G% w/ r% F& S: I- ]) L4 |2 f# d8 a
8、配置MySQL
$ W- O: z! Z3 Z6 E: @ [shell]# pcs resource create MySQL ocf:heartbeat:mysql \* C: W- L5 K% I, q. P. m
binary="/usr/bin/mysqld_safe" config="/etc/my.cnf" datadir="/var/lib/mysql" \+ y5 j1 j5 t; ?/ z) c
pid="/var/run/mysqld/mysql.pid" socket="/tmp/mysql.sock" \' h9 Y- A: n3 G, Z' }; L' b$ R
op start timeout=180s op stop timeout=180s op monitor interval=20s timeout=60s5 |+ n0 L( Y1 W( K, L3 e
9 D# E! B T2 l* S' p2 c
9、配置Pingd,检测节点与目标的连接有效性' S* f# C+ V( D6 b
[shell]# pcs resource create PingCheck ocf:heartbeat:pingd \
' D- l. J e: o3 K# k# Q7 H dampen=5s multiplier=100 host_list="192.168.10.1 router" \
5 t: l- ^& E8 b! r5 t w op monitor interval=30s timeout=10s5 @& ^( w5 P5 }; t! ]! Y, B L. r6 {
% Q2 _4 w* Y* f. P
10、创建资源clone,克隆的资源会在全部节点启动
: ^6 C1 T* _3 l: R" o* F [shell]# pcs resource clone PingCheck4 F1 c3 v& n' b+ N! T9 j. T
[shell]# pcs resource clone ClusterIP clone-max=2 clone-node-max=2 globally-unique=true ## clone-max=2,数据包分成2路. j: L, a9 q2 _2 u8 {% y1 {( R% H
[shell]# pcs resource update ClusterIP clusterip_hash=sourceip ## 指定响应请求的分配策略为:sourceip
8 ]7 M- o8 C& Y! N
) [. a, u$ L5 c4 ~8 Y4 P' |7 w% [7 X4 _
% c' {* [- r3 `6 [
三、调整群集资源
5 o! @" K3 Z S' H6 d; d4 U! }$ ~' N B d% F
1、配置资源约束6 L) |4 g y; I2 I+ m/ H
[shell]# pcs resource group add WebSrvs ClusterIP ## 配置资源组,组中资源会在同一节点运行7 k* F. o; T2 ]
[shell]# pcs resource group remove WebSrvs ClusterIP ## 移除组中的指定资源
0 q7 s3 c* {* Q# V# C [shell]# pcs resource master WebDataClone WebData ## 配置具有多个状态的资源,如 DRBD master/slave状态, F& y+ E8 Z: \# R* G1 ]8 W9 y$ n4 G! F
[shell]# pcs constraint colocation add WebServer ClusterIP INFINITY ## 配置资源捆绑关系1 q0 x' X' U& l0 F. ]3 c
[shell]# pcs constraint colocation remove WebServer ## 移除资源捆绑关系约束中资源
" \+ C' n4 d, `3 l$ F/ L [shell]# pcs constraint order ClusterIP then WebServer ## 配置资源启动顺序
. r/ Y% _* Q* m! Z0 L [shell]# pcs constraint order remove ClusterIP ## 移除资源启动顺序约束中资源9 }, N! P6 R3 s& L
[shell]# pcs constraint ## 查看资源约束关系, pcs constraint --full
" U: L0 M6 @, x" n
# M8 ~ p" d) V9 M3 h2、配置资源位置
% n5 ?+ T0 ~0 s [shell]# pcs constraint location WebServer prefers node11 ## 指定资源默认某个节点,node=50 指定增加的 score
7 R/ g0 Q x( q3 j [shell]# pcs constraint location WebServer avoids node11 ## 指定资源避开某个节点,node=50 指定减少的 score
5 w& ^& H) m9 g4 R [shell]# pcs constraint location remove location-WebServer ## 移除资源节点位置约束中资源ID,可用pcs config获取
! k$ a: `! J! h2 p [shell]# pcs constraint location WebServer prefers node11=INFINITY ## 手工移动资源节点,指定节点资源的 score of INFINITY
- E( a# `8 T" { h5 Y O' V1 g [shell]# crm_simulate -sL ## 验证节点资源 score 值
- G) n* }0 g, G+ Q S9 C* g9 X5 G( f( P$ W! u
3、修改资源配置
7 S9 U1 D: i* F( }4 K [shell]# pcs resource update WebFS ## 更新资源配置
" w8 o. M/ d4 y8 Z2 m: q [shell]# pcs resource delete WebFS ## 删除指定资源
7 |& c1 i! Y Z" e) a9 b5 t2 N7 ?; X2 m3 h `5 j3 d
4、管理群集资源
3 @4 |0 L ]* Q [shell]# pcs resource disable ClusterIP ## 禁用资源: A! p+ R" m! W5 j$ m3 @
[shell]# pcs resource enable ClusterIP ## 启用资源3 y4 y" L$ Z: `
[shell]# pcs resource failcount show ClusterIP ## 显示指定资源的错误计数0 W9 j# q5 u: t6 w- M8 C
[shell]# pcs resource failcount reset ClusterIP ## 清除指定资源的错误计数
1 A( B+ j/ M0 y i( @* @9 ^& w [shell]# pcs resource cleanup ClusterIP ## 清除指定资源的状态与错误计数) |* x9 e2 o/ {& P$ z1 r6 x6 m! I; F
3 F2 L1 |4 a) A5 X1 j/ j' M. ^/ f1 [
: W* X; L, u6 _2 Q& y1 d: Y$ i8 W# S% f8 M: B) S2 q* X: l: ?- c; Q
- T& h* \4 |3 G. i: H
四、配置Fencing设备,启用STONITH" |/ ~$ y$ p8 v
2 ^! C" q- B4 R0 r. o/ { e7 T _
1、查询Fence设备资源, J0 ^; Z3 t* }
[shell]# pcs stonith list ## 查看支持Fence列表* D% U9 X4 l; a" }9 G" D# H
[shell]# pcs stonith describe agent_name ## 查看Fence资源使用参数,pcs stonith describe fence_vmware_soap7 y; V1 d, I( a8 G/ h9 H
4 j2 |0 ?2 E6 c8 W! r3 R
2、配置fence设备资源
% f+ D+ F, w( F" n [shell]# pcs stonith create ipmi-fencing fence_ipmilan \
7 s$ p5 Q: o: u/ U3 {& d pcmk_host_list="pcmk-1 pcmk-2" ipaddr="10.0.0.1" login=testuser passwd=acd123 \% y$ g r+ Z ]& Q$ l5 G
op monitor interval=60s1 z1 y9 j( ?9 w( P- p
; J q. c7 d( A5 Omark:5 f: \, {0 O# o7 \/ ]
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.
9 f+ ^5 f) G$ M4 a! f" L }If 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.
+ z- b) E- L/ V+ P6 G% |. |+ @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.# C- u# m; O- s- N
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.
2 M% P) C' L/ ?$ nexample: pcmk_host_argument="uuid" pcmk_host_map="node11:4;node12:5;node13:6" pcmk_host_list="node11,node12" pcmk_host_check="static-list"
1 z6 t- f! c, Y( \/ Y$ { |& q6 p4 S5 ^. c3 I
3、配置VMWARE (fence_vmware_soap)9 @0 C5 S r8 H) G" S6 w) U
特别说明:本次实例中使用了第3项(pcs stonith create vmware-fencing fence_vmware_soap)这个指定pcmk配置参数才能正常执行Fencing动作。
9 y9 I0 x4 L2 Z: P( Y( Z$ Q
& _6 a0 I, ?" p% g" l3.1、确认vmware虚拟机的状态:, a/ H# k5 h" f; {
[shell]# fence_vmware_soap -o list -a vcenter.example.com -l cluster-admin -p <password> -z ## 获取虚拟机UUID
- G4 C+ ?0 n' B" U) g [shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -U <UUID> ## 查看状态
2 C7 p* ^0 j& L1 F, H8 ~' @ [shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -n <vm name>: Z; U: i& Z+ R! [( K3 x/ s* @
9 _" ?6 F! W: b3.2、配置fence_vmware_soap
' {' l5 f6 C, m* o- W. x [shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \5 l K8 r4 ^& x5 c5 R5 b8 b! I
action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \' b$ R2 i4 z Z( I7 }) b0 d
port="node11" shell_timeout=60s login_timeout=60s op monitor interval=90s
7 {' R! X, m2 w' P% B2 w: D$ R7 E0 I1 M3 U* l( x8 T2 N
[shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \4 I& {3 h4 U! ?, ?" {6 M/ Q
action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \2 Y7 b- W: W2 G
uuid="421dec5f-c484-3d69-ddfb-65af46530581" shell_timeout=60s login_timeout=60s op monitor interval=90s' k8 x( ]& W% F
' X, y* J; i& E' D4 W- n
[shell]# pcs stonith create vmware-fencing fence_vmware_soap \
2 P& @8 Y* u! y3 n3 m S action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \
1 b8 N1 y) K0 E3 E pcmk_host_argument="uuid" pcmk_host_check="static-list" pcmk_host_list="node11,node12" \
; k# q6 }1 ~. ~% r& g pcmk_host_map="node11:421dec5f-c484-3d69-ddfb-65af46530581;node12:421dec5f-c484-3d69-ddfb-65af46530582" \
! N7 E. S" M j9 M% S shell_timeout=60s login_timeout=60s op monitor interval=90s
4 E! D+ ]7 D3 @! a3 W, i6 M D6 \8 n" ]6 |9 g$ M Z5 c: ^. p
注:如果配置fence_vmware_soap设备时用port=vm name在测试时不能识别,则使用uuid=vm uuid代替;
9 \# p) K, _ f! B. t l, X建议使用 pcmk_host_argument、pcmk_host_map、pcmk_host_check、pcmk_host_list 参数指明节点与设备端口关系,格式:- u6 ]) }: M# i$ q+ A/ G
pcmk_host_argument="uuid" pcmk_host_map="node11:uuid4;node12:uuid5;node13:uuid6" pcmk_host_list="node11,node12,node13" pcmk_host_check="static-list"
( A0 u' A; H+ }0 t
' w; |* n0 r. w4、配置SCSI
1 u0 O: }6 i4 }1 G4 q$ Q [shell]# ls /dev/disk/by-id/wwn-* ## 获取Fencing磁盘UUID号,磁盘须未格式化( W+ J3 D2 G% a+ j W& W% G
[shell]# pcs stonith create iscsi-fencing fence_scsi \
4 ?1 _4 [5 P" r! `+ y action="reboot" devices="/dev/disk/by-id/wwn-0x600e002" meta provides=unfencing
0 r- _" L! J6 G* N9 R
! n, |5 i2 [+ M B1 F0 `5、配置DELL DRAC: P* Q4 Y! r9 H1 K
[shell]# pcs stonith create dell-fencing-node11 fence_drac
+ Z' o$ Q% X8 `$ t* S.....+ U5 b4 ?1 I* D+ X
8 j3 [% P$ l1 j8 {1 v2 @) T" I5 J9 L6 }0 Z6 a
6、管理 STONITH: g$ v6 b/ b! T
[shell]# pcs resource clone vmware-fencing ## clone stonith资源,供多节点启动
5 `/ K, J9 |) n6 x8 b [shell]# pcs property set stonith-enabled=true ## 启用 stonith 组件功能9 R( B, f1 z. [' z
[shell]# pcs stonith cleanup vmware-fencing ## 清除Fence资源的状态与错误计数
* s k' D" h( O7 M3 j, z6 L) ` [shell]# pcs stonith fence node11 ## fencing指定节点 F0 W- _+ D6 U2 }; U2 l
5 ?. e' T' J( w0 P8 l
' r% E, i r9 d. Y: x( a2 E
3 E5 r/ _# J, y; d2 S" ` X1 x2 l, O8 C/ T
五、群集操作命令
7 p' R! T: D2 [ _7 O* A! E+ \. \& V Z1 F. g) F; L" d
1、验证群集安装
. `8 ]3 T9 f# T' _: E1 J, i' V [shell]# pacemakerd -F ## 查看pacemaker组件,ps axf | grep pacemaker
4 `4 y# _5 z3 a/ N [shell]# corosync-cfgtool -s ## 查看corosync序号# U6 y- t, a7 d4 c+ J6 n' p& @ R
[shell]# corosync-cmapctl | grep members ## corosync 2.3.x
& r9 J5 ?9 p$ b# q [shell]# corosync-objctl | grep members ## corosync 1.4.x1 `6 _+ T: C+ a$ ?2 J8 j( w; V
8 M% g! a5 z: ]2 F
2、查看群集资源
) k8 o4 b9 M; F, b [shell]# pcs resource standards ## 查看支持资源类型9 Y% n; P6 d# { Z
[shell]# pcs resource providers ## 查看资源提供商
$ q7 u: O6 j- ^7 I! ? V8 r [shell]# pcs resource agents ## 查看所有资源代理
8 N8 c8 J# _* |+ d! B) w W [shell]# pcs resource list ## 查看支持资源列表8 A& n0 c0 E5 G% T2 g2 p
[shell]# pcs stonith list ## 查看支持Fence列表4 f7 ], s2 X. A8 Z9 E
[shell]# pcs property list --all ## 显示群集默认变量参数* r Y* l5 j3 v0 ~0 \4 z( S7 w& D
[shell]# crm_simulate -sL ## 检验资源 score 值! I% S! e4 k* x; k. S5 s
' W9 W d! w8 _/ `* O6 a3、使用群集脚本( L+ {$ L1 @* R0 X: [) _; g! s
[shell]# pcs cluster cib ra_cfg ## 将群集资源配置信息保存在指定文件, ^8 p! n8 l7 Z4 n# M6 t- M& c
[shell]# pcs -f ra_cfg resource create ## 创建群集资源并保存在指定文件中(而非保存在运行配置)) C& W% L' g) F+ S5 |- J
[shell]# pcs -f ra_cfg resource show ## 显示指定文件的配置信息,检查无误后+ C! j: W. {+ @" D
[shell]# pcs cluster cib-push ra_cfg ## 将指定配置文件加载到运行配置中% h* [6 S: W$ {: K/ q& j
; y; j7 S4 b! {* Z. j
4、STONITH 设备操作
. q! G) M: O3 [6 E [shell]# stonith_admin -I ## 查询fence设备7 Q% K$ m( g3 B1 j2 s8 a
[shell]# stonith_admin -M -a agent_name ## 查询fence设备的元数据,stonith_admin -M -a fence_vmware_soap6 u6 M u5 E) G0 b+ ~
[shell]# stonith_admin --reboot nodename ## 测试 STONITH 设备
. J4 J; J' y- D) q
- V2 z9 X; d! ~2 r, I1 D& O5、查看群集配置) R- n( W" E0 d6 r7 g6 T+ [ a; d+ n
[shell]# crm_verify -L -V ## 检查配置有无错误
' P0 \) v5 p, |+ ]( F9 J3 @ [shell]# pcs property ## 查看群集属性
/ u$ N, C' c8 G: k1 X2 ] g* X [shell]# pcs stonith ## 查看stonith" V" d% S- x: l4 r A
[shell]# pcs constraint ## 查看资源约束
( w; g( l0 G# X3 n [shell]# pcs config ## 查看群集资源配置
8 r# r& z5 U0 H1 f- j6 X e [shell]# pcs cluster cib ## 以XML格式显示群集配置
/ n+ O, G* w5 N2 y) T4 K7 l
6 G3 P( U" C+ d) p/ Y8 p( ~6、管理群集! v" ~5 ~% T$ F: Z6 O; T% Z; \1 ?' O) ?
[shell]# pcs status ## 查看群集状态6 h3 W: }: A {- K
[shell]# pcs status cluster
1 p- z6 ~8 O/ ]! I$ s3 T4 W* u [shell]# pcs status corosync
) E0 Z4 @3 k0 I. t" G4 z( B [shell]# pcs cluster stop [node11] ## 停止群集, r. k9 d+ `* _4 J3 |& O
[shell]# pcs cluster start --all ## 启动群集
& j' R+ x+ U6 N: g4 @1 W [shell]# pcs cluster standby node11 ## 将节点置为后备standby状态,pcs cluster unstandby node11
. q) p( z' ]5 b0 Y) J2 T o/ e [shell]# pcs cluster destroy [--all] ## 删除群集,[--all]同时恢复corosync.conf文件' _6 c5 {! b. s# O
[shell]# pcs resource cleanup ClusterIP ## 清除指定资源的状态与错误计数
# m* }+ \, G) i* M9 H1 m [shell]# pcs stonith cleanup vmware-fencing ## 清除Fence资源的状态与错误计数
; P1 Q' D( \8 |7 i5 z! O- }% m9 U3 v5 D0 Y" |
3 T6 `! w% l/ [1 G; {: v: k
|
|