易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 3886|回复: 0
收起左侧

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

[复制链接]
发表于 2018-1-6 19:22:20 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?开始注册

x
使用pcs shell配置corosync & pacemaker群集
5 R9 W8 d0 B( p. S+ e% n$ X  |. d6 ~2 w" i- q% f& n

/ y- M$ i- p  u8 Z3 a: I) ~Pacemaker
5 v4 B7 U2 M7 f! k) _% n5 pPacemaker,即Cluster Resource Manager(CRM),管理整个HA,客户端通过pacemaker管理监控整个集群。# [5 L6 q1 o. a6 d
+ {& q* I0 l* l* u# k
CRM支持ocf和lsb两种资源类型:' T; P+ j6 W5 l- L

# e4 X% q* f2 X* F8 A( V! Kocf格式的启动脚本在/usr/lib/ocf/resource.d/下面。4 t' g/ G  g; Q; S6 @9 z7 J8 n
lsb的脚本一般在/etc/rc.d/init.d/下面。$ N4 V* m% e1 F6 d- a$ z

) r8 h- {$ y# Z) f. k" ]
3 O! }' ~* M8 }; @7 Z0 ]$ i
0 Q1 ~6 t- i1 g) ^1、常用的集群管理工具:
' R# t/ y, P% V# `* G(1)基于命令行, D# L" H6 X: W. Q' W
crm shell/pcs4 a7 Z8 @$ r% R0 d* M4 q

7 S4 u$ i# k$ F1 l) ?, P2 l$ U! ](2)基于图形化) ]1 D7 @, ]4 E0 z
pygui/hawk/lcmc/pcs# W; `6 M3 I( {* q) Y* R) e6 _
! n# Y0 x" f$ W2 t

- V+ Y; p% J8 R' [6 Y8 _2、相关的资源文件:
2 `& X0 M7 _4 c/ D3 b(1)/usr/lib/ocf/resource.d,pacemaker资源库文件位置,可安装资源包:resource-agents 获取更多ocf格式的资源。3 v. \( y3 j& J7 i
(2)/usr/sbin/fence_***,Fencing设备的执行脚本名称,可安装资源包:fence-agents 获取更多Fencing设备资源。
+ K( g! ]2 w5 t2 K# ]1 M% q# Z1 `9 K( ~: `! Q* G& r- }
3、查看使用说明:( g: H/ O% i3 m1 {) [* k
[shell]# man ocf_heartbeat_***          ## 查看OCF资源说明,man ocf_heartbeat_apache: L. r) o! a* a
[shell]# man fence_***                  ## 查看Fencing设备说明,man fence_vmware2 q8 T6 D8 Q  T8 n( p
# T2 o6 @  i) @6 E$ O; Z' G
4、参考文档. o! \7 T; j; r& t3 s/ w& a5 W
https://github.com/ClusterLabs
3 h* Z0 S( E) S! A8 A; ~/ fhttp://clusterlabs.org/doc/$ B, Z( b/ S* @$ T1 M  K$ T
http://www.linux-ha.org/doc/man-pages/man-pages.html' |7 c: Z4 z: ?* p/ {7 I
https://access.redhat.com/docume ... acemaker/index.html0 k' {  v/ i$ U2 t0 W  e

+ U$ y& w* J, B在群集配置过程中参考了互联网上众多优秀文章,在此感谢原作者!!!0 U% r9 v; q$ q: n! t: M9 ]& A# _. W

4 w; }" E2 l. |8 g: S8 y& y以下记录整理了在vmware esxi5.5 + centos6.6环境中使用PCS命令配置corosync & pacemaker群集的一些操作,由于本人水平有限,仅供参考:
' }6 x( q4 n1 s7 o, M4 E4 Z. `, E# R1 D" q
--------------------------------------------------& V" v) y" R9 W2 C" T$ o. I8 O

5 E$ s+ }8 n2 r% @, l& \1 T' w/ f, d( C5 [6 r" K6 [: x
1.安装群集软件:$ U8 w' Q  [& [
[shell]# yum -y install corosync pacemaker pcs$ i/ w' P" ?4 d2 b# W8 [
[shell]# yum -y install fence-agents resource-agents
! f4 e7 F, C, Z; a% {3 a" R. n6 I' v3 u2 `9 r. p
2.拷贝配置文件、启动脚本
# Q# {  y& j* F9 a4 c1 c( H9 |3 L6 k [shell]# mkdir -p /etc/cluster/
0 h" m. w+ G$ u1 ^, ?$ v [shell]# ln -s /etc/rc.d/init.d/corosync /etc/rc.d/init.d/cman
* f9 K/ F8 Z. i- N( p- e2 ~& b [shell]# ln -s /usr/sbin/corosync-cmapctl /usr/sbin/corosync-objctl$ X; q9 t; K6 `! A8 C
[shell]# cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf7 M$ @. K) D( H
2 A. H9 z3 B% W4 W! T

. w2 s' A+ t' e7 p; M& w3 `4 r注意:群集需要严格的时间同步机制,如果启用了防火墙需要开放相应的端口。! i4 w4 u" ]3 o2 O
) W. u5 C1 |# K1 i8 L
--------------------------------------------------
4 {/ S" g5 q5 l$ g- {5 e8 F  P; ~% n; A) b2 ~- P3 y
PCS(Pacemaker/Corosync configuration system)命令配置群集示例:
" W7 N  u- j6 V& o5 _  N! N
! o  L0 j7 A% K2 _1 }# Y, c6 n0 M
' z0 o8 B* w  |) j% D3 B( N$ x3 ?8 `. T一、建立群集:, d8 {$ F% b0 n5 Z3 C1 U! h# o
3 E2 F2 L( D8 J: U  z
1、配置群集节点的认证as the hacluster user:
, n3 v$ H- J) m+ M* F4 \7 P [shell]# pcs cluster auth node11 node12
& N, u( `: O/ [8 b* j' G/ o' W& i6 D* G, _5 ]: h
2、创建一个二个节点的群集
. p% _+ V2 n. x9 y6 m" B [shell]# pcs cluster setup --name mycluster node11 node12+ O0 C8 Y$ O' t5 c6 X- F! b
[shell]# pcs cluster start --all                                  ## 启动群集2 w1 `' ^4 P4 E2 h
3 p/ Z* a5 b3 N: [7 j& D0 P) b
3、设置资源默认粘性(防止资源回切)* w2 D& ^4 c' G! t/ u, H3 R# D
[shell]# pcs resource defaults resource-stickiness=100
  j4 o- z: F# @6 M& [9 L [shell]# pcs resource defaults
! D% H3 g+ T( o
/ y7 O1 F2 a7 X4、设置资源超时时间/ z. W6 D: p5 i
[shell]# pcs resource op defaults timeout=90s
. M0 s+ C# C2 t [shell]# pcs resource op defaults$ w6 I  y+ X& t$ Q$ S' o
( o: t' S+ b  X+ G( F9 `) ~# t3 i0 L2 f
5、二个节点时,忽略节点quorum功能
* r8 U7 w3 N, J! B: ^ [shell]# pcs property set no-quorum-policy=ignore2 W* g# b6 k' ^: k4 H" g

5 a( z5 a2 O: [8 [- ?6、没有 Fencing设备时,禁用STONITH 组件功能
7 _$ \3 e. H% G) o7 E+ s在 stonith-enabled="false" 的情况下,分布式锁管理器 (DLM) 等资源以及依赖DLM 的所有服务(例如 cLVM2、GFS2 和 OCFS2)都将无法启动。5 K1 t9 {3 B/ Q4 v, v3 ^7 y
[shell]# pcs property set stonith-enabled=false. S2 [6 V% l- ~9 ^+ {( z; V9 ~  K3 w
[shell]# crm_verify -L -V                                            ## 验证群集配置信息; D% u9 C% J  \6 _. b, y# J' Y
3 S4 ]4 i* G. E5 f* D5 n

7 n: P# Q- H- o
' L: S  x/ ?3 W* |7 Y+ d( s二、建立群集资源% w* t  y7 l- S7 F; E2 B

" X9 V  `0 @( I1、查看可用资源
' n7 _( O- V5 e [shell]# pcs resource list                                         ## 查看支持资源列表,pcs resource list ocf:heartbeat* h5 H5 V7 O7 Y6 N
[shell]# pcs resource describe agent_name                          ## 查看资源使用参数,pcs resource describe ocf:heartbeat:IPaddr2$ {2 t9 R) ]: W+ w6 j

  }  }7 K' Z. w; t- ~0 t0 W; M2、配置虚拟IP# [  D! v5 s1 o7 S  S; @" X7 H
[shell]# pcs resource create ClusterIP ocf:heartbeat:IPaddr2 \- V4 n5 P2 I3 K" a& T. K# v
  ip="192.168.10.15" cidr_netmask=32 nic=eth0 op monitor interval=30s & x& v: K, G5 ]" X, r& C" P

8 ^0 X1 c* |9 t; z3、配置Apache(httpd)
4 m: Y$ _1 X! ?6 g [shell]# pcs resource create WebServer ocf:heartbeat:apache \
, q7 r; B1 g0 c$ s9 H  httpd="/usr/sbin/httpd" configfile="/etc/httpd/conf/httpd.conf" \$ C/ g" d5 l& n( q
  statusurl="http://localhost/server-status" op monitor interval=1min9 z2 O$ i2 y. e9 l3 B

" ?% A$ X* [1 {4、配置Nginx
# e9 P5 }7 G$ ?& }( e% P3 C [shell]# pcs resource create WebServer ocf:heartbeat:nginx \
$ r' |5 p  a4 _. {9 @) c  w  httpd="/usr/sbin/nginx" configfile="/etc/nginx/nginx.conf" \
3 M5 a! @$ e  G- v  statusurl="http://localhost/ngx_status" op monitor interval=30s$ C( b% R% j& d9 Q3 s6 n3 x

9 p0 h3 ]/ c- Y8 L7 S3 e* c5.1、配置FileSystem1 l  s! [+ @) @  l. q. I) T
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
6 D; q( K6 l5 w+ t: ?  device="/dev/sdb1" directory="/var/www/html" fstype="ext4"( L! c  p# \" E3 ]
" T6 R9 @) _; `
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \% M3 w# W! k& l8 v( b
  device="-U 32937d65eb" directory="/var/www/html" fstype="ext4"  F' E3 {3 A; t/ `5 a7 d9 A
3 E: [1 w' @8 r5 x
5.2、配置FileSystem-NFS
9 n0 `0 J9 B# D# p: r: W# t3 M [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
4 I- t4 r: I5 E3 w: F& \  device="192.168.10.18:/mysqldata" directory="/var/lib/mysql" fstype="nfs" \
4 Y! o4 @9 B( Q, u) _) o  options="-o username=your_name,password=your_password" \8 O. _7 N  {7 n/ x: g3 w0 J
  op start timeout=60s op stop timeout=60s op monitor interval=20s timeout=60s9 Y& A/ N1 i& x3 y$ g# v

3 X& p$ O0 {% L2 v# U# k6、配置Iscsi- d& d: p: y6 ?5 ^4 B- g
[shell]# pcs resource create WebData ocf:heartbeat:iscsi \0 v2 {8 s% P! P7 S5 I: k
  portal="192.168.10.18" target="iqn.2008-08.com.starwindsoftware:" \4 B$ a- `# r/ U, g
  op monitor depth="0" timeout="30" interval="120"
! U# _7 k) o0 k: A8 B$ x6 h
6 q! s' O7 y: R( Y" {, _ [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
1 B! [: W! y9 B0 ?  device="-U 32937d65eb" directory="/var/www/html" fstype="ext4" options="_netdev"" B1 b1 V' @) x0 R6 \
: V/ g4 S  d* H$ g! R
7、配置DRBD
) M; ^  C" C- N8 w/ h [shell]# pcs resource create WebData ocf:linbit:drbd \
# i& H5 l; @- k  Z' Y% n% m  drbd_resource=wwwdata op monitor interval=60s
7 I! N6 [+ g' E1 t
! g0 _0 y/ m; ^# j5 p [shell]# pcs resource master WebDataClone WebData \- \* ~. y1 i9 `1 h9 M# Q0 n
  master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true
0 l& U" s" h, u" q1 c6 R5 k: `0 T$ }$ |: Q- l! o6 Y" I' p
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
" s! u6 Q  W0 A  device="/dev/drbd1" directory="/var/www/html" fstype="ext4"
9 W4 N. S' j7 [% `+ L; t
9 F6 v4 h+ `, @7 ~: @; U6 `8、配置MySQL
0 R+ v  C5 P! h* \$ y3 n7 V [shell]# pcs resource create MySQL ocf:heartbeat:mysql \6 e( i* b4 E) t$ p# P  w
  binary="/usr/bin/mysqld_safe" config="/etc/my.cnf" datadir="/var/lib/mysql" \4 d$ Y$ R5 R4 W& y/ X; G  t
  pid="/var/run/mysqld/mysql.pid" socket="/tmp/mysql.sock" \
/ d  u: K% ?% p7 }1 u. M  op start timeout=180s op stop timeout=180s op monitor interval=20s timeout=60s
# u6 N! h: [& ?7 ?. ~
) G6 n6 K8 o. {$ J9、配置Pingd,检测节点与目标的连接有效性1 T" T+ i/ D1 {
[shell]# pcs resource create PingCheck ocf:heartbeat:pingd \* A( X  o" W! ?9 w9 ~9 B" ?% p
  dampen=5s multiplier=100 host_list="192.168.10.1 router" \. ?) L! F# V- C# i( X( j( R# Z! s
  op monitor interval=30s timeout=10s% m" T4 {' N1 U' g3 \; J

, u+ \' t9 t: B4 p10、创建资源clone,克隆的资源会在全部节点启动; Q! p9 `. N8 X3 D' ?# x
[shell]# pcs resource clone PingCheck0 g& L4 K" ?" ]( s6 p
[shell]# pcs resource clone ClusterIP clone-max=2 clone-node-max=2 globally-unique=true            ## clone-max=2,数据包分成2路
( ~  @. T6 L! S5 p; ^6 t [shell]# pcs resource update ClusterIP clusterip_hash=sourceip            ## 指定响应请求的分配策略为:sourceip2 K' [7 |9 q  y) {
5 |, _  M; d! B, N3 V3 p

! ?* R, s' _5 Y# K/ v, V; b; V% w1 U2 \2 _' v3 L5 H; D
三、调整群集资源
9 |# _1 N( z3 J' j6 ~3 X0 T- b; q! v- U  r; ]5 ]6 h
1、配置资源约束+ W6 r# h/ C: l3 D9 O/ g
[shell]# pcs resource group add WebSrvs ClusterIP                            ## 配置资源组,组中资源会在同一节点运行
# A: p" T2 u1 U8 c" J- R [shell]# pcs resource group remove WebSrvs ClusterIP                    ## 移除组中的指定资源8 a: D+ N- g8 h& d0 N! E! L7 E
[shell]# pcs resource master WebDataClone WebData                          ## 配置具有多个状态的资源,如 DRBD master/slave状态' p/ E- W6 J5 B2 i
[shell]# pcs constraint colocation add WebServer ClusterIP INFINITY          ## 配置资源捆绑关系
- M* B# ?* l4 |, M& l: q% R [shell]# pcs constraint colocation remove WebServer                      ## 移除资源捆绑关系约束中资源' O! W5 e) Z: Q4 b$ C8 A% p
[shell]# pcs constraint order ClusterIP then WebServer                   ## 配置资源启动顺序
8 H, [0 ?0 o& w  N  A9 Q [shell]# pcs constraint order remove ClusterIP                             ## 移除资源启动顺序约束中资源: Q4 B9 L  _. o4 I+ n
[shell]# pcs constraint                                                  ## 查看资源约束关系, pcs constraint --full  z0 ]. }/ @# ~; V' q* P
, n# c0 G+ N( t) Q
2、配置资源位置# T& O! w! E. a
[shell]# pcs constraint location WebServer prefers node11                 ## 指定资源默认某个节点,node=50 指定增加的 score* Y% t" ]0 ^2 ?# ?- H$ j* s" v) [4 E
[shell]# pcs constraint location WebServer avoids node11                ## 指定资源避开某个节点,node=50 指定减少的 score+ e6 x3 U, y8 s' o) y4 w
[shell]# pcs constraint location remove location-WebServer                ## 移除资源节点位置约束中资源ID,可用pcs config获取5 {' R% ]7 E  Q' a- _; p5 Z  f" m! \
[shell]# pcs constraint location WebServer prefers node11=INFINITY           ## 手工移动资源节点,指定节点资源的 score of INFINITY
4 v$ l3 u+ u4 D6 Y [shell]# crm_simulate -sL                                                    ## 验证节点资源 score 值8 J7 r8 G6 j# [8 ?5 e* H
$ H% b+ x' B2 l0 y
3、修改资源配置$ P  s* x' e1 t, M7 H  D& D4 i% l$ [6 }
[shell]# pcs resource update WebFS                                            ## 更新资源配置+ o/ w5 {4 v' Z1 Y
[shell]# pcs resource delete WebFS                                            ## 删除指定资源* I% Z3 r# q6 m* f6 a$ g8 _
6 {, U; F5 d9 Q- u
4、管理群集资源
1 ~$ j/ t/ K; C$ U; }" ? [shell]# pcs resource disable ClusterIP                                    ## 禁用资源; m- C- x, F8 ~' x( e
[shell]# pcs resource enable ClusterIP                                    ## 启用资源
5 f% e$ _4 t4 X. w7 ^ [shell]# pcs resource failcount show ClusterIP                          ## 显示指定资源的错误计数
; d, x/ G2 p1 s3 I' E& O* o; c [shell]# pcs resource failcount reset ClusterIP                         ## 清除指定资源的错误计数
( }6 {. P: O  |$ D6 _' `. D. m [shell]# pcs resource cleanup ClusterIP                                ## 清除指定资源的状态与错误计数$ h& F0 W1 f+ P* l9 k

5 g; _; L2 {* F; W. k, o3 K+ W- M& `2 s+ }
1 Q4 s' p3 e* G- t( g

# z* S, d4 L% s; U四、配置Fencing设备,启用STONITH& A/ a2 K; H* A4 m" |, r
1 X! I" J* r6 |2 J) _' h  P
1、查询Fence设备资源
4 p( j( r% Z0 [: f$ X; g4 { [shell]# pcs stonith list                                                   ## 查看支持Fence列表
$ w2 k1 a- r; E+ n [shell]# pcs stonith describe agent_name                                  ## 查看Fence资源使用参数,pcs stonith describe fence_vmware_soap/ e% I! _9 `, b  ^  P7 z7 V0 ~
       
* y- t6 W, B9 u( U" ~9 J: X' {2、配置fence设备资源: [4 k( V# N9 ]6 G% p
[shell]# pcs stonith create ipmi-fencing fence_ipmilan \4 S5 x& m- ~+ ]7 Q% F" F
  pcmk_host_list="pcmk-1 pcmk-2" ipaddr="10.0.0.1" login=testuser passwd=acd123 \- b! m9 S( a9 M
  op monitor interval=60s9 H- e0 x" `& i& o0 g6 v2 t$ ^

9 M1 R- ~6 O) w( }1 l5 \/ Nmark:
  ^2 \4 c/ K  p  x! D5 A. \) W3 [, uIf 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.
! r! Y. G/ k( a$ W5 IIf 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., V# x# [8 X; V, _# b
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.
0 c4 c( @% z, j) [, r/ ^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.. {4 C. c/ F% J% X* {
example: pcmk_host_argument="uuid" pcmk_host_map="node11:4;node12:5;node13:6" pcmk_host_list="node11,node12"  pcmk_host_check="static-list"" E* K4 Y0 W9 V' X  h' ?
( F8 M! T( N3 Q. u% c5 R
3、配置VMWARE (fence_vmware_soap)) n$ S3 [2 u, C/ D' N& \
特别说明:本次实例中使用了第3项(pcs stonith create vmware-fencing fence_vmware_soap)这个指定pcmk配置参数才能正常执行Fencing动作。" ^# D3 n, g" w$ S/ m
; F2 A  ]' l2 c. ~3 ^
3.1、确认vmware虚拟机的状态:
5 H* h$ B0 I: F3 p [shell]# fence_vmware_soap -o list -a vcenter.example.com -l cluster-admin -p <password> -z                          ## 获取虚拟机UUID
' O) E0 a0 l! U% E, s4 I3 K5 x# ]8 E [shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -U <UUID>         ## 查看状态
( ?4 L+ a5 a$ n  { [shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -n <vm name>
0 G/ c4 }( D7 b+ T* {2 L) |3 e4 L/ @& r+ w7 |, [, \8 O# y
3.2、配置fence_vmware_soap
; O- H/ Z- ]( l, ~ [shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \
) E. B' w/ o6 o  action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \
. j/ \0 e5 ?4 i. Q8 t7 o( m  port="node11" shell_timeout=60s login_timeout=60s op monitor interval=90s1 Y' S1 ^" b. n+ H" M( W6 \0 l

! v: \+ k& ?5 i+ [ [shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \, u/ O( S) T/ B' i
  action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \
: \: o& ]- n- B9 ]5 k7 z4 ~  uuid="421dec5f-c484-3d69-ddfb-65af46530581" shell_timeout=60s login_timeout=60s op monitor interval=90s
& m9 W, B/ Q* [& ]. s# H+ f0 N% |
. g. b* n; {8 f8 q  c" M [shell]# pcs stonith create vmware-fencing fence_vmware_soap \% n; L5 r% ]; h1 D3 W# u
  action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \
7 t; i! |, {# a* {8 W/ R- S6 x) D" x  pcmk_host_argument="uuid" pcmk_host_check="static-list" pcmk_host_list="node11,node12" \
; b" a! ^* c; O1 X  pcmk_host_map="node11:421dec5f-c484-3d69-ddfb-65af46530581;node12:421dec5f-c484-3d69-ddfb-65af46530582" \
- Y/ I; y  k3 C  shell_timeout=60s login_timeout=60s op monitor interval=90s
6 p) N  E$ ?4 R' S$ r$ S9 Y' Z( I. f. Y9 V  T7 u, h; X3 h8 |7 x/ P5 q
注:如果配置fence_vmware_soap设备时用port=vm name在测试时不能识别,则使用uuid=vm uuid代替;) z+ R" @. e* ?
建议使用 pcmk_host_argument、pcmk_host_map、pcmk_host_check、pcmk_host_list 参数指明节点与设备端口关系,格式:
% g' I8 p. l2 h- S, M+ 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"6 W8 [; g, H. Y. d

9 s2 X! G7 P9 {. a  m- ~4、配置SCSI" K# w4 C! ^/ f0 F2 D, A+ f
[shell]# ls /dev/disk/by-id/wwn-*                            ## 获取Fencing磁盘UUID号,磁盘须未格式化
3 a$ Y( M, S+ i, x% t$ R9 U [shell]# pcs stonith create iscsi-fencing fence_scsi \# ^3 {0 j0 O8 q
  action="reboot" devices="/dev/disk/by-id/wwn-0x600e002" meta provides=unfencing9 @% i2 k2 u, v
3 F6 i! ?( W$ m; M) c2 b# B
5、配置DELL DRAC8 E# ]" `2 B8 `7 Y5 L
[shell]# pcs stonith create dell-fencing-node11 fence_drac- y5 F8 k9 P6 E1 k8 h
.....
5 E/ E, t- E% V% V% x3 R4 x4 ~4 A+ E8 e& f9 s
# _- B8 @  l2 I+ P1 Q. N. o$ }8 }
6、管理 STONITH! q* e! H4 \# a5 O
[shell]# pcs resource clone vmware-fencing                    ## clone stonith资源,供多节点启动
1 G8 Z( v+ f6 D [shell]# pcs property set stonith-enabled=true          ## 启用 stonith 组件功能8 O: G5 g+ k2 O7 E7 _; v: w
[shell]# pcs stonith cleanup vmware-fencing                ## 清除Fence资源的状态与错误计数
3 h& X" k* a  h7 q% i; M3 l [shell]# pcs stonith fence node11                             ## fencing指定节点
0 I) |" n3 L  `5 d7 {) y5 d
: V0 B8 G/ ]; }5 N( [6 X* o
- A7 w9 {  A* {" Z; m9 R' n/ v! Z# B, v/ n! a3 O
& A( ?+ d5 L; C: q
五、群集操作命令
5 u( l2 d# W& ~# M9 y* a* y# n$ T7 x) w6 o8 o0 {# K
1、验证群集安装
2 K0 A: @: v2 I# @' V [shell]# pacemakerd -F                                    ## 查看pacemaker组件,ps axf | grep pacemaker+ n7 Y$ V& z. l0 Q1 H& D
[shell]# corosync-cfgtool -s                                  ## 查看corosync序号* D/ U3 {1 G3 \0 X: J) q+ D! p) B
[shell]# corosync-cmapctl | grep members                  ## corosync 2.3.x
( C0 ]+ q0 L9 G7 R3 T) @ [shell]# corosync-objctl | grep members                  ## corosync 1.4.x6 F& I  l- n: b9 \: ?# A8 F

- j& I+ ?* z: Y* P2、查看群集资源- }% M& r5 P  y8 {; b
[shell]# pcs resource standards                          ## 查看支持资源类型  C7 ^, S3 x; N7 j8 z! A3 H
[shell]# pcs resource providers                          ## 查看资源提供商: H# x/ f/ C  W+ `* K
[shell]# pcs resource agents                                ## 查看所有资源代理
& @6 O& _1 q4 x" q) ~# {: @ [shell]# pcs resource list                                 ## 查看支持资源列表
- u/ g; B" q9 ` [shell]# pcs stonith list                                ## 查看支持Fence列表
! m* p  A. l2 g5 a+ @8 P2 Y [shell]# pcs property list --all                        ## 显示群集默认变量参数7 L4 N3 G5 u7 |/ K
[shell]# crm_simulate -sL                                    ## 检验资源 score 值" G: N- c) c; ]/ p' ]: Z
0 A' B) _4 ?9 W3 S
3、使用群集脚本
5 D3 E3 s: N4 C2 L" l [shell]# pcs cluster cib ra_cfg                            ## 将群集资源配置信息保存在指定文件
2 {( x* Z; w/ n [shell]# pcs -f ra_cfg resource create                    ## 创建群集资源并保存在指定文件中(而非保存在运行配置)+ Z& c$ V- K0 b' ?4 ], E* Z
[shell]# pcs -f ra_cfg resource show                          ## 显示指定文件的配置信息,检查无误后
1 Y& C% J' J2 j$ d [shell]# pcs cluster cib-push ra_cfg                          ## 将指定配置文件加载到运行配置中# i% {# Q! W- c& F
$ _2 J7 C7 X, u4 W( |
4、STONITH 设备操作9 e( U  P: X( k. \9 w' W. k
[shell]# stonith_admin -I                                    ## 查询fence设备- v) Y2 V: t$ P
[shell]# stonith_admin -M -a agent_name                   ## 查询fence设备的元数据,stonith_admin -M -a fence_vmware_soap
7 R' W& B$ B3 ^: T [shell]# stonith_admin --reboot nodename                    ## 测试 STONITH 设备; F+ _, T0 J9 g+ t
) Y' T9 \) E5 g& K! t
5、查看群集配置
3 R! ?  G6 k5 l9 H [shell]# crm_verify -L -V                                    ## 检查配置有无错误: U8 P9 b! }2 k1 [. [( s2 b9 }
[shell]# pcs property                                    ## 查看群集属性0 x. _. H% h: L, o) {, l. F
[shell]# pcs stonith                                    ## 查看stonith* M" O/ c; z6 S: Z( u
[shell]# pcs constraint                                    ## 查看资源约束
5 s& n' c. y$ ~+ H& j8 ~) O. d [shell]# pcs config                                    ## 查看群集资源配置
# A# r$ e) g( k' O. v7 f1 A [shell]# pcs cluster cib                                    ## 以XML格式显示群集配置6 R8 W2 f; f6 a1 U6 T) r' D/ b
5 |" E$ N2 d6 @+ O5 `
6、管理群集+ {7 O- ?$ o8 ]( D
[shell]# pcs status                                          ## 查看群集状态2 l: m0 E$ ?2 I1 `1 j) D6 J% {, C
[shell]# pcs status cluster
+ w! ^6 |* S& l' u# B [shell]# pcs status corosync
" C; y# [$ W; X [shell]# pcs cluster stop [node11]                          ## 停止群集$ c9 H' N2 E2 j' t7 o( J/ r' n
[shell]# pcs cluster start --all                            ## 启动群集( W5 M3 X" o. d) |4 l- p3 e
[shell]# pcs cluster standby node11                          ## 将节点置为后备standby状态,pcs cluster unstandby node11 5 T  I9 D0 M" t7 D( u+ w
[shell]# pcs cluster destroy [--all]                          ## 删除群集,[--all]同时恢复corosync.conf文件/ c% m# T9 p; l1 q
[shell]# pcs resource cleanup ClusterIP                ## 清除指定资源的状态与错误计数
3 T, ^! z4 t- `, A- ?, F3 B [shell]# pcs stonith cleanup vmware-fencing                ## 清除Fence资源的状态与错误计数
( U, H) }- y8 z% V! a$ |2 ~& {% Y' D$ p7 l: V0 z
) m! F& @# K6 ^1 X" O% J
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 点击这里给我发消息

GMT+8, 2026-4-8 17:40 , Processed in 0.046024 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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