找回密码
 注册
查看: 3884|回复: 0

PCS命令配置corosync、pacemaker群集操作步骤

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2018-1-6 19:22:20 | 显示全部楼层 |阅读模式
使用pcs shell配置corosync & pacemaker群集
8 L- Q6 Y, f# x% J& x! I+ }! }* l" X# b! P8 z. a
) U, k9 A4 |+ v& J, r
Pacemaker0 C5 u1 w+ }) Q' c; k
Pacemaker,即Cluster Resource Manager(CRM),管理整个HA,客户端通过pacemaker管理监控整个集群。
8 n# `5 R1 w! G. a7 z+ r6 E8 Q
0 z5 ^9 p. G8 E* c4 Q; yCRM支持ocf和lsb两种资源类型:4 i$ D  M+ ]8 M* H& T* X3 G
( K2 k7 u* S; U/ O0 a7 i; @1 }8 B
ocf格式的启动脚本在/usr/lib/ocf/resource.d/下面。: G. b, n3 L/ @- f
lsb的脚本一般在/etc/rc.d/init.d/下面。
  y' M% R3 h# g' |9 @, X) T
0 A, n* _4 h1 Z$ _! K. j* a& I
3 w9 f6 t- `7 v0 `
1 x# Y$ [9 a/ K1 u" [2 p1、常用的集群管理工具:0 |; N5 n" {* q3 G
(1)基于命令行
$ y3 r% n4 @- Hcrm shell/pcs
" ]0 f/ e1 m5 X8 J8 d7 R& N( r  {0 [0 ]$ }
(2)基于图形化/ t1 B6 L6 c$ s2 s
pygui/hawk/lcmc/pcs
+ Z, f& v9 a* M8 b
- B. k) F/ @7 r' H/ v9 K4 K8 m# b3 J. p  \5 h
2、相关的资源文件:' U6 z8 @6 |! r/ O8 J+ l3 f- b( j1 M
(1)/usr/lib/ocf/resource.d,pacemaker资源库文件位置,可安装资源包:resource-agents 获取更多ocf格式的资源。; _& }/ ^) @# Q. ?
(2)/usr/sbin/fence_***,Fencing设备的执行脚本名称,可安装资源包:fence-agents 获取更多Fencing设备资源。
8 p+ ~: @1 N) E8 u- ]; i/ d7 a/ `" F7 V
3、查看使用说明:7 p* s* K: h+ _- J0 n
[shell]# man ocf_heartbeat_***          ## 查看OCF资源说明,man ocf_heartbeat_apache$ T* v) A% ^! L" V2 x3 A% e
[shell]# man fence_***                  ## 查看Fencing设备说明,man fence_vmware
# }& \8 _/ W8 \( H: u
3 T8 I% q5 M5 c" O4 W& |4、参考文档; ^2 P9 l* ^9 p* N) E
https://github.com/ClusterLabs
, h, c% n; K1 a2 |- ghttp://clusterlabs.org/doc/
  j& e5 M2 Y- Z! s6 g) vhttp://www.linux-ha.org/doc/man-pages/man-pages.html
$ c" I& q4 n4 |% `& r4 Uhttps://access.redhat.com/docume ... acemaker/index.html
3 I% V& a1 M! {, n: r
3 h! S( `0 ~2 p: @在群集配置过程中参考了互联网上众多优秀文章,在此感谢原作者!!!
, ]: O/ H  Y2 p* r: L% Y  j2 ~4 Y+ a& D
以下记录整理了在vmware esxi5.5 + centos6.6环境中使用PCS命令配置corosync & pacemaker群集的一些操作,由于本人水平有限,仅供参考:
3 r( |1 x( K" v; R$ i/ q, |
) I% [& Y: O2 y4 |) l$ w--------------------------------------------------
3 j  g1 x2 _; D" X! Z
! e% j1 s# S- b1 k3 H7 j" S1 X1 `. F( q. j
1.安装群集软件:
8 C: i/ U: Z& c1 }. A& Q [shell]# yum -y install corosync pacemaker pcs: N# M9 f6 k' E; i: C! e: K$ M
[shell]# yum -y install fence-agents resource-agents& p# p. J# S, L4 m  s

3 r& H2 F- Y; h9 G2.拷贝配置文件、启动脚本
, h' [; ?9 `1 O! u5 x! k [shell]# mkdir -p /etc/cluster/" v% r; }3 {1 [' j4 r* V1 H2 L
[shell]# ln -s /etc/rc.d/init.d/corosync /etc/rc.d/init.d/cman
' c4 z! f" ?: U. l" ?1 I& Q& n [shell]# ln -s /usr/sbin/corosync-cmapctl /usr/sbin/corosync-objctl* a8 ^2 g  W1 j8 y8 Z) X8 s
[shell]# cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf$ o- @( \# d0 V% I/ @

; z/ d% y' O  P  l% _( g! T* p0 s1 _9 H/ @8 ^4 I6 |: G
注意:群集需要严格的时间同步机制,如果启用了防火墙需要开放相应的端口。- e! T* t* S& E0 \

2 w2 J$ @* q" }% j$ L--------------------------------------------------
* f7 E  ?7 Q3 v0 {. t; f( ]+ G1 k* t& U' a# a  `) y) F
PCS(Pacemaker/Corosync configuration system)命令配置群集示例:
1 p2 Y6 x' ]5 Q4 I
5 f* T; P% ]* E/ @6 H, D" S& V! o' l
一、建立群集:
. K' @) B4 d! C: S7 I- c  H
" T$ B5 k0 S) l7 J% w1、配置群集节点的认证as the hacluster user:3 S$ b0 \6 D7 g4 k$ Y$ ~* H' @0 `
[shell]# pcs cluster auth node11 node12; ?0 }4 y3 s, L; @+ Q* B: [5 r

, z- Q% {% O% Z8 f: g' C2、创建一个二个节点的群集& B' L& D* T7 B0 d
[shell]# pcs cluster setup --name mycluster node11 node123 T( k" u( Q" e% d( l9 M
[shell]# pcs cluster start --all                                  ## 启动群集
7 u) V0 [7 T  }' ^  I; X& }; }8 ~# j* r* Y& X8 L
3、设置资源默认粘性(防止资源回切)
' f3 L3 C" S1 p" M& n; v% ` [shell]# pcs resource defaults resource-stickiness=100& H- ~( S0 F2 g4 S4 i0 ~
[shell]# pcs resource defaults" y( n" B0 s4 S6 q4 e

8 o. V6 A2 N% _/ S: m/ `4、设置资源超时时间
# y+ U. t% b; O# |1 d2 M& R# V [shell]# pcs resource op defaults timeout=90s
) B6 {" x7 O6 h [shell]# pcs resource op defaults2 S/ l* R: N& w
2 K; e$ g, l+ m. T% Q. m0 t
5、二个节点时,忽略节点quorum功能
1 ]& ]2 `3 B% L% |2 b, H. g. L [shell]# pcs property set no-quorum-policy=ignore
, l- e$ Y& _/ i) m; }( p: D3 Q/ w1 @" j6 D" v7 K+ G* v0 `
6、没有 Fencing设备时,禁用STONITH 组件功能; n4 y- a8 v8 e
在 stonith-enabled="false" 的情况下,分布式锁管理器 (DLM) 等资源以及依赖DLM 的所有服务(例如 cLVM2、GFS2 和 OCFS2)都将无法启动。
( O) |1 P/ i/ O5 w% ~2 a [shell]# pcs property set stonith-enabled=false
" r1 x( q; ~. R$ s) l4 ~ [shell]# crm_verify -L -V                                            ## 验证群集配置信息( Y& A/ s! S# {: Q0 B
+ W: j- \6 g. {' l. y2 Y2 s  H

0 a3 S5 Z2 S1 A, T
+ x2 I' H5 k7 S+ X9 m* a2 b二、建立群集资源
; B3 z" l) a% Z' P. U8 s1 l0 e, l5 t. z) s
1、查看可用资源9 c, Y0 ?$ _0 ^; V! M
[shell]# pcs resource list                                         ## 查看支持资源列表,pcs resource list ocf:heartbeat
  a( M! v3 [6 d1 O$ Z6 `3 A! B [shell]# pcs resource describe agent_name                          ## 查看资源使用参数,pcs resource describe ocf:heartbeat:IPaddr2
2 U3 s9 Z5 B( M: G4 K% X7 @5 @
& h! t6 |1 Z- H0 I) Z2、配置虚拟IP
$ u' f9 R3 q" {% N. a4 f [shell]# pcs resource create ClusterIP ocf:heartbeat:IPaddr2 \
+ P1 d& q2 O# g0 E$ p6 |) s" R  ip="192.168.10.15" cidr_netmask=32 nic=eth0 op monitor interval=30s
* u1 h8 d( ?( P* e; ]5 w' g6 J1 y% v  x; m0 I( Q: A; S
3、配置Apache(httpd)4 c$ N: V3 F* V0 O# i
[shell]# pcs resource create WebServer ocf:heartbeat:apache \6 V4 `# ]: b& m" q0 _
  httpd="/usr/sbin/httpd" configfile="/etc/httpd/conf/httpd.conf" \6 Q# \- u9 Y, p" ?
  statusurl="http://localhost/server-status" op monitor interval=1min
7 @7 @' j* W  _3 {  O% z2 f
9 `# A' n* r0 }) n3 ]0 q4、配置Nginx
- E5 x3 L9 a5 Q' m" s" W' ^+ x0 V' W [shell]# pcs resource create WebServer ocf:heartbeat:nginx \! b- {3 c/ o. S' ?! h+ K$ ^% e( M
  httpd="/usr/sbin/nginx" configfile="/etc/nginx/nginx.conf" \# ~; G8 _% G; x; x5 k6 G  Z
  statusurl="http://localhost/ngx_status" op monitor interval=30s  W5 w: c6 F5 N0 ?% Y9 n8 ~0 t

& h, T5 r; l4 m% I5.1、配置FileSystem' ^! J7 S' t8 E, H% l7 ]  I/ i  x- @
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \8 Q( c" o- S( ?6 w
  device="/dev/sdb1" directory="/var/www/html" fstype="ext4"
+ e0 Z" c* [0 N9 t6 |$ D  b  R9 k7 C" [" X2 [+ e8 q) l
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
( h6 E' e+ N" d  device="-U 32937d65eb" directory="/var/www/html" fstype="ext4"2 y6 x2 e. o, E3 m+ E9 B

) e1 b/ O: U4 a1 ]' E" V* A9 O" @5.2、配置FileSystem-NFS* d$ }" M! @  d& J& c5 L
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
4 i# h, o4 W  ^3 Y' d7 M  device="192.168.10.18:/mysqldata" directory="/var/lib/mysql" fstype="nfs" \' s8 i7 A7 f3 N! v
  options="-o username=your_name,password=your_password" \
: c! q: b9 _8 Q9 z( M2 M$ D8 e  op start timeout=60s op stop timeout=60s op monitor interval=20s timeout=60s
% K$ f" g# H. O- O1 `* I6 Q+ q6 }1 m/ W5 X
6、配置Iscsi+ R, b, g. u4 F! P2 ?5 ]$ b
[shell]# pcs resource create WebData ocf:heartbeat:iscsi \& Q$ d5 t+ S1 l  R; a5 t4 p, [
  portal="192.168.10.18" target="iqn.2008-08.com.starwindsoftware:" \1 T3 g* W& d8 F4 y' o( _5 h" ~
  op monitor depth="0" timeout="30" interval="120"- y* b# c! ?$ o4 ]/ v
8 R5 Y, V8 q) x5 \1 o
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \' o+ ~* y. [* P  C0 p' X; \
  device="-U 32937d65eb" directory="/var/www/html" fstype="ext4" options="_netdev"
+ e5 Q8 o9 X8 I  F) O' H
7 `: R8 y$ r# d- a7、配置DRBD: p  t% f9 A+ Z4 n0 d
[shell]# pcs resource create WebData ocf:linbit:drbd \- V6 O; C9 E6 s* G* I
  drbd_resource=wwwdata op monitor interval=60s* m7 K5 X, P' Y" e

( D4 n1 A: l7 G( @5 K& o/ v! N [shell]# pcs resource master WebDataClone WebData \
2 ?+ ^( x/ H2 Y% [' L: m/ b3 u  master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true4 s1 m/ L) @( r' F$ I
$ |8 w1 A% X9 t( a, |9 E
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \* _$ T" C+ f( e/ p( w6 [+ P: k
  device="/dev/drbd1" directory="/var/www/html" fstype="ext4"2 f7 b! V( I* s6 b- t
5 W4 _% v- Q, O; p  ^: q' t3 `( S
8、配置MySQL
/ ]- G% x5 Y9 K5 a1 y9 }- U# |4 Y [shell]# pcs resource create MySQL ocf:heartbeat:mysql \
- J. c+ T* H& ?7 U3 _  binary="/usr/bin/mysqld_safe" config="/etc/my.cnf" datadir="/var/lib/mysql" \
7 E4 N+ |" X: ^! o& \& J7 {- Y  pid="/var/run/mysqld/mysql.pid" socket="/tmp/mysql.sock" \9 z4 Z! k. o( A6 `) T* T; z! I
  op start timeout=180s op stop timeout=180s op monitor interval=20s timeout=60s1 V6 l) o3 A3 p% D6 X9 n
: Z+ o5 p: B; w
9、配置Pingd,检测节点与目标的连接有效性
$ D/ [6 |3 w! k! x0 m, V [shell]# pcs resource create PingCheck ocf:heartbeat:pingd \- ~1 Z+ c6 N: i8 [$ D
  dampen=5s multiplier=100 host_list="192.168.10.1 router" \
6 m1 e: q- [; A2 P9 s# r, I  op monitor interval=30s timeout=10s
7 }/ }# w1 X( E1 i
. c1 ~* n  s7 M! {" d! O' y2 P$ M: z10、创建资源clone,克隆的资源会在全部节点启动
  Z5 J2 Z6 d( g6 i; w$ r [shell]# pcs resource clone PingCheck
( P4 [! v# w' X, N [shell]# pcs resource clone ClusterIP clone-max=2 clone-node-max=2 globally-unique=true            ## clone-max=2,数据包分成2路4 ]" h0 U; w/ J  v0 j% E
[shell]# pcs resource update ClusterIP clusterip_hash=sourceip            ## 指定响应请求的分配策略为:sourceip  R/ ~% X& q& e2 K0 K# R/ ~: t6 C

) P" @9 Y" {& v
& t8 s' ]: v( i0 q- N* h  N+ n8 G. f( _# _
三、调整群集资源* P; F6 T3 H! u, S' Y. d; m- m

6 U2 c9 a1 c2 |* M) I7 [" `" J1、配置资源约束
2 L$ f5 ]9 y. W [shell]# pcs resource group add WebSrvs ClusterIP                            ## 配置资源组,组中资源会在同一节点运行
# |4 n% Z2 O8 g3 m4 Y) b% d7 g [shell]# pcs resource group remove WebSrvs ClusterIP                    ## 移除组中的指定资源
8 u7 O6 E# b6 R8 P0 p/ a [shell]# pcs resource master WebDataClone WebData                          ## 配置具有多个状态的资源,如 DRBD master/slave状态
6 H' X+ d. S7 |  p [shell]# pcs constraint colocation add WebServer ClusterIP INFINITY          ## 配置资源捆绑关系, x0 h" M. j, B7 \8 ]
[shell]# pcs constraint colocation remove WebServer                      ## 移除资源捆绑关系约束中资源
5 N. m  Q( [. @- p( [5 v [shell]# pcs constraint order ClusterIP then WebServer                   ## 配置资源启动顺序5 x8 h4 k6 @& [
[shell]# pcs constraint order remove ClusterIP                             ## 移除资源启动顺序约束中资源; S: ]) n4 y- n
[shell]# pcs constraint                                                  ## 查看资源约束关系, pcs constraint --full
! ^; w6 H: f$ m9 m# q6 g3 ~
5 M' k( J* v- A8 T& K. Y, \0 P+ `2、配置资源位置* O. @! I4 M6 ?! L  X
[shell]# pcs constraint location WebServer prefers node11                 ## 指定资源默认某个节点,node=50 指定增加的 score
$ m2 P- ?, z. y; j5 m2 K [shell]# pcs constraint location WebServer avoids node11                ## 指定资源避开某个节点,node=50 指定减少的 score* [/ v) k7 e. M8 Z4 x. {- c# }
[shell]# pcs constraint location remove location-WebServer                ## 移除资源节点位置约束中资源ID,可用pcs config获取  ?. M8 P3 ^5 q# ~
[shell]# pcs constraint location WebServer prefers node11=INFINITY           ## 手工移动资源节点,指定节点资源的 score of INFINITY9 `, p7 M) p  I, H' f
[shell]# crm_simulate -sL                                                    ## 验证节点资源 score 值# r4 Q  Q' R' h+ W0 F
' ?5 {* `! W2 `) p' w8 R9 y
3、修改资源配置4 {: k2 T. y; l
[shell]# pcs resource update WebFS                                            ## 更新资源配置
7 o; r( \0 z; @5 ~. @2 x3 ^  P7 ? [shell]# pcs resource delete WebFS                                            ## 删除指定资源4 {8 Q& @+ J% D. a( s
% U- X1 x6 {$ o8 \/ @; ?
4、管理群集资源6 ?+ k8 H  G# Y0 W* `0 ]6 S
[shell]# pcs resource disable ClusterIP                                    ## 禁用资源: L. H6 F* W) _# C, \
[shell]# pcs resource enable ClusterIP                                    ## 启用资源' D' x2 W  \2 c9 W, H7 A6 B: M
[shell]# pcs resource failcount show ClusterIP                          ## 显示指定资源的错误计数
3 P1 k2 Q, S7 W5 U [shell]# pcs resource failcount reset ClusterIP                         ## 清除指定资源的错误计数
$ E0 `+ m! I' B- `) b3 r6 S  s" A [shell]# pcs resource cleanup ClusterIP                                ## 清除指定资源的状态与错误计数$ \/ e; C8 n6 U) f$ F, A2 H3 h2 I$ X3 _
& k& J4 H% l. j4 q7 g+ g

$ B, F/ P* O" s* }+ M# Q  @, a; a6 T8 g1 ]

+ s0 ]: J& j6 \. X% Q6 f* n四、配置Fencing设备,启用STONITH
7 V4 L. {6 T& ]+ w
3 v( R" ?2 v8 C% J  M7 b1、查询Fence设备资源. e6 u9 a, Z6 X7 B6 ~3 A6 f: x8 k% D
[shell]# pcs stonith list                                                   ## 查看支持Fence列表
: }: ?" B+ ^' P" R5 o' ]& s [shell]# pcs stonith describe agent_name                                  ## 查看Fence资源使用参数,pcs stonith describe fence_vmware_soap
% j% K) e3 y  e) L, t8 q  F       
4 P4 M! m* L- O6 k2、配置fence设备资源! ~4 G/ u7 g* V' U9 @) }; M
[shell]# pcs stonith create ipmi-fencing fence_ipmilan \; ^1 q$ W7 _' w' C* m0 E8 x3 _
  pcmk_host_list="pcmk-1 pcmk-2" ipaddr="10.0.0.1" login=testuser passwd=acd123 \
- i. J% E* `- W( B  op monitor interval=60s, a2 Q8 N. w0 {, }
3 f1 ]; s* z* R. p% C
mark:) K1 C2 J+ U- @2 p9 T1 O" |
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.3 v* Q2 W1 e2 b# r
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.% P# P3 j; q4 x
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.1 r. i1 [& u+ d
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.' e5 x2 o( ]9 f6 ]7 C, A6 w
example: pcmk_host_argument="uuid" pcmk_host_map="node11:4;node12:5;node13:6" pcmk_host_list="node11,node12"  pcmk_host_check="static-list") R! V8 P# i: z7 e2 \( s

' p/ K6 i; _0 g2 ~3 v: _3、配置VMWARE (fence_vmware_soap)4 _: l+ A7 a5 I1 ?# `3 ]
特别说明:本次实例中使用了第3项(pcs stonith create vmware-fencing fence_vmware_soap)这个指定pcmk配置参数才能正常执行Fencing动作。( F  g7 S! {# e8 \+ h' c

1 G/ g1 k3 l  \5 r3.1、确认vmware虚拟机的状态:
) d2 ?) S+ |' O: [1 k [shell]# fence_vmware_soap -o list -a vcenter.example.com -l cluster-admin -p <password> -z                          ## 获取虚拟机UUID
! i8 M6 {6 ?: i) o [shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -U <UUID>         ## 查看状态
4 L1 }+ U+ L6 t  h. l1 p [shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -n <vm name>! m5 p) @* r# k" N! h# h% V4 }
% C) l4 l$ w, c) z
3.2、配置fence_vmware_soap
4 H! V# v0 E- O4 V' Z [shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \" w7 }3 Y: H, |* _% j" V8 Y: {% w
  action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \
' i4 s/ J- B1 O5 X/ Z3 s+ E: h  port="node11" shell_timeout=60s login_timeout=60s op monitor interval=90s7 Z1 w% U  C/ T" R, G

. {. C' z! K% o; i) \7 }, Y/ t. x [shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \
( O# s' i+ i5 ^& k+ |  action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \  z' }$ `; h8 S! S7 s/ v& W" g
  uuid="421dec5f-c484-3d69-ddfb-65af46530581" shell_timeout=60s login_timeout=60s op monitor interval=90s
- a' @; Z: T4 b% r2 J3 a, q: Y# w/ S" _8 D
[shell]# pcs stonith create vmware-fencing fence_vmware_soap \/ D0 [1 L' q* X
  action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \& G, I9 \! u+ `1 y5 a
  pcmk_host_argument="uuid" pcmk_host_check="static-list" pcmk_host_list="node11,node12" \3 |) t6 N: h7 X- f/ I
  pcmk_host_map="node11:421dec5f-c484-3d69-ddfb-65af46530581;node12:421dec5f-c484-3d69-ddfb-65af46530582" \
$ t; S: K8 w- N2 U6 i  shell_timeout=60s login_timeout=60s op monitor interval=90s  S$ `( {" y+ [

& A# d* O; n$ y4 l) ^6 v注:如果配置fence_vmware_soap设备时用port=vm name在测试时不能识别,则使用uuid=vm uuid代替;
) W' ^) t: I$ S; I建议使用 pcmk_host_argument、pcmk_host_map、pcmk_host_check、pcmk_host_list 参数指明节点与设备端口关系,格式:
: F8 R- z2 Y# S5 O1 j pcmk_host_argument="uuid"  pcmk_host_map="node11:uuid4;node12:uuid5;node13:uuid6"  pcmk_host_list="node11,node12,node13"  pcmk_host_check="static-list"
) i4 A. s, N7 t
. D0 T& ?2 L+ \+ @; M0 i0 a- L% y4、配置SCSI8 }3 o' V& c1 x, D( D1 I: h6 x
[shell]# ls /dev/disk/by-id/wwn-*                            ## 获取Fencing磁盘UUID号,磁盘须未格式化, @5 f% g1 z* c. [  O5 y' e) `6 X+ k
[shell]# pcs stonith create iscsi-fencing fence_scsi \) r1 \' ~1 z1 _! n7 m2 ]% n
  action="reboot" devices="/dev/disk/by-id/wwn-0x600e002" meta provides=unfencing
: |; Z* \6 y7 z: B, m0 h* o" v* G$ {$ d; ]+ z
5、配置DELL DRAC
1 c) N6 ?8 C& D  F% G; k% C2 ` [shell]# pcs stonith create dell-fencing-node11 fence_drac# o3 P: F: C* p0 r3 k" _6 ^
.....
3 B. a! L$ B6 [7 f9 D( I8 f# ]  O7 ^0 e: m7 E! ]9 `0 {/ C* W

0 W# f+ \/ q1 O. n/ @) b6、管理 STONITH4 i4 [0 o5 }' I6 {. i( H/ M& b) o" {
[shell]# pcs resource clone vmware-fencing                    ## clone stonith资源,供多节点启动
3 O8 [9 [, ~6 {1 }2 {) q [shell]# pcs property set stonith-enabled=true          ## 启用 stonith 组件功能5 h  d9 V, L8 D/ r
[shell]# pcs stonith cleanup vmware-fencing                ## 清除Fence资源的状态与错误计数
) q1 ?$ t/ |$ l2 o. j( R8 ^ [shell]# pcs stonith fence node11                             ## fencing指定节点
3 k4 h+ C. h& X  |! I  Q# o; I' H6 k, x+ {3 N4 J9 z
6 T& _9 Q9 v/ a: F) ^: O/ {

$ R! V, D; N" n( q" G* B  L% ]4 @8 s" z% c" f* L" {
五、群集操作命令# J' q) e+ m* G9 n
$ T' N1 t2 H) f* C+ w
1、验证群集安装
$ V7 K7 @; O" {" W# |9 J* e [shell]# pacemakerd -F                                    ## 查看pacemaker组件,ps axf | grep pacemaker" k1 A$ R& K8 q5 p3 [
[shell]# corosync-cfgtool -s                                  ## 查看corosync序号
/ B3 |1 ?0 W& z8 S: B [shell]# corosync-cmapctl | grep members                  ## corosync 2.3.x( U: q. f% d6 z( T9 ]/ y
[shell]# corosync-objctl | grep members                  ## corosync 1.4.x
) h9 Q( S4 N! _% r' W2 o! o2 C  T, N# ^, T
2、查看群集资源8 p8 I' Y) G+ X) @
[shell]# pcs resource standards                          ## 查看支持资源类型0 P. `5 x/ n3 t
[shell]# pcs resource providers                          ## 查看资源提供商
6 `; d' @  a6 Z  P [shell]# pcs resource agents                                ## 查看所有资源代理# T' p' j% E* C2 k1 i& ?
[shell]# pcs resource list                                 ## 查看支持资源列表
; o% I* ~! g5 K( N) h [shell]# pcs stonith list                                ## 查看支持Fence列表1 g) C1 R0 @) h5 t
[shell]# pcs property list --all                        ## 显示群集默认变量参数. ]+ Q; t  Y8 V
[shell]# crm_simulate -sL                                    ## 检验资源 score 值/ `; d( I- Z9 U6 T% S# k+ A$ h; H; c
2 a2 E, P* i1 ^- z, C9 |- c
3、使用群集脚本& q* K/ I% N5 O% @
[shell]# pcs cluster cib ra_cfg                            ## 将群集资源配置信息保存在指定文件! k4 }9 q& u" g9 {2 N6 E
[shell]# pcs -f ra_cfg resource create                    ## 创建群集资源并保存在指定文件中(而非保存在运行配置)
9 e6 l, Y! f: ?4 P2 w% f [shell]# pcs -f ra_cfg resource show                          ## 显示指定文件的配置信息,检查无误后$ O/ ?2 I0 g6 R: z4 M7 d( Y
[shell]# pcs cluster cib-push ra_cfg                          ## 将指定配置文件加载到运行配置中* W1 a& C  N4 R; w9 H4 [& h7 h% Q, D( m) b
7 J7 x6 E; _9 ^
4、STONITH 设备操作: R* O% z3 ~& y7 J( L
[shell]# stonith_admin -I                                    ## 查询fence设备
6 O! w5 T9 Z% l! j* m: Z% d [shell]# stonith_admin -M -a agent_name                   ## 查询fence设备的元数据,stonith_admin -M -a fence_vmware_soap+ ~! Q3 W0 J& t5 D0 w- B$ w! s
[shell]# stonith_admin --reboot nodename                    ## 测试 STONITH 设备, K4 y5 n+ Y2 y! u. m7 O9 a
& b: O2 F) h- Y5 r# c7 D) y9 {
5、查看群集配置
0 \8 y0 a, C' G# j [shell]# crm_verify -L -V                                    ## 检查配置有无错误
+ u( Z9 Z0 J6 X& ^) T% v* g [shell]# pcs property                                    ## 查看群集属性7 e/ c* G1 `; h
[shell]# pcs stonith                                    ## 查看stonith
: [7 v7 y" }+ D( l, ~" x [shell]# pcs constraint                                    ## 查看资源约束
3 D# U: [5 I  ~2 u6 `. C [shell]# pcs config                                    ## 查看群集资源配置
8 |* K% {. S7 V( ^6 K% J [shell]# pcs cluster cib                                    ## 以XML格式显示群集配置" o( f% f. j" s9 Z- F! ^/ U9 l

3 i# L0 o  x% C1 J$ z6、管理群集
" U9 D& X3 `4 ~ [shell]# pcs status                                          ## 查看群集状态
  G- p& H: C. ^. n( z/ B& S! e [shell]# pcs status cluster6 _7 i. p0 O: i% ^4 g6 h. F
[shell]# pcs status corosync  x1 I. W/ y; Y. z4 F* i
[shell]# pcs cluster stop [node11]                          ## 停止群集' E" |6 z% r# T6 O6 B$ I* T, l
[shell]# pcs cluster start --all                            ## 启动群集
" J2 C. ^# i- [0 j6 N [shell]# pcs cluster standby node11                          ## 将节点置为后备standby状态,pcs cluster unstandby node11
- g5 ?  v# ?: [) D8 L6 n [shell]# pcs cluster destroy [--all]                          ## 删除群集,[--all]同时恢复corosync.conf文件' C) Q+ V6 o/ G3 u1 \; G
[shell]# pcs resource cleanup ClusterIP                ## 清除指定资源的状态与错误计数9 l5 F3 ~- C  S. i$ a
[shell]# pcs stonith cleanup vmware-fencing                ## 清除Fence资源的状态与错误计数* B7 `. [- O9 h9 P% I) ^

. ~2 L7 S& }9 j2 J% c& Y' N. i8 G# R: H
, O9 e0 L$ f$ j8 H
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 01:00 , Processed in 0.023700 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表