- 积分
- 16843
在线时间 小时
最后登录1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?开始注册
x
使用pcs shell配置corosync & pacemaker群集. s& ^5 r2 X7 l4 r2 h: i/ E$ }
b0 G' P: p) _1 X' W/ q2 B ]" o: Y4 i
& ^: S6 H8 O, T
Pacemaker8 S# w( t8 v9 ]$ o# ^
Pacemaker,即Cluster Resource Manager(CRM),管理整个HA,客户端通过pacemaker管理监控整个集群。+ k+ ^6 [" a. o6 e9 k
% {& P+ i8 W* s9 C3 Z" U. qCRM支持ocf和lsb两种资源类型:7 y' }: w. q5 e0 H' I; v( [/ S
& M9 ^" A) n% a4 Gocf格式的启动脚本在/usr/lib/ocf/resource.d/下面。- K3 K, _ @" T( m& w6 R
lsb的脚本一般在/etc/rc.d/init.d/下面。8 ^) ?" l- i6 ?8 J$ I& g
( S6 t, f! l3 p% s% a3 d
7 f9 v! S9 z6 e( e: C# C' \: B: x* t6 I C
1、常用的集群管理工具:
3 ]. t, ? R: J4 g) {(1)基于命令行" W) T0 {5 k% A. r5 {7 w
crm shell/pcs/ U0 w C+ s7 R! V6 I, \& N
# [0 A+ O* K; [6 u9 t(2)基于图形化2 l: C) _( v' E H. R
pygui/hawk/lcmc/pcs
0 f Q) v- c/ d4 E5 X- Q9 ^& p& r1 A# K7 P: T+ `
+ Q0 b$ B% v" d" I2 p) ~
2、相关的资源文件:# {5 M& R$ P7 F& e7 X: d
(1)/usr/lib/ocf/resource.d,pacemaker资源库文件位置,可安装资源包:resource-agents 获取更多ocf格式的资源。1 ^' l7 J' h$ U% W( `' v% }
(2)/usr/sbin/fence_***,Fencing设备的执行脚本名称,可安装资源包:fence-agents 获取更多Fencing设备资源。6 \( b$ v! _: D2 u
' C+ \, w' v/ g
3、查看使用说明:
9 f* x4 c, p: h4 U3 v [shell]# man ocf_heartbeat_*** ## 查看OCF资源说明,man ocf_heartbeat_apache
# d; T) x9 Z% [- ]& G$ b [shell]# man fence_*** ## 查看Fencing设备说明,man fence_vmware: ]* j+ _) r0 m. N
2 i8 k+ p) [! e, U; E4、参考文档5 o! c" {$ z# G6 B
https://github.com/ClusterLabs6 l3 X( Q" |( p" o. c
http://clusterlabs.org/doc/
! \2 W! S+ W4 t- l0 {8 Lhttp://www.linux-ha.org/doc/man-pages/man-pages.html
: `% k* e6 I3 n9 Qhttps://access.redhat.com/docume ... acemaker/index.html
* S$ Z( q+ G: X# @/ |7 J! a: H% V# \% X* G, Q/ e5 _( r/ i. [3 u$ g
在群集配置过程中参考了互联网上众多优秀文章,在此感谢原作者!!!5 Z2 O. j: O9 p' J
2 u# q; D. P+ D- h以下记录整理了在vmware esxi5.5 + centos6.6环境中使用PCS命令配置corosync & pacemaker群集的一些操作,由于本人水平有限,仅供参考:
, m2 t1 i! D# E4 k
- J: f' o0 j& F8 b/ b--------------------------------------------------+ @/ }+ ]: b" W- ] a( V( k$ {% N
$ S+ p7 }/ l7 U9 r8 O* }8 s
M9 e: e7 r+ Q. T. e7 W- y4 b
1.安装群集软件:, E/ h3 D7 Y: Y2 [2 q' o: [
[shell]# yum -y install corosync pacemaker pcs3 L% l! O% `4 ?$ X
[shell]# yum -y install fence-agents resource-agents& u2 {! i3 h$ I- I: M! l
$ T. H8 r# O* q9 V* @2.拷贝配置文件、启动脚本0 ]" p+ ?1 a Y$ o6 {+ Q! U$ O
[shell]# mkdir -p /etc/cluster/7 x2 Q' i) y0 J% A
[shell]# ln -s /etc/rc.d/init.d/corosync /etc/rc.d/init.d/cman. {; _ v& J7 {
[shell]# ln -s /usr/sbin/corosync-cmapctl /usr/sbin/corosync-objctl
; z3 G' R4 i' \# H [shell]# cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf3 r$ v% E$ m0 y ^7 z) D- a
5 ~1 H8 G+ H2 [0 t# J
& Z8 h" L! n9 I0 t: C! v
注意:群集需要严格的时间同步机制,如果启用了防火墙需要开放相应的端口。1 a C1 A1 r7 V: Z8 m x8 @
& X% U' M' I, H3 L--------------------------------------------------7 p( S5 \6 s c# U _
& a% I) u1 t$ i* F3 Z
PCS(Pacemaker/Corosync configuration system)命令配置群集示例:& D) |2 F! b" m1 w: F& P1 [8 H" z
/ Y; h0 E/ d# C
) `$ B% _6 K I! @* @
一、建立群集:" Y& a+ K ~+ E7 D
; i; ^+ ?3 e& O* n9 G1、配置群集节点的认证as the hacluster user:
1 D/ I7 t/ q% G# R$ \ [shell]# pcs cluster auth node11 node12
6 l) U4 C2 r3 w: X, @9 N, U) s5 m: U& f# q; S
2、创建一个二个节点的群集% {7 D- {0 m" B. P5 C. q
[shell]# pcs cluster setup --name mycluster node11 node12- w) e! J0 ]' o) ?6 a+ _' ~# M% u/ S
[shell]# pcs cluster start --all ## 启动群集) U$ p Q% t* J- C
, \; K0 v+ _1 P0 \4 i& q4 `3、设置资源默认粘性(防止资源回切)
# F9 v6 H4 p) N+ w [shell]# pcs resource defaults resource-stickiness=100
8 n% ]8 ~: a ` [shell]# pcs resource defaults
4 ], {; {3 [- k% ]$ z) G6 K+ G
: Y) ]+ i) y# W' P. X9 e4 _) L4、设置资源超时时间+ D/ S3 P: l3 u9 G5 @
[shell]# pcs resource op defaults timeout=90s
* ?! i9 p6 l" \: Q, L0 n [shell]# pcs resource op defaults6 W$ r5 x1 b* Z5 r+ c- ^5 @
$ D) @) w) Q2 I: Z5、二个节点时,忽略节点quorum功能9 B& P/ z( ~0 A. l; e$ i: Q
[shell]# pcs property set no-quorum-policy=ignore7 c/ a$ ^7 @7 ?' I3 O
1 Y8 e' |+ H: u& e
6、没有 Fencing设备时,禁用STONITH 组件功能3 Y- g% `5 Z% m* Q/ Z
在 stonith-enabled="false" 的情况下,分布式锁管理器 (DLM) 等资源以及依赖DLM 的所有服务(例如 cLVM2、GFS2 和 OCFS2)都将无法启动。1 }+ F+ u5 T) |) @0 ^4 T* b' ^
[shell]# pcs property set stonith-enabled=false' y/ d/ a1 s" T; g: M7 X! a
[shell]# crm_verify -L -V ## 验证群集配置信息1 ?7 L3 y" Z1 O$ `' X& i" a5 a
0 \) I- B3 p* P( {5 ?) ?
2 r$ g! c4 L! r9 x9 b: U& {
) G# u( P2 z/ q9 X5 T2 l二、建立群集资源
# u6 n' F7 I" d) X
! l( _. X: V& I6 Q6 G1、查看可用资源
* E! F+ _) n, h% o; B' @ [shell]# pcs resource list ## 查看支持资源列表,pcs resource list ocf:heartbeat( M1 u' h, {8 X
[shell]# pcs resource describe agent_name ## 查看资源使用参数,pcs resource describe ocf:heartbeat:IPaddr2
; ?7 p6 p# D" t) Y
( z7 O0 i2 X& [- ~6 X# d% C2、配置虚拟IP
9 c2 m' w/ T+ K6 p% K [shell]# pcs resource create ClusterIP ocf:heartbeat:IPaddr2 \3 ]* @. }2 f7 W9 [# [- |0 w
ip="192.168.10.15" cidr_netmask=32 nic=eth0 op monitor interval=30s ) w- x6 x+ Z, `6 a1 U' H7 p/ A
( z+ F7 F3 v# ]5 h( R
3、配置Apache(httpd)
. p1 ^3 F, f1 ~! z( x( E( l I [shell]# pcs resource create WebServer ocf:heartbeat:apache \4 i% t2 ]* F1 E( c. b$ c# o7 \
httpd="/usr/sbin/httpd" configfile="/etc/httpd/conf/httpd.conf" \. a P# |2 @: j: |8 e( a) ~. ?5 L; P
statusurl="http://localhost/server-status" op monitor interval=1min
2 [7 r' ]% {& Z: J; R: [4 ]7 L* n) Y
8 R9 C7 F# m) ] b( U5 ^4、配置Nginx, `% [% |0 H' I5 P8 M: I. }
[shell]# pcs resource create WebServer ocf:heartbeat:nginx \7 G" r/ d. ^, t) K) b: r# f
httpd="/usr/sbin/nginx" configfile="/etc/nginx/nginx.conf" \8 Z( `0 s' `) C
statusurl="http://localhost/ngx_status" op monitor interval=30s3 C4 m. z, X( p3 e
6 ]% X$ W1 Q4 W: r3 a$ J7 c" w3 f5.1、配置FileSystem' C: d0 q% ^) s# e' Z- q9 u
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
, f; i) X e5 s' w, P device="/dev/sdb1" directory="/var/www/html" fstype="ext4", ]# [ k7 A& c3 y+ w9 d0 T8 @. y
7 D" r- Y: z6 h1 ]2 A
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
3 I1 z6 ?) Y0 Z0 M2 _8 u device="-U 32937d65eb" directory="/var/www/html" fstype="ext4"
' b; j2 q6 }' [3 `/ n; v5 b- M& X) U8 ?) B! z1 l6 b( x1 l$ B8 g- v
5.2、配置FileSystem-NFS
! L# y% w' A3 W [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
; S7 Y3 B9 c+ j* i& E2 ` device="192.168.10.18:/mysqldata" directory="/var/lib/mysql" fstype="nfs" \
6 r) A$ m1 M+ M8 N4 G( d options="-o username=your_name,password=your_password" \
3 P! U0 f2 x# g4 m: ^& H op start timeout=60s op stop timeout=60s op monitor interval=20s timeout=60s
& v; s8 \2 s, Y
+ r7 i8 m6 `% y- Z- ?5 x* b+ r3 U6、配置Iscsi
$ y& G/ H8 x7 `1 B [shell]# pcs resource create WebData ocf:heartbeat:iscsi \6 A# n# }% t* U; z% J$ a
portal="192.168.10.18" target="iqn.2008-08.com.starwindsoftware:" \
# A! h3 C: i9 ~ op monitor depth="0" timeout="30" interval="120"& M# A, Z7 `3 n9 V$ F
6 V, j ]: }0 O [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
& i# @% ^! B# f3 ^0 n8 ]& S/ {; i device="-U 32937d65eb" directory="/var/www/html" fstype="ext4" options="_netdev"# b I: a! F7 S2 D, j( K, w: E+ Y
( _4 U! D; _0 v3 W5 \
7、配置DRBD$ n" j2 V) w0 L5 b" ~
[shell]# pcs resource create WebData ocf:linbit:drbd \$ H# u4 Q/ A6 ^ s! ~! v
drbd_resource=wwwdata op monitor interval=60s
# E& `0 k/ v, M( E; ]2 H
6 L0 i% b* D8 X8 t [shell]# pcs resource master WebDataClone WebData \
; a, ], R1 o7 J master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true7 I& U1 R/ e% K6 `9 _; t
5 x9 r. i, K- i [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
5 g# v' x( w3 {+ Z3 C. V device="/dev/drbd1" directory="/var/www/html" fstype="ext4"' t2 ~$ s( L- i$ Z* O6 x
' Q$ f2 v+ Z& W( {( s
8、配置MySQL/ ~( U3 e6 Q3 o6 [' i
[shell]# pcs resource create MySQL ocf:heartbeat:mysql \: B! u' I! B4 _2 \
binary="/usr/bin/mysqld_safe" config="/etc/my.cnf" datadir="/var/lib/mysql" \
* D7 _# q, D' a pid="/var/run/mysqld/mysql.pid" socket="/tmp/mysql.sock" \3 g7 m5 k/ `2 m! F" Z) E: R
op start timeout=180s op stop timeout=180s op monitor interval=20s timeout=60s4 ^/ `9 q2 ^, t! @( L6 x
7 ^5 ]8 K+ \& g# r
9、配置Pingd,检测节点与目标的连接有效性
6 p! `2 d6 ^. g" s$ T% s2 I& } [shell]# pcs resource create PingCheck ocf:heartbeat:pingd \2 D/ L6 S4 p1 `; C4 I' d
dampen=5s multiplier=100 host_list="192.168.10.1 router" \: f- ], ?0 d+ @2 H' T' n$ D6 _) j
op monitor interval=30s timeout=10s
O2 Z6 N) z7 M: k( B7 I* \) S4 J2 Z) _; T/ |3 J3 N
10、创建资源clone,克隆的资源会在全部节点启动. \& }! H3 o/ f3 ]
[shell]# pcs resource clone PingCheck
2 N: Q' v S' @1 a! s7 T. ?/ ]2 s [shell]# pcs resource clone ClusterIP clone-max=2 clone-node-max=2 globally-unique=true ## clone-max=2,数据包分成2路+ p* \& f- Y x3 K( [9 P( G
[shell]# pcs resource update ClusterIP clusterip_hash=sourceip ## 指定响应请求的分配策略为:sourceip: G S0 X& q: G6 ]
( @9 l, [- {0 c. @! P
4 c1 W/ @! }0 D# {
* D" g+ q* l H9 L) |0 F三、调整群集资源3 l2 o/ ~: O5 V, _0 f: ^$ V
2 c6 N0 Q" Z- o3 V6 v1、配置资源约束
1 {* h0 u% t, j. U5 | [shell]# pcs resource group add WebSrvs ClusterIP ## 配置资源组,组中资源会在同一节点运行! M9 C5 \+ \' }0 ~
[shell]# pcs resource group remove WebSrvs ClusterIP ## 移除组中的指定资源
! K/ {" A, b! |$ S. C$ u [shell]# pcs resource master WebDataClone WebData ## 配置具有多个状态的资源,如 DRBD master/slave状态! [. \5 Y* O$ v: a
[shell]# pcs constraint colocation add WebServer ClusterIP INFINITY ## 配置资源捆绑关系
8 S7 |* L5 V. e7 M0 U [shell]# pcs constraint colocation remove WebServer ## 移除资源捆绑关系约束中资源
+ d4 z0 ]% F v5 y9 i% ` [shell]# pcs constraint order ClusterIP then WebServer ## 配置资源启动顺序' s$ v+ c9 j& J
[shell]# pcs constraint order remove ClusterIP ## 移除资源启动顺序约束中资源
: I( f0 [4 s) X9 U [shell]# pcs constraint ## 查看资源约束关系, pcs constraint --full1 S. e7 N3 z" _# r5 Y0 k
' b' E* e0 s$ K5 z; j. T9 y# ?
2、配置资源位置& j ]. ^2 O' K- d
[shell]# pcs constraint location WebServer prefers node11 ## 指定资源默认某个节点,node=50 指定增加的 score
1 F7 L" ]* O+ @( E2 d& H [shell]# pcs constraint location WebServer avoids node11 ## 指定资源避开某个节点,node=50 指定减少的 score& B' l& B, S$ u! A( ^7 L
[shell]# pcs constraint location remove location-WebServer ## 移除资源节点位置约束中资源ID,可用pcs config获取- _: o7 e% O. t& X2 O: X+ n
[shell]# pcs constraint location WebServer prefers node11=INFINITY ## 手工移动资源节点,指定节点资源的 score of INFINITY
; n% |4 P" u! _3 F: Q% ~ W& O [shell]# crm_simulate -sL ## 验证节点资源 score 值
7 A# x/ `$ x7 c; K7 j* i t; I
3、修改资源配置
1 k& D" ~) ~! b" P [shell]# pcs resource update WebFS ## 更新资源配置
" s: k! z: q: Z7 D" [+ F* ^ [shell]# pcs resource delete WebFS ## 删除指定资源' w# s i" O E5 T0 {; S
& d6 I7 T; j1 P. f1 Z l% D4、管理群集资源
4 `& o' h1 H$ D0 F/ l: C [shell]# pcs resource disable ClusterIP ## 禁用资源
0 l& Q$ U9 B0 i! K( c5 } [shell]# pcs resource enable ClusterIP ## 启用资源
1 Z5 Q# ] ?4 m" [% I [shell]# pcs resource failcount show ClusterIP ## 显示指定资源的错误计数
# a1 u! ]+ n% t7 G l [shell]# pcs resource failcount reset ClusterIP ## 清除指定资源的错误计数
% G3 ^: r4 G/ h. ]+ C2 ] [shell]# pcs resource cleanup ClusterIP ## 清除指定资源的状态与错误计数
( d+ L$ {4 C5 e& N9 f' f8 S% ?/ Y" m% m; C' L3 d9 Q* H
7 v* `% h" n) V$ a) b
( h: [. n! s' k- u1 ?- d; a6 B' E( _0 }' x2 ?% a
四、配置Fencing设备,启用STONITH
) Y" ~; l2 I' b5 L* G
/ m4 K/ g6 T. O$ z' o1、查询Fence设备资源
* ~2 Y5 D! K ]) B% `* k# ]" b [shell]# pcs stonith list ## 查看支持Fence列表5 ?5 ]( l- y0 c- J' U: n" p6 d9 q
[shell]# pcs stonith describe agent_name ## 查看Fence资源使用参数,pcs stonith describe fence_vmware_soap e; G1 x, ^0 k U! I0 z9 V
9 _3 E5 D) M, U& C2、配置fence设备资源
7 f. Q, R9 o/ r# F! W1 q [shell]# pcs stonith create ipmi-fencing fence_ipmilan \% J+ w$ z/ ~* B5 L! ]4 }! v, R
pcmk_host_list="pcmk-1 pcmk-2" ipaddr="10.0.0.1" login=testuser passwd=acd123 \
1 o. v. [- @( ?9 M/ X6 m op monitor interval=60s
" c$ j2 h" Z- F$ y1 g2 `$ T3 p
+ Z, y* ^ q! l, ] {/ ~2 x9 Rmark:
9 N- Q$ \- v2 n8 N: LIf 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.# K5 E4 g# y$ R0 e8 g
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.
' [- G+ ~- n! C8 n1 uIf 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.
# Y, K! {8 ~* e$ a0 O. IIf 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.
/ L) o; m) x( n/ jexample: pcmk_host_argument="uuid" pcmk_host_map="node11:4;node12:5;node13:6" pcmk_host_list="node11,node12" pcmk_host_check="static-list"
8 S0 n6 a) y# h8 Z3 r. c) y7 i- M- T
3、配置VMWARE (fence_vmware_soap)' y4 G- [- |; F+ F, m7 u
特别说明:本次实例中使用了第3项(pcs stonith create vmware-fencing fence_vmware_soap)这个指定pcmk配置参数才能正常执行Fencing动作。& R- G! E& p8 }, ]8 k& U8 I
5 t* B9 V: U5 D& a* \+ a2 k1 B& w5 g. |
3.1、确认vmware虚拟机的状态:$ f- u3 k2 U7 p/ o6 P! C4 x B/ T/ j
[shell]# fence_vmware_soap -o list -a vcenter.example.com -l cluster-admin -p <password> -z ## 获取虚拟机UUID
# Z" `- K v+ F [shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -U <UUID> ## 查看状态; d% S+ w8 d3 j3 M5 P, K; C
[shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -n <vm name>, P M, g% o1 @8 |6 \) ?- @& h
2 x* F* B" H C3.2、配置fence_vmware_soap
, U1 N* \) O; ~; Y) s [shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \
6 M# g6 t' W7 F- @ action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \
4 b" J; @6 G, k! n$ J port="node11" shell_timeout=60s login_timeout=60s op monitor interval=90s2 e( G( z4 A" K" v3 U
% p# K) A! d I2 w- z* B2 R0 a
[shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \
- q2 l: f3 J' |! ?% k& ~ action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \: X0 |5 ?* D& q! h g# S
uuid="421dec5f-c484-3d69-ddfb-65af46530581" shell_timeout=60s login_timeout=60s op monitor interval=90s. g8 k. I) x6 h+ n+ |) @7 F% g, F
3 b' `, O; R% {/ w: n
[shell]# pcs stonith create vmware-fencing fence_vmware_soap \ }9 F- U T @% o
action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \/ w. ?5 V& g" ?0 E: {
pcmk_host_argument="uuid" pcmk_host_check="static-list" pcmk_host_list="node11,node12" \% o! w5 U% V3 [: ~
pcmk_host_map="node11:421dec5f-c484-3d69-ddfb-65af46530581;node12:421dec5f-c484-3d69-ddfb-65af46530582" \
! k* @ H+ k$ y shell_timeout=60s login_timeout=60s op monitor interval=90s' a( {8 {# k) z5 v% }7 U
8 Z. e6 A# c$ ?% c& z f% ~
注:如果配置fence_vmware_soap设备时用port=vm name在测试时不能识别,则使用uuid=vm uuid代替;0 _5 P; T5 Q& `; i& A: b7 V) y
建议使用 pcmk_host_argument、pcmk_host_map、pcmk_host_check、pcmk_host_list 参数指明节点与设备端口关系,格式:7 K; O" a/ W2 Z s. F# e* n
pcmk_host_argument="uuid" pcmk_host_map="node11:uuid4;node12:uuid5;node13:uuid6" pcmk_host_list="node11,node12,node13" pcmk_host_check="static-list"2 P4 G1 l# h' E/ M0 |
/ i; `! U$ A5 `4 F
4、配置SCSI
1 K7 O1 P8 V% h+ o) D [shell]# ls /dev/disk/by-id/wwn-* ## 获取Fencing磁盘UUID号,磁盘须未格式化
) t( c, E# n9 |3 t9 g3 i [shell]# pcs stonith create iscsi-fencing fence_scsi \
+ T) q, U5 E! S {3 ?9 p4 } q. d action="reboot" devices="/dev/disk/by-id/wwn-0x600e002" meta provides=unfencing: ~1 r6 G" [8 F7 B) D2 w
% k; t' {* w; [2 |9 L) L5、配置DELL DRAC
1 i& J; a4 J |% _; G# ^ [shell]# pcs stonith create dell-fencing-node11 fence_drac! O# s4 b* p2 P v- O- }$ t* v
.....
# f4 R; j8 O5 M0 e) D/ [+ X, r
' n4 \% H/ J# v5 j
6、管理 STONITH$ G' O2 j: a8 _1 X i; T
[shell]# pcs resource clone vmware-fencing ## clone stonith资源,供多节点启动) X* o' K1 H2 d. [, q
[shell]# pcs property set stonith-enabled=true ## 启用 stonith 组件功能
2 ~9 E- p3 J' Z# [5 j [shell]# pcs stonith cleanup vmware-fencing ## 清除Fence资源的状态与错误计数5 C# J0 n, R/ v; _+ ^/ }
[shell]# pcs stonith fence node11 ## fencing指定节点
; p3 o5 Q8 F+ M3 A& v# }3 y3 Q8 [; e$ @3 o. J
8 e* E% L$ l8 y1 s7 d+ g8 h, J
! L6 b. C: a. P1 y" K7 J7 D4 ]" b* s0 r0 u1 H
五、群集操作命令4 _! q7 ~9 V( J: R B8 o
- ~* [8 N0 T' Q0 f/ J
1、验证群集安装( a G* L7 ]' }9 m
[shell]# pacemakerd -F ## 查看pacemaker组件,ps axf | grep pacemaker3 G% H# G* }7 Y1 q
[shell]# corosync-cfgtool -s ## 查看corosync序号
- s9 e" _0 Z# n [shell]# corosync-cmapctl | grep members ## corosync 2.3.x
# s) l9 i: @7 L( K. f5 U [shell]# corosync-objctl | grep members ## corosync 1.4.x
& u2 m' A, D' A" [5 J! \) q* v. J8 _
2、查看群集资源
, A9 M8 G( [0 D* c8 S: L$ n( E [shell]# pcs resource standards ## 查看支持资源类型
% u9 r; w d! U( O3 [2 C2 j [shell]# pcs resource providers ## 查看资源提供商% _# A" c; `! h4 C7 ^' {5 l
[shell]# pcs resource agents ## 查看所有资源代理+ |, F* n% k/ U! |1 L
[shell]# pcs resource list ## 查看支持资源列表
7 B) t H1 }3 ~+ N3 {) O6 h6 d [shell]# pcs stonith list ## 查看支持Fence列表# V$ N2 z4 i3 V( a" u# ^# S/ O0 @7 a
[shell]# pcs property list --all ## 显示群集默认变量参数' H0 Y. }* {: y0 X& D6 v8 G
[shell]# crm_simulate -sL ## 检验资源 score 值
: ?$ @3 w$ \+ O* k2 S2 S( V/ w- j9 F( G2 m" d' b+ a/ M% ~# o' t9 z# Q
3、使用群集脚本 v# E1 l: {+ U/ \0 ~$ o9 Q8 H
[shell]# pcs cluster cib ra_cfg ## 将群集资源配置信息保存在指定文件! U( V* Y4 X* L8 N
[shell]# pcs -f ra_cfg resource create ## 创建群集资源并保存在指定文件中(而非保存在运行配置)" u: k1 p4 U. H6 u4 D
[shell]# pcs -f ra_cfg resource show ## 显示指定文件的配置信息,检查无误后+ R5 V# b0 ]8 t0 {4 `: S
[shell]# pcs cluster cib-push ra_cfg ## 将指定配置文件加载到运行配置中/ |* M9 u/ |0 `
6 ?2 e4 X6 j5 S# @
4、STONITH 设备操作
+ I# ~; v: z0 b: O, U7 m) F [shell]# stonith_admin -I ## 查询fence设备
; ]6 B# `3 O! n4 t+ ^ [shell]# stonith_admin -M -a agent_name ## 查询fence设备的元数据,stonith_admin -M -a fence_vmware_soap! s$ I' e0 _0 x* T* e
[shell]# stonith_admin --reboot nodename ## 测试 STONITH 设备1 \+ T V$ U5 j1 N- o
6 q0 R B: v7 g9 x {( I0 A5、查看群集配置( Z, H7 Y1 \$ X" C' K# f
[shell]# crm_verify -L -V ## 检查配置有无错误
% ]+ B3 H- @% d) e% @6 y [shell]# pcs property ## 查看群集属性
3 z8 L. |% K1 s( j n# n [shell]# pcs stonith ## 查看stonith* f S! e8 i3 Y) n
[shell]# pcs constraint ## 查看资源约束! K' R2 k! o, G8 k ^' Y
[shell]# pcs config ## 查看群集资源配置: s/ F6 s3 w9 V4 o# _
[shell]# pcs cluster cib ## 以XML格式显示群集配置
3 e& J- j- V1 q% J) _) J- H5 }4 ?8 x3 H
6、管理群集& |! H8 B0 d; o# N5 |0 \, A
[shell]# pcs status ## 查看群集状态( J/ P: e- _% S2 Z" F6 I8 `. `
[shell]# pcs status cluster5 o1 s" W6 F- v; ^
[shell]# pcs status corosync
9 u; H7 r0 d* J [shell]# pcs cluster stop [node11] ## 停止群集
5 }* b& R8 q2 `; J( I6 H [shell]# pcs cluster start --all ## 启动群集
- O" c6 E! U& W) S2 Z. A [shell]# pcs cluster standby node11 ## 将节点置为后备standby状态,pcs cluster unstandby node11 5 g" c* y3 x: b" G7 c' M
[shell]# pcs cluster destroy [--all] ## 删除群集,[--all]同时恢复corosync.conf文件
8 I( Q `1 @- ~6 h8 ^ [shell]# pcs resource cleanup ClusterIP ## 清除指定资源的状态与错误计数
( n; O' R# F+ F [shell]# pcs stonith cleanup vmware-fencing ## 清除Fence资源的状态与错误计数
6 j- t. T# U5 R/ \0 J/ d% @
/ B! ~$ \ i8 [6 S" i, H u) o& r% W; N% Q' w8 ~
|
|