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

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

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2018-1-6 19:22:20 | 显示全部楼层 |阅读模式
使用pcs shell配置corosync & pacemaker群集
, C  g% M. k) I9 G
/ E! @3 ], `) G/ E! j  [7 @) q, ~7 s4 Z0 \2 F) Q! i5 }
Pacemaker# s: s- n3 }4 W$ I* ]
Pacemaker,即Cluster Resource Manager(CRM),管理整个HA,客户端通过pacemaker管理监控整个集群。# H2 m7 g6 G8 k* m- e. E+ E
3 T9 ^6 H  ~3 G0 W# a- j. ]
CRM支持ocf和lsb两种资源类型:! f2 f9 G3 S$ b6 f
# ], u% I) j* D9 _
ocf格式的启动脚本在/usr/lib/ocf/resource.d/下面。
5 ~4 I9 {; c8 I7 {3 Wlsb的脚本一般在/etc/rc.d/init.d/下面。
2 f8 y: j7 \5 S1 J* q- m$ S: D% I  m3 L- `; |5 U' F
* [9 t( ?4 e' l5 A
/ g8 q/ _; T" E3 U2 L
1、常用的集群管理工具:
' H. z8 o1 n0 }0 m2 K6 _(1)基于命令行7 b1 W' {+ M3 e1 V
crm shell/pcs
5 K6 o: E( a) n( u3 W1 d& j4 {' p. O9 [4 d
(2)基于图形化
. Z4 D! {% C3 Upygui/hawk/lcmc/pcs0 I( V7 R. G! L. h# }5 s. `

7 P' h" N" B" o2 ~
$ \. p* G& P6 L8 W( _) u2、相关的资源文件:: ^; e/ N- I, U8 b
(1)/usr/lib/ocf/resource.d,pacemaker资源库文件位置,可安装资源包:resource-agents 获取更多ocf格式的资源。
! I+ e7 r+ }, D  e& u(2)/usr/sbin/fence_***,Fencing设备的执行脚本名称,可安装资源包:fence-agents 获取更多Fencing设备资源。% Y7 ~3 n1 ?$ M6 M' `

6 h7 S7 ?' t* h3 J, x. J3、查看使用说明:
1 m; v/ @! h1 ~. ] [shell]# man ocf_heartbeat_***          ## 查看OCF资源说明,man ocf_heartbeat_apache
) B* ^, t9 y) w; c [shell]# man fence_***                  ## 查看Fencing设备说明,man fence_vmware9 s- E: n1 M" A' w( I0 B- r4 O

* D+ C' a8 M2 V2 `( _- x4、参考文档
" a7 a: u" o% w! ?' p' H7 Zhttps://github.com/ClusterLabs* u4 r' `, d$ _" a) k. q6 V
http://clusterlabs.org/doc/- `( H9 V1 i0 y1 K! }. j. Y. W& W# R
http://www.linux-ha.org/doc/man-pages/man-pages.html7 F! X- P4 F8 I$ ]. q
https://access.redhat.com/docume ... acemaker/index.html
2 s3 j* ?8 w! X2 O$ K
+ E2 Y( N7 h- M, d6 @9 k在群集配置过程中参考了互联网上众多优秀文章,在此感谢原作者!!!. a: Q# K2 d/ c
( i) `/ |/ B, I& Q: n1 E; O
以下记录整理了在vmware esxi5.5 + centos6.6环境中使用PCS命令配置corosync & pacemaker群集的一些操作,由于本人水平有限,仅供参考:, F" i* P0 W* }. s0 I: R* ^; ]

: @( S: L0 L1 e  ?1 F6 }--------------------------------------------------
7 o& q$ i( B4 ^  \0 Z  [+ V- k: m$ h( j2 v7 [1 X$ W
: m  D, E$ V) k1 y
1.安装群集软件:
0 o8 ^- H2 L( i6 j$ [5 J7 B [shell]# yum -y install corosync pacemaker pcs
. n+ q# R2 I- Q8 B' z  U# Z [shell]# yum -y install fence-agents resource-agents# p3 q7 F9 _) W8 b- L* c

6 ?- \' ^1 F) @. v2.拷贝配置文件、启动脚本
3 o: V5 @  o! X$ K/ |0 v. F [shell]# mkdir -p /etc/cluster/
) L$ |, }+ L8 m/ F+ ]  h/ v [shell]# ln -s /etc/rc.d/init.d/corosync /etc/rc.d/init.d/cman2 W  b+ W7 ^% V! e1 @4 p' P
[shell]# ln -s /usr/sbin/corosync-cmapctl /usr/sbin/corosync-objctl/ h. b. `' l- \
[shell]# cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf
# M, ?( j+ ~9 \: d" ?$ B: p8 ^! ^9 A# g- n8 p& i
1 U; l3 W( {( A) h7 F
注意:群集需要严格的时间同步机制,如果启用了防火墙需要开放相应的端口。
& @: ]/ u" q' y! U9 `
- H: G4 c5 P* w! ?% H; G--------------------------------------------------
  a) k; p5 f' k7 \
& U. c1 `. h: {! V5 q$ J! hPCS(Pacemaker/Corosync configuration system)命令配置群集示例:8 r; ^* i4 [; `8 \: d' \5 ]

# A4 G% x( q: f! |  E( _: o# D  c/ A0 l4 J) t+ |7 m' I9 L2 H/ X/ W
一、建立群集:
  \- P* T& X2 C- F+ I0 {" j2 s0 M' }% }
1、配置群集节点的认证as the hacluster user:: l% y% v( f0 Q' j; y
[shell]# pcs cluster auth node11 node12: g3 L: T( A/ t; G5 v; F
* i8 i" g. K  t+ d
2、创建一个二个节点的群集
$ _) \' R2 e2 j; L1 t [shell]# pcs cluster setup --name mycluster node11 node12
, d# {0 o8 n7 G' ] [shell]# pcs cluster start --all                                  ## 启动群集% o( X% `2 |! p1 C

! ~" `) m6 k  j3、设置资源默认粘性(防止资源回切)( g; ^% n, J) k; A- N+ k
[shell]# pcs resource defaults resource-stickiness=100) U* N: K  Z8 z% [8 K- s- w; I
[shell]# pcs resource defaults
" _2 g9 \* M- n3 K8 W0 F" s5 k7 }5 L  E  t0 W7 o" j1 t8 I
4、设置资源超时时间. F. N! P4 B/ [5 `3 N* Y
[shell]# pcs resource op defaults timeout=90s2 `  T3 U# Z% l7 \
[shell]# pcs resource op defaults% \3 f7 G: v7 A* n2 Z. M

. F2 Y( ?( K3 f+ d! r- |5、二个节点时,忽略节点quorum功能7 z  ]) x: |# Z1 `( w6 u' @* R8 i2 [
[shell]# pcs property set no-quorum-policy=ignore
( C, B/ W  j  A* @5 o) [$ y" g! n  c: j/ o
6、没有 Fencing设备时,禁用STONITH 组件功能) ]) \( Z8 w% L  M! Y
在 stonith-enabled="false" 的情况下,分布式锁管理器 (DLM) 等资源以及依赖DLM 的所有服务(例如 cLVM2、GFS2 和 OCFS2)都将无法启动。, N- z0 t; I3 z" C' s0 C; e
[shell]# pcs property set stonith-enabled=false& p3 ?" u, l6 O7 n' h( }
[shell]# crm_verify -L -V                                            ## 验证群集配置信息
+ \& j" f, v. l) z2 g* u4 b+ l/ f7 _4 {& Y5 q: w  g5 X

3 {5 B! B9 ~! U7 A$ H, C/ k. a
$ q3 A8 n; j4 ?) S& N8 E二、建立群集资源( G8 o9 g6 `; n9 E: ~' y! s! h* j+ |
( w- o8 E# `1 J6 D3 k! A3 N, }
1、查看可用资源
8 J  M, P2 Z3 [ [shell]# pcs resource list                                         ## 查看支持资源列表,pcs resource list ocf:heartbeat# a- r3 }3 s4 v/ i( H  R( N
[shell]# pcs resource describe agent_name                          ## 查看资源使用参数,pcs resource describe ocf:heartbeat:IPaddr2* [& N! M1 ]  F3 X. g3 p0 n, I

/ g2 }3 @! a) X) ?2 c, N2、配置虚拟IP" Z3 G9 r8 I: `( L3 ], s
[shell]# pcs resource create ClusterIP ocf:heartbeat:IPaddr2 \3 |8 `0 n$ m5 j9 {# ~* @2 i
  ip="192.168.10.15" cidr_netmask=32 nic=eth0 op monitor interval=30s ; i9 x0 s: S- k/ i1 C' F& K

( x, C0 H; ?6 H% I3、配置Apache(httpd)! r+ X8 ?5 h- P! k( j
[shell]# pcs resource create WebServer ocf:heartbeat:apache \
0 M1 z' O9 s, B6 {  httpd="/usr/sbin/httpd" configfile="/etc/httpd/conf/httpd.conf" \2 a# }$ R' E3 r( T* c
  statusurl="http://localhost/server-status" op monitor interval=1min+ b9 F$ X) S5 \9 s, U  c2 o

1 A. R1 I' m5 w( @' @5 }4、配置Nginx
8 N8 t% i& O# C5 x" J [shell]# pcs resource create WebServer ocf:heartbeat:nginx \! [$ ]+ P' o! p* d/ w# i6 O
  httpd="/usr/sbin/nginx" configfile="/etc/nginx/nginx.conf" \/ K) f; f& X5 ~+ r! Z2 T
  statusurl="http://localhost/ngx_status" op monitor interval=30s+ \% v5 d# `+ W* o6 \+ k  N  ~
* ^3 j( ~2 k* |. e. k
5.1、配置FileSystem
, |  }) W5 \9 ~; p2 H) L [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \0 F: p: y! E1 z
  device="/dev/sdb1" directory="/var/www/html" fstype="ext4". M3 i' N7 c, o4 R. s

. O: @3 f6 L; r$ ^ [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
* H* g+ n! @- {( v1 s7 F( r  device="-U 32937d65eb" directory="/var/www/html" fstype="ext4"
  Z" `" I+ `: T# n$ o) {5 }" @6 G6 D* s- U
5.2、配置FileSystem-NFS
6 R* _4 r. |9 A; _ [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
% L* B5 |7 ?# A  device="192.168.10.18:/mysqldata" directory="/var/lib/mysql" fstype="nfs" \  q: u* L' Z. [3 u& i, b
  options="-o username=your_name,password=your_password" \
% q" G7 D6 i. i2 _0 f  op start timeout=60s op stop timeout=60s op monitor interval=20s timeout=60s
2 j" N6 T" {1 X2 i7 H" F' B7 g* _; Y. D6 ]
6、配置Iscsi
! O  N0 M7 r+ F* N' Q) g5 Y( x. ]- [ [shell]# pcs resource create WebData ocf:heartbeat:iscsi \! @5 D9 ^8 C. D) B
  portal="192.168.10.18" target="iqn.2008-08.com.starwindsoftware:" \* D2 L1 ~+ ^- {8 R! S3 f" w" R
  op monitor depth="0" timeout="30" interval="120"
' \& i+ J) S/ y; L, y  G+ }1 R6 j- e$ d5 a4 ]' F1 d
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
% X8 `. |/ u! E' t9 c  d3 |4 Q  device="-U 32937d65eb" directory="/var/www/html" fstype="ext4" options="_netdev"
/ e+ Y, l7 @  P
) X8 e& n8 U: N- A% h0 s7、配置DRBD% [4 Q: C0 `3 y# y6 Y; Q2 G
[shell]# pcs resource create WebData ocf:linbit:drbd \
, @+ g7 J7 H6 O) E0 d, i  drbd_resource=wwwdata op monitor interval=60s6 H1 _  T- B$ k7 B5 P
: ?1 ]9 q& m7 A* [' C1 G3 n9 v
[shell]# pcs resource master WebDataClone WebData \# S6 g/ e! o9 ]% Z
  master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true; j3 B  G0 Y& [& j7 }, ]( b) F

. A: ~4 Q7 H; t" \$ b0 u! [: \ [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
: v" G( M2 k1 K' c& }- q, v  device="/dev/drbd1" directory="/var/www/html" fstype="ext4"
* f& c* r! K  U4 B* E( H/ ~& h2 Z+ u
8、配置MySQL9 S* U% p: A$ ?+ T& u+ C/ i
[shell]# pcs resource create MySQL ocf:heartbeat:mysql \
( c# x0 X3 @% l; L  binary="/usr/bin/mysqld_safe" config="/etc/my.cnf" datadir="/var/lib/mysql" \
% d8 o5 O1 k. c) u( w- T  pid="/var/run/mysqld/mysql.pid" socket="/tmp/mysql.sock" \
- x& E& I2 ?5 {. E  op start timeout=180s op stop timeout=180s op monitor interval=20s timeout=60s
, H( H6 [* Q8 [. e4 O% f2 S% K9 x$ ?5 H
9、配置Pingd,检测节点与目标的连接有效性- s1 n* V2 m9 O' t8 U- B
[shell]# pcs resource create PingCheck ocf:heartbeat:pingd \& f' X- u- Q' T; a" j
  dampen=5s multiplier=100 host_list="192.168.10.1 router" \9 r8 Z% o! A& ^% H- e& u# T
  op monitor interval=30s timeout=10s; p: A( b6 E6 j" v" c
4 s7 z1 r) L2 x2 \% e  J% G' h. x
10、创建资源clone,克隆的资源会在全部节点启动
/ t9 j; O# c4 D0 E; a, C' x [shell]# pcs resource clone PingCheck
) |9 D% W, c+ K4 j. C% D) G [shell]# pcs resource clone ClusterIP clone-max=2 clone-node-max=2 globally-unique=true            ## clone-max=2,数据包分成2路
$ {+ Q1 @. v& y+ \  u [shell]# pcs resource update ClusterIP clusterip_hash=sourceip            ## 指定响应请求的分配策略为:sourceip/ U) r3 O& e5 [, s! A& W/ _, x" d

) G: D" k4 d1 R( e% B2 A; C' c: o6 s
8 J- \( ?: v6 [* M$ J0 U: ]& w" n5 r  @: O! u
三、调整群集资源0 F! \' Z1 W6 ~
8 n7 J) n: I7 @+ b
1、配置资源约束
/ \) W" _+ Q% x& @0 [9 Q7 y1 b0 H! ^6 b [shell]# pcs resource group add WebSrvs ClusterIP                            ## 配置资源组,组中资源会在同一节点运行
3 I8 ?+ j/ I' a6 t# g/ ~% b  b [shell]# pcs resource group remove WebSrvs ClusterIP                    ## 移除组中的指定资源7 K$ b/ j3 n: N* C
[shell]# pcs resource master WebDataClone WebData                          ## 配置具有多个状态的资源,如 DRBD master/slave状态
* _# Q, r; b. K& P# T [shell]# pcs constraint colocation add WebServer ClusterIP INFINITY          ## 配置资源捆绑关系/ J; E8 _5 N7 y. S1 @% f
[shell]# pcs constraint colocation remove WebServer                      ## 移除资源捆绑关系约束中资源0 r& W: ~8 k! i* h. `
[shell]# pcs constraint order ClusterIP then WebServer                   ## 配置资源启动顺序
. I* U, P. c' l9 I4 I0 {  h [shell]# pcs constraint order remove ClusterIP                             ## 移除资源启动顺序约束中资源
; K& O) [; ]7 A0 r4 ~4 r: ^/ E1 }. w [shell]# pcs constraint                                                  ## 查看资源约束关系, pcs constraint --full+ O0 E- d4 R* p8 |- t5 g/ I

* N. c% Z- E! b! Q1 E2、配置资源位置1 c( K& s6 V0 n$ ]- F
[shell]# pcs constraint location WebServer prefers node11                 ## 指定资源默认某个节点,node=50 指定增加的 score
' ]: t% i1 B4 v$ ^ [shell]# pcs constraint location WebServer avoids node11                ## 指定资源避开某个节点,node=50 指定减少的 score
$ s1 q2 I. u, u! I4 n [shell]# pcs constraint location remove location-WebServer                ## 移除资源节点位置约束中资源ID,可用pcs config获取
+ f  Z7 C% G4 F0 P [shell]# pcs constraint location WebServer prefers node11=INFINITY           ## 手工移动资源节点,指定节点资源的 score of INFINITY
$ C3 v0 ?0 S$ A5 ]+ @1 H [shell]# crm_simulate -sL                                                    ## 验证节点资源 score 值( Y& n) K* a0 m& W; k; t, x2 H
: F' _9 _! q: f+ B7 V
3、修改资源配置
5 J$ d, L' G% h$ R [shell]# pcs resource update WebFS                                            ## 更新资源配置
+ A  F2 J( z0 {5 w [shell]# pcs resource delete WebFS                                            ## 删除指定资源" O# s9 i( G# u8 b

$ \& C& H- ]  N9 ], ^7 c* ~6 a% w4、管理群集资源
# a, P1 b- d4 L. \, |# l [shell]# pcs resource disable ClusterIP                                    ## 禁用资源. Q2 K9 j7 @; W3 ]& R
[shell]# pcs resource enable ClusterIP                                    ## 启用资源9 \5 \2 ~! M0 ?0 Y0 e3 Y5 L7 x6 g7 ]
[shell]# pcs resource failcount show ClusterIP                          ## 显示指定资源的错误计数
. @% ?# _) t) U8 C, V [shell]# pcs resource failcount reset ClusterIP                         ## 清除指定资源的错误计数 9 Y, i3 `- ^( u/ z& y) l$ f
[shell]# pcs resource cleanup ClusterIP                                ## 清除指定资源的状态与错误计数
, W( Y& N& h% f. u
' t- k% q6 g% f5 d  v# i7 a9 b$ ~7 z( j

8 `" m* t$ Q4 D- Y0 D6 I4 ~, o1 V2 w7 h" ?6 h
四、配置Fencing设备,启用STONITH+ V! R. B3 f  d9 s
0 H4 F, `, B0 ^1 t% b
1、查询Fence设备资源
- n1 O9 P& Z3 z" { [shell]# pcs stonith list                                                   ## 查看支持Fence列表
1 _5 e6 o3 `: l# O& }4 I* k: H [shell]# pcs stonith describe agent_name                                  ## 查看Fence资源使用参数,pcs stonith describe fence_vmware_soap
* e) d6 J, K& ?; ]9 B# W0 Q       
' [5 y, Y2 @0 u" K9 y- Z2、配置fence设备资源
2 X3 Q9 o! i( G& s [shell]# pcs stonith create ipmi-fencing fence_ipmilan \
; l4 r3 u, m9 k. p7 ]% U; L) }$ T/ q  pcmk_host_list="pcmk-1 pcmk-2" ipaddr="10.0.0.1" login=testuser passwd=acd123 \
5 E* F# b$ j- p) x  e* N2 j  op monitor interval=60s: w2 @9 A# n7 I4 d
; g' x- ]2 u+ {* h" ~* Y
mark:
) x0 ]8 h6 m/ a( S  @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.
* h( Q2 D7 K7 y; }3 RIf 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.
5 q2 I9 M/ ?2 @) M* j0 I% K$ pIf 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.
/ S- w! o) g! }2 a8 @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., b: l7 L! m3 `, w. |5 G
example: pcmk_host_argument="uuid" pcmk_host_map="node11:4;node12:5;node13:6" pcmk_host_list="node11,node12"  pcmk_host_check="static-list"5 n- u# B) P9 c. u/ ^$ h6 ]" [
( N  Q' A- i" J' e
3、配置VMWARE (fence_vmware_soap)
. P8 W$ ~$ w  B 特别说明:本次实例中使用了第3项(pcs stonith create vmware-fencing fence_vmware_soap)这个指定pcmk配置参数才能正常执行Fencing动作。
: x% B) ^. ~3 \- n3 _. l/ x% N# A/ S* Y7 A8 @
3.1、确认vmware虚拟机的状态:  F2 {6 o3 \- S( ]* K3 i
[shell]# fence_vmware_soap -o list -a vcenter.example.com -l cluster-admin -p <password> -z                          ## 获取虚拟机UUID5 h* a! |  q5 h9 g3 j" w
[shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -U <UUID>         ## 查看状态
  D9 k' k- q7 Z9 B# s [shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -n <vm name>
" \1 _: V4 z& B: a" L9 K6 x. i
8 `! Y' K7 y+ G" b; n# z& T3.2、配置fence_vmware_soap: e- b0 I+ K* L
[shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \
4 s5 k+ A. b0 i5 _- v  action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \
, @; E: Y9 t+ Z+ T) y% d  port="node11" shell_timeout=60s login_timeout=60s op monitor interval=90s
! N3 n% e  e0 m- m+ r: O0 ~7 M) O  P& `
[shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \: P& X0 u5 E7 D! A3 a1 ]
  action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \
2 t3 v8 p; s& e  uuid="421dec5f-c484-3d69-ddfb-65af46530581" shell_timeout=60s login_timeout=60s op monitor interval=90s
/ t( q2 o7 n+ z' [
* y, }5 p4 C) d [shell]# pcs stonith create vmware-fencing fence_vmware_soap \
, j  `5 L" g3 Q4 ^8 Q  action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \
! u: v, c3 L% G5 P  pcmk_host_argument="uuid" pcmk_host_check="static-list" pcmk_host_list="node11,node12" \
" I& [% G0 x9 l! e) m1 K7 ^* R  pcmk_host_map="node11:421dec5f-c484-3d69-ddfb-65af46530581;node12:421dec5f-c484-3d69-ddfb-65af46530582" \. ]+ w+ t9 D4 S: j2 l3 ?
  shell_timeout=60s login_timeout=60s op monitor interval=90s# [. _, A6 N( S5 [. v7 ?

1 E4 W, {; d) z8 g, j8 m1 M注:如果配置fence_vmware_soap设备时用port=vm name在测试时不能识别,则使用uuid=vm uuid代替;2 D5 \9 x7 B! M  Z4 A, Q
建议使用 pcmk_host_argument、pcmk_host_map、pcmk_host_check、pcmk_host_list 参数指明节点与设备端口关系,格式:- T8 b5 g* 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"
; g1 m1 P$ ^) W* b
: w5 D0 w  m$ U% l/ @: n( S4、配置SCSI
4 _9 n1 L# h' J! L [shell]# ls /dev/disk/by-id/wwn-*                            ## 获取Fencing磁盘UUID号,磁盘须未格式化
6 C% a+ @5 ?/ F) T [shell]# pcs stonith create iscsi-fencing fence_scsi \8 U0 @8 n6 g1 n" u
  action="reboot" devices="/dev/disk/by-id/wwn-0x600e002" meta provides=unfencing
9 B6 S  x; u5 e" \( L; F0 x
, V# }5 p; y% @& B8 v3 h$ b5、配置DELL DRAC
2 L2 [; S4 E, N! g [shell]# pcs stonith create dell-fencing-node11 fence_drac- S2 k5 N: Y# P
.....
! r8 c) g5 }  G, w5 D* {+ X
& w6 r0 N; G$ w# c5 E% e. H' z6 U" a! y
6、管理 STONITH
; Z" M. P3 S% t' y$ v [shell]# pcs resource clone vmware-fencing                    ## clone stonith资源,供多节点启动
; `9 H0 Y' }7 }# e  Z1 ?1 ?: w* M) D [shell]# pcs property set stonith-enabled=true          ## 启用 stonith 组件功能8 f) [; N; B% F. T6 B3 [) p- Z
[shell]# pcs stonith cleanup vmware-fencing                ## 清除Fence资源的状态与错误计数
& P6 z, w2 ?, t' {4 W [shell]# pcs stonith fence node11                             ## fencing指定节点
( d1 I2 Q& K  p( m
( m4 H9 Q+ h5 O. X1 [  J7 }$ \6 z4 T; O

+ N. R, S, o8 s) U* A# \. @0 N8 M& m' E5 m) H" V
五、群集操作命令- A- T1 Z  k4 o9 F

& K% p& ?. r' {% i; q5 F1、验证群集安装
5 X: s2 y/ p- x$ D+ d [shell]# pacemakerd -F                                    ## 查看pacemaker组件,ps axf | grep pacemaker
; d4 b, B' I8 U [shell]# corosync-cfgtool -s                                  ## 查看corosync序号
* Y1 }: B! l8 @8 d; K$ f. ~; W [shell]# corosync-cmapctl | grep members                  ## corosync 2.3.x
( G% s! ~/ g1 A2 G3 Q% y [shell]# corosync-objctl | grep members                  ## corosync 1.4.x
% D* d% {& c/ a% c: M0 ]% s2 z: _5 c# K/ P+ z6 `' j# B
2、查看群集资源* p  B3 q" t- r  `- _& B$ e; F
[shell]# pcs resource standards                          ## 查看支持资源类型
8 {8 b0 ~/ N' b# }  O+ a# } [shell]# pcs resource providers                          ## 查看资源提供商
+ M$ p& ~9 A) J* y3 K [shell]# pcs resource agents                                ## 查看所有资源代理
+ m  X1 ?- s4 m! _, t) @, T9 t# N [shell]# pcs resource list                                 ## 查看支持资源列表
* Q# c! E2 M6 X8 Y8 g [shell]# pcs stonith list                                ## 查看支持Fence列表9 F# ]2 ^2 x0 W8 s; a
[shell]# pcs property list --all                        ## 显示群集默认变量参数; ]0 L7 F$ G, z# G1 A
[shell]# crm_simulate -sL                                    ## 检验资源 score 值
( Z$ \& i2 w: S- `5 c5 ~: X- G
4 s# f, x  g0 x" _6 n6 R6 W4 M3、使用群集脚本* p5 a( c( [' z  I! d) p0 F
[shell]# pcs cluster cib ra_cfg                            ## 将群集资源配置信息保存在指定文件
1 H, H( x/ O- C! J+ ~ [shell]# pcs -f ra_cfg resource create                    ## 创建群集资源并保存在指定文件中(而非保存在运行配置)
; |3 s! q. S( b- ^- k0 { [shell]# pcs -f ra_cfg resource show                          ## 显示指定文件的配置信息,检查无误后6 |6 {' S6 ?, c2 O3 n3 f& w7 }
[shell]# pcs cluster cib-push ra_cfg                          ## 将指定配置文件加载到运行配置中# V# K, V  i  B; u0 P- C
+ K+ `$ z/ W8 ?- j- n  f+ z+ e. Z5 f
4、STONITH 设备操作
3 r: {7 c' e) s# p* k& j [shell]# stonith_admin -I                                    ## 查询fence设备
8 G" h* g+ y, n. } [shell]# stonith_admin -M -a agent_name                   ## 查询fence设备的元数据,stonith_admin -M -a fence_vmware_soap
, o- K6 S2 [, O+ ~9 E3 I [shell]# stonith_admin --reboot nodename                    ## 测试 STONITH 设备
6 C5 r' `" \8 m- x! k) w( n& U3 X& F/ W2 s1 h
5、查看群集配置  j& m0 T+ ]: @% w* m# ~
[shell]# crm_verify -L -V                                    ## 检查配置有无错误! s. q/ I7 ]  B" s
[shell]# pcs property                                    ## 查看群集属性' P( @! |8 A# |( ^# B! c
[shell]# pcs stonith                                    ## 查看stonith3 m& N4 O+ F$ E% \7 p. L0 Y
[shell]# pcs constraint                                    ## 查看资源约束) m# h& G) a1 J' z! y
[shell]# pcs config                                    ## 查看群集资源配置
: l/ z# h  x: q9 m$ T) |+ H* n* a [shell]# pcs cluster cib                                    ## 以XML格式显示群集配置8 M; u' O* [( r3 ~
# A+ K* o+ a9 H, n( J$ Y% {
6、管理群集
$ ~3 I3 _' h# y4 y [shell]# pcs status                                          ## 查看群集状态
. y% A: T. _2 T+ p [shell]# pcs status cluster
$ b* M. D' Z+ S' U6 f/ E [shell]# pcs status corosync- n5 K6 G; T% C' a' ]& J( f+ q
[shell]# pcs cluster stop [node11]                          ## 停止群集
4 ^5 r& T- G+ x* a" `& y [shell]# pcs cluster start --all                            ## 启动群集
1 I) O/ o* z3 E4 S! g5 W9 i0 f [shell]# pcs cluster standby node11                          ## 将节点置为后备standby状态,pcs cluster unstandby node11
5 j! g# }+ h6 h2 E [shell]# pcs cluster destroy [--all]                          ## 删除群集,[--all]同时恢复corosync.conf文件/ C  u  N  ~+ D, |+ N  X# @
[shell]# pcs resource cleanup ClusterIP                ## 清除指定资源的状态与错误计数
  R, F% t( s: G& Q [shell]# pcs stonith cleanup vmware-fencing                ## 清除Fence资源的状态与错误计数8 s* ?6 N! O1 x  Q+ o+ U

: I9 D- d4 I$ D- M7 x! R/ j
/ _5 ]/ j0 H, C3 r
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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