易陆发现互联网技术论坛

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

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

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

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

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

x
使用pcs shell配置corosync & pacemaker群集
# Q2 l, A  H# G! q; S/ {, C. `: `4 h+ C7 k

  f* ~' a* v6 l/ B& MPacemaker
' S$ r4 h! B2 l: y/ v% OPacemaker,即Cluster Resource Manager(CRM),管理整个HA,客户端通过pacemaker管理监控整个集群。
) f: l( o  y" Y, ?- j5 j8 w
3 H0 N/ h4 p9 ~# k8 l# ICRM支持ocf和lsb两种资源类型:
8 E0 `1 y  u# X. B' }+ w# f5 r# D9 D8 q+ V4 Q' v% l9 C
ocf格式的启动脚本在/usr/lib/ocf/resource.d/下面。
  e  S8 a0 G' Jlsb的脚本一般在/etc/rc.d/init.d/下面。
: ^: w6 p$ @9 r/ P1 v7 U) f: r" h: p& ~" @' f

" k, j! _& ]. J! `/ J* C8 b1 U( N7 S8 U
1、常用的集群管理工具:
4 x& V# J* g* r. s% F(1)基于命令行
3 s0 I" G& u+ Ocrm shell/pcs- }0 P+ l1 i2 j7 v- y) a

0 T( r1 z' {% s, o( C) I(2)基于图形化1 z; k* V$ U$ p/ h" a
pygui/hawk/lcmc/pcs% n- T( {3 L: v2 y- V
2 a/ }9 q7 {1 b" w. T+ V

! Z. K7 u" z# D- d' a2、相关的资源文件:
% O* V8 J" Y6 i4 ?4 D0 Y+ B7 j* G(1)/usr/lib/ocf/resource.d,pacemaker资源库文件位置,可安装资源包:resource-agents 获取更多ocf格式的资源。) P6 p0 l( ?# W8 s- I2 S$ C% o
(2)/usr/sbin/fence_***,Fencing设备的执行脚本名称,可安装资源包:fence-agents 获取更多Fencing设备资源。
$ w4 b( x1 U. g8 K0 Q# j# K
  T# i8 e$ t. z3、查看使用说明:
$ V8 q* [2 C2 B! N. r1 ] [shell]# man ocf_heartbeat_***          ## 查看OCF资源说明,man ocf_heartbeat_apache3 y! J7 _7 D5 T! R
[shell]# man fence_***                  ## 查看Fencing设备说明,man fence_vmware. T& z' o( n" f8 y) v# _

4 d5 z1 G$ Q6 n4 |' z4、参考文档
) k& {. X" j) Y, @9 [6 phttps://github.com/ClusterLabs
* e% F: U* H8 _, \http://clusterlabs.org/doc/3 N/ _3 {+ i; m1 k6 X
http://www.linux-ha.org/doc/man-pages/man-pages.html; m9 T5 S5 x- ^1 s# a
https://access.redhat.com/docume ... acemaker/index.html
' u( C/ x# c" l% {+ q
$ F  I9 x% w( j- f在群集配置过程中参考了互联网上众多优秀文章,在此感谢原作者!!!6 F2 t4 M' Q( h/ y5 D, i* ^

2 q6 |. ?5 I2 H3 m; A3 q7 y以下记录整理了在vmware esxi5.5 + centos6.6环境中使用PCS命令配置corosync & pacemaker群集的一些操作,由于本人水平有限,仅供参考:1 I8 D/ N) J/ j# i. o' T: v9 ^# r; D
) @6 e( z( C9 C) I% p
--------------------------------------------------
  P3 e  P. O* f9 @3 l7 L5 v  H; |$ J, V; e9 m: G1 q( p

$ ]7 f1 s3 A  h3 t( n/ a( w7 b1.安装群集软件:* G# _& ?  e0 q  U% L4 H0 _
[shell]# yum -y install corosync pacemaker pcs
1 }9 G5 p" K' k3 J1 k8 p; d% x3 ]; |' j5 L [shell]# yum -y install fence-agents resource-agents
$ l3 ]5 X$ S+ Q' E
6 B2 m9 x9 K0 e7 R1 u2.拷贝配置文件、启动脚本( U# x7 o3 j# \$ t8 R) b
[shell]# mkdir -p /etc/cluster/
  d8 D( _6 R& C  u2 A" h [shell]# ln -s /etc/rc.d/init.d/corosync /etc/rc.d/init.d/cman
% |" l1 W: G3 \ [shell]# ln -s /usr/sbin/corosync-cmapctl /usr/sbin/corosync-objctl/ l: U$ H' t' v1 e
[shell]# cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf3 _7 V; s4 u+ ?6 C/ Y; k. V

$ [6 l- o* y" h; j! m3 G. e# {% z: \9 K2 {
注意:群集需要严格的时间同步机制,如果启用了防火墙需要开放相应的端口。8 l% g0 l& E+ N3 L
& G1 H& O. I6 I# |( l, y
--------------------------------------------------' j" h! p& `* t3 x& e

" ?, {, f' g! k( C& Y2 {PCS(Pacemaker/Corosync configuration system)命令配置群集示例:9 V1 ^, R7 |- a) s1 U; Y
4 ]# m* q/ [; e

8 D9 h5 j+ N5 `9 j9 H" J一、建立群集:
: ^' A& E; [' M; L0 [- U: v0 n
( N7 k" ^, Y+ K- i  Y1、配置群集节点的认证as the hacluster user:% |. o) H+ s; @% ^& w! \, x
[shell]# pcs cluster auth node11 node125 P& D6 z1 t9 b( e

/ O% [3 a1 ~4 ~" T# z2、创建一个二个节点的群集
" l0 l0 J" u$ ~ [shell]# pcs cluster setup --name mycluster node11 node12
+ q- {: p& o' ~+ V- } [shell]# pcs cluster start --all                                  ## 启动群集
- {3 B6 n$ h+ ]$ Q0 l1 {
$ P9 o( H# ]6 c& I: o# }) B3、设置资源默认粘性(防止资源回切)+ O6 R  h' \; O7 P9 J
[shell]# pcs resource defaults resource-stickiness=1006 m% [. `. j/ D) Q6 |7 t5 J
[shell]# pcs resource defaults
( A3 b5 {1 m6 k8 D3 `0 F
+ {1 K* e& E3 i/ ~% c) X4、设置资源超时时间
% ~* ?, V) M  d% v" ?" s [shell]# pcs resource op defaults timeout=90s
, |8 [. Y7 N& K$ b( T. N7 R' w2 h [shell]# pcs resource op defaults
& d, b6 C: g% u) H
& I" k" B( e7 i2 R( m5、二个节点时,忽略节点quorum功能
6 V! T7 y/ a3 S' A" V [shell]# pcs property set no-quorum-policy=ignore
5 k  q; G/ M3 F/ r
% G8 V7 i% i; Q3 q$ ?6、没有 Fencing设备时,禁用STONITH 组件功能; U2 ?/ k  i. |% l* ?6 k1 @
在 stonith-enabled="false" 的情况下,分布式锁管理器 (DLM) 等资源以及依赖DLM 的所有服务(例如 cLVM2、GFS2 和 OCFS2)都将无法启动。* q& `" u. K: o# L3 ]
[shell]# pcs property set stonith-enabled=false" O7 I* N8 H! p; K' ^+ A
[shell]# crm_verify -L -V                                            ## 验证群集配置信息
: \: i# X9 t9 X3 h( x+ i( b- w

. R+ W- `: m1 _5 s5 E/ t$ z4 {# c$ p0 ^# A, T
二、建立群集资源' Y, S6 x+ i) \3 Z- n
' r( G; |$ ]5 A6 v
1、查看可用资源
2 Q6 ^2 E# N; W3 D. I/ R+ v) i3 o! C [shell]# pcs resource list                                         ## 查看支持资源列表,pcs resource list ocf:heartbeat0 F9 }4 @9 \% j/ ~4 t" p
[shell]# pcs resource describe agent_name                          ## 查看资源使用参数,pcs resource describe ocf:heartbeat:IPaddr2
/ {& S$ Z& X' j( t2 q; t4 S$ r8 Z. F, d" e. t
2、配置虚拟IP
7 ]5 `* E* b: s) }& } [shell]# pcs resource create ClusterIP ocf:heartbeat:IPaddr2 \( O1 [3 q6 j) a
  ip="192.168.10.15" cidr_netmask=32 nic=eth0 op monitor interval=30s
6 V4 C, Y8 ?, p: e# {& k  G" X4 o: U7 `  ^
3、配置Apache(httpd)# i; n' T! z8 V
[shell]# pcs resource create WebServer ocf:heartbeat:apache \. y) s7 U2 f, Y9 W& b
  httpd="/usr/sbin/httpd" configfile="/etc/httpd/conf/httpd.conf" \1 a, ]. l! [5 i$ P. H7 Z
  statusurl="http://localhost/server-status" op monitor interval=1min: L1 X' H; c" f$ l/ W

4 N* w; Q% B8 O. M4、配置Nginx4 ?! K+ J8 ]$ z+ x2 j: X2 U
[shell]# pcs resource create WebServer ocf:heartbeat:nginx \
3 }6 D9 _5 `) m5 ]' x7 a" c  httpd="/usr/sbin/nginx" configfile="/etc/nginx/nginx.conf" \
8 X0 f/ U3 J" o2 B: _  statusurl="http://localhost/ngx_status" op monitor interval=30s
9 z' H: w2 e! k) x% e0 E# e. [& z: Y
5.1、配置FileSystem
  j9 W% E% t) j9 _* `1 ? [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
$ w, l8 E) a4 ~7 O1 }. N  device="/dev/sdb1" directory="/var/www/html" fstype="ext4"
" _" O. c# S% t! l
; X, a; l+ g+ f# W/ D5 s6 F, f% o9 z [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
- l% p( c: p# T( Z( i4 O/ `% f  device="-U 32937d65eb" directory="/var/www/html" fstype="ext4"- U2 [9 Y* V9 U" j4 n% P' w/ Q

+ s5 I8 l% h' W. f% ?5.2、配置FileSystem-NFS
* S. x6 P1 n2 w7 B$ H5 A; i& H. f: f+ s [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
  F8 I9 A, q" c+ I4 \  device="192.168.10.18:/mysqldata" directory="/var/lib/mysql" fstype="nfs" \
, O: \/ ~, a9 i( D8 W  options="-o username=your_name,password=your_password" \
! D7 o2 m, P! ?5 |" b: `# B  op start timeout=60s op stop timeout=60s op monitor interval=20s timeout=60s$ b1 T9 B' G1 B' F/ g3 s8 f% V
5 ]; ]+ S. X0 G! {
6、配置Iscsi
, l# U8 S0 H9 I% d! | [shell]# pcs resource create WebData ocf:heartbeat:iscsi \
# k$ g7 F+ p% a  a3 e, \  portal="192.168.10.18" target="iqn.2008-08.com.starwindsoftware:" \0 A4 Y2 c  F! A" F
  op monitor depth="0" timeout="30" interval="120"
( A9 B5 i# n( }1 p
/ r! B% s" J; \4 p; @! _' O [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \1 q  H6 ^- z( M2 ]- b) b4 M5 F
  device="-U 32937d65eb" directory="/var/www/html" fstype="ext4" options="_netdev"" g5 q" m& u2 y) R' C
* p+ O& Z0 }3 I9 U8 U8 v
7、配置DRBD3 O0 q# C* K# ?( m6 n" b
[shell]# pcs resource create WebData ocf:linbit:drbd \. ], \0 d8 E2 W, I7 Q
  drbd_resource=wwwdata op monitor interval=60s+ j8 \" t+ X3 i

' P8 r) s4 l& P' Z7 V  @: ]5 | [shell]# pcs resource master WebDataClone WebData \7 l2 L+ I% Q+ E& j/ r! Q
  master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true
2 H8 z+ x" `. S# m; {$ v" y
, ?' a( [) S/ k  f [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
8 ^3 O7 y* J3 R: w  device="/dev/drbd1" directory="/var/www/html" fstype="ext4"
2 _0 D" ~* b  Z2 v. e8 ?- `" R, U# `- p( H+ W
8、配置MySQL
* p& T  j. b, V [shell]# pcs resource create MySQL ocf:heartbeat:mysql \
! N- _) Q/ n( P$ ?/ Z5 p! O3 r% G) G  binary="/usr/bin/mysqld_safe" config="/etc/my.cnf" datadir="/var/lib/mysql" \
2 J2 b# ^1 t  i1 P  t  w! i  pid="/var/run/mysqld/mysql.pid" socket="/tmp/mysql.sock" \( W6 z" U5 n" \" q0 _
  op start timeout=180s op stop timeout=180s op monitor interval=20s timeout=60s
4 d8 a% ?0 k2 Y- c0 ^' Z8 q* X% h8 b% n0 U1 ?% y
9、配置Pingd,检测节点与目标的连接有效性  R9 Z; e) @4 m5 I6 ?7 I4 f6 s' @8 Q
[shell]# pcs resource create PingCheck ocf:heartbeat:pingd \2 {2 V/ y, x( u# Y( {
  dampen=5s multiplier=100 host_list="192.168.10.1 router" \
9 M- l, t1 V$ G  op monitor interval=30s timeout=10s' U; `) b5 t% X8 _) b
3 ]6 t+ }2 K0 i
10、创建资源clone,克隆的资源会在全部节点启动. t" m- v* b, T
[shell]# pcs resource clone PingCheck
) ^- e& N1 Q% W1 z/ s [shell]# pcs resource clone ClusterIP clone-max=2 clone-node-max=2 globally-unique=true            ## clone-max=2,数据包分成2路" x5 L1 x- h3 Q/ r
[shell]# pcs resource update ClusterIP clusterip_hash=sourceip            ## 指定响应请求的分配策略为:sourceip
/ X0 A0 d% i0 q. W; ^$ a
  B" f5 k9 h. r4 C% ~3 X+ [
( r4 L, k5 V" b2 G* F2 ]" j4 T8 j! W9 k  }6 u$ S) W; J) u
三、调整群集资源' ~: J" f" N, G9 S  S1 [
6 @, g: t% Y* ]& r8 w' ?6 i# ?. h
1、配置资源约束
& B% ?& p) I# C- R; W9 e [shell]# pcs resource group add WebSrvs ClusterIP                            ## 配置资源组,组中资源会在同一节点运行
  U& S4 M( L2 e/ `9 M' e% F [shell]# pcs resource group remove WebSrvs ClusterIP                    ## 移除组中的指定资源
6 ^* ^& O& ^# A% N, W$ B: X0 Z4 { [shell]# pcs resource master WebDataClone WebData                          ## 配置具有多个状态的资源,如 DRBD master/slave状态3 f8 ~; [+ P  [: [, N
[shell]# pcs constraint colocation add WebServer ClusterIP INFINITY          ## 配置资源捆绑关系
+ t( u7 g; k5 o& f% F/ K [shell]# pcs constraint colocation remove WebServer                      ## 移除资源捆绑关系约束中资源
1 H/ H' Q% j: W9 }8 g [shell]# pcs constraint order ClusterIP then WebServer                   ## 配置资源启动顺序: W5 L) C5 d" t8 A' y
[shell]# pcs constraint order remove ClusterIP                             ## 移除资源启动顺序约束中资源2 ?+ L. ?5 l1 P0 y
[shell]# pcs constraint                                                  ## 查看资源约束关系, pcs constraint --full1 Z/ c8 q; Q* c4 o: A

# ~6 j. i/ F# h' y, \5 f" d2、配置资源位置
9 s& v$ Y1 B7 a [shell]# pcs constraint location WebServer prefers node11                 ## 指定资源默认某个节点,node=50 指定增加的 score
/ e% ?. M# ~' o% N7 K7 i& D [shell]# pcs constraint location WebServer avoids node11                ## 指定资源避开某个节点,node=50 指定减少的 score5 _' w+ e  Q9 Y$ p8 {
[shell]# pcs constraint location remove location-WebServer                ## 移除资源节点位置约束中资源ID,可用pcs config获取. w$ r. ~7 C8 a% Q) j2 f
[shell]# pcs constraint location WebServer prefers node11=INFINITY           ## 手工移动资源节点,指定节点资源的 score of INFINITY9 a. W4 ]; u9 K% Q0 D) Y
[shell]# crm_simulate -sL                                                    ## 验证节点资源 score 值
5 l  P/ T0 N2 {6 L, m( b2 ?
8 b% `! z# v4 v. e$ g3、修改资源配置
8 T0 H: C" l8 a1 A [shell]# pcs resource update WebFS                                            ## 更新资源配置7 ~, r7 }, n# y7 H1 Z6 P5 u
[shell]# pcs resource delete WebFS                                            ## 删除指定资源8 t1 ~: X: G  s$ |4 ]

( i( {$ z4 L# h1 w# F: E  j1 C4、管理群集资源' j. n- Y: n0 L' \6 z3 V4 O
[shell]# pcs resource disable ClusterIP                                    ## 禁用资源5 ~" m0 s9 _- D+ Q' Q2 W" ]; _
[shell]# pcs resource enable ClusterIP                                    ## 启用资源
# @! q( x2 }5 E! l. G' t [shell]# pcs resource failcount show ClusterIP                          ## 显示指定资源的错误计数
/ v  X% P. O6 M, H! }& t [shell]# pcs resource failcount reset ClusterIP                         ## 清除指定资源的错误计数 + B1 @2 A2 n$ _+ E2 @7 a' f* D
[shell]# pcs resource cleanup ClusterIP                                ## 清除指定资源的状态与错误计数5 [0 G, \, O/ F7 P( m) q/ t1 [8 I

3 W/ q4 y/ ~7 q/ H; s
3 X" g7 G( [: U) f: R9 L: l4 y, \3 [

: t: S7 l- u2 E; ~% w  V四、配置Fencing设备,启用STONITH' W$ H- ]$ c/ t
4 T8 v- K* {: |5 s
1、查询Fence设备资源$ g; [6 [# {' a2 i
[shell]# pcs stonith list                                                   ## 查看支持Fence列表
+ P+ j6 h" o* H: P [shell]# pcs stonith describe agent_name                                  ## 查看Fence资源使用参数,pcs stonith describe fence_vmware_soap
9 P$ M. U8 a) V, O3 a        ( [4 i9 M3 w1 N( \6 M7 j6 \2 p
2、配置fence设备资源
5 i, a4 U) \; V5 ~$ H [shell]# pcs stonith create ipmi-fencing fence_ipmilan \1 o/ x4 V  ^; }' v- x" Z
  pcmk_host_list="pcmk-1 pcmk-2" ipaddr="10.0.0.1" login=testuser passwd=acd123 \5 e9 C0 w7 v% f6 G/ A( l. T0 m( t
  op monitor interval=60s3 s7 ^( ?+ p2 \$ g" r* v" N

4 G1 M$ ^% R8 |. bmark:" C# K* e5 d) m# J0 L$ m+ ^
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.% i5 [2 X% E. `
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.& Y" Y* p* l7 U9 H7 K
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.3 h+ l! e3 c3 Y/ Q7 F& l
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.
! _7 G+ U& G+ J2 H/ yexample: pcmk_host_argument="uuid" pcmk_host_map="node11:4;node12:5;node13:6" pcmk_host_list="node11,node12"  pcmk_host_check="static-list"
( y9 r3 Y4 ~1 C2 ^: h. C* I' d3 B: x7 n+ V3 |
3、配置VMWARE (fence_vmware_soap)/ @6 v: l) [$ i6 Z! T* F. z- _
特别说明:本次实例中使用了第3项(pcs stonith create vmware-fencing fence_vmware_soap)这个指定pcmk配置参数才能正常执行Fencing动作。
: j: Y" e. k, }
% t1 [" _; F$ e) k0 w# t3.1、确认vmware虚拟机的状态:
/ N0 {5 M0 n  u& O. _  B! Q' X$ a [shell]# fence_vmware_soap -o list -a vcenter.example.com -l cluster-admin -p <password> -z                          ## 获取虚拟机UUID+ W! F: h7 Y# r: V2 i2 Y
[shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -U <UUID>         ## 查看状态
$ `4 Y) t: g9 V% V4 i, A7 f [shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -n <vm name>
7 `/ @! Q) f6 |9 {0 S# L0 m6 m2 p' x# G/ U7 D3 m7 t# Q
3.2、配置fence_vmware_soap
( b6 f" o% M0 p6 n1 ^. P8 \% M [shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \
& T: t3 \+ `" c/ d  action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \
. W: _0 q4 n' e8 X1 u9 r  port="node11" shell_timeout=60s login_timeout=60s op monitor interval=90s
5 w9 l4 t3 f' l; w4 c0 m) Y9 F; X2 R% U# N
[shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \% D. i+ B7 M+ V- B
  action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \- u; |5 j" z+ Z+ W) e' l
  uuid="421dec5f-c484-3d69-ddfb-65af46530581" shell_timeout=60s login_timeout=60s op monitor interval=90s0 S- m/ i, D4 L
, u$ H7 i7 H7 t( S* ?
[shell]# pcs stonith create vmware-fencing fence_vmware_soap \- _+ M6 d3 q0 |2 ?& n4 P; ^
  action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \
8 O! B) _) ]  \# A  pcmk_host_argument="uuid" pcmk_host_check="static-list" pcmk_host_list="node11,node12" \- R/ N5 U5 W; ^3 [% {- l4 H( G4 E( |6 i
  pcmk_host_map="node11:421dec5f-c484-3d69-ddfb-65af46530581;node12:421dec5f-c484-3d69-ddfb-65af46530582" \
3 r2 ]+ a2 ~% h; s! ?  shell_timeout=60s login_timeout=60s op monitor interval=90s0 j/ o, M$ C" k' I5 b  d2 p) F) I

3 ]) v& T, U' b注:如果配置fence_vmware_soap设备时用port=vm name在测试时不能识别,则使用uuid=vm uuid代替;; w! ^% q( d7 k( M0 R+ P
建议使用 pcmk_host_argument、pcmk_host_map、pcmk_host_check、pcmk_host_list 参数指明节点与设备端口关系,格式:, v' A, M7 b0 O5 u
pcmk_host_argument="uuid"  pcmk_host_map="node11:uuid4;node12:uuid5;node13:uuid6"  pcmk_host_list="node11,node12,node13"  pcmk_host_check="static-list"
+ B+ Q5 T$ e" e0 g9 a% Q2 t6 d# G/ Y2 R0 s& c# m
4、配置SCSI( \/ k% S. d- A
[shell]# ls /dev/disk/by-id/wwn-*                            ## 获取Fencing磁盘UUID号,磁盘须未格式化
- b% i3 T  t, n. ] [shell]# pcs stonith create iscsi-fencing fence_scsi \. l1 L2 o; B7 g$ R& l
  action="reboot" devices="/dev/disk/by-id/wwn-0x600e002" meta provides=unfencing
) i, ~9 J" t" k+ D2 {: }! [( Q0 V8 Z0 L! a/ d5 w6 z# j- f. y$ N6 `& ?
5、配置DELL DRAC
( Z& N# l, B) L, S2 S' @* d; _ [shell]# pcs stonith create dell-fencing-node11 fence_drac
1 q9 r: F1 u4 M4 J: [& N/ E  _.....8 q" t# O+ }( k4 T) y4 q

( n7 F3 j6 j2 q' m: v- h' J1 {; m0 b% W+ a/ ~# q! d9 T
6、管理 STONITH6 a+ S+ R' q; [  `! b7 T0 Z% a. F
[shell]# pcs resource clone vmware-fencing                    ## clone stonith资源,供多节点启动
, K. _: v$ M  Q/ \ [shell]# pcs property set stonith-enabled=true          ## 启用 stonith 组件功能0 g/ D# a& `& L& `& q) g; |: [8 M0 V& |
[shell]# pcs stonith cleanup vmware-fencing                ## 清除Fence资源的状态与错误计数
) p6 `0 N3 Y6 ], p" h+ Q [shell]# pcs stonith fence node11                             ## fencing指定节点' Y8 Y+ e9 d# [$ a% B. X
+ i, c; B7 H* v% ?5 ]+ ^
" B8 G, d- N' ^3 z9 M
3 q+ H3 u$ ]4 {# K# B* U% k* I
" v( Z& ^2 j4 F
五、群集操作命令
! p2 N; ~, h9 H0 u$ M
* Z! s' k+ Z) l2 d% \; s1、验证群集安装
+ J& l0 q6 Z7 X  B [shell]# pacemakerd -F                                    ## 查看pacemaker组件,ps axf | grep pacemaker% {: d2 g4 S, e' r6 H0 \
[shell]# corosync-cfgtool -s                                  ## 查看corosync序号
9 T0 W8 ~, @" [, c [shell]# corosync-cmapctl | grep members                  ## corosync 2.3.x& H  S5 u. b& m. \8 V
[shell]# corosync-objctl | grep members                  ## corosync 1.4.x
/ ~- A) `, H" u9 K1 a7 W. M0 P6 `8 n; E6 M# @- r. H* f, p
2、查看群集资源
$ f, A- t4 K, ~- T1 t+ q# v [shell]# pcs resource standards                          ## 查看支持资源类型
8 F+ T: ~0 g1 K& \ [shell]# pcs resource providers                          ## 查看资源提供商% |3 }3 A. r  W+ L8 M5 c' a/ z
[shell]# pcs resource agents                                ## 查看所有资源代理
& E0 h& v! z) z; H0 ?" j( J [shell]# pcs resource list                                 ## 查看支持资源列表
2 `/ L4 a$ d8 E5 R% Z [shell]# pcs stonith list                                ## 查看支持Fence列表
. a* k+ Q5 a- X# a [shell]# pcs property list --all                        ## 显示群集默认变量参数: q& \+ S7 P2 p. y/ \- ?/ ~
[shell]# crm_simulate -sL                                    ## 检验资源 score 值9 }4 U/ `" m3 X
( J/ S/ n& t5 y# B* H2 \) |
3、使用群集脚本
* O4 B' q6 T" \/ | [shell]# pcs cluster cib ra_cfg                            ## 将群集资源配置信息保存在指定文件
+ }0 j& X. r) y8 X [shell]# pcs -f ra_cfg resource create                    ## 创建群集资源并保存在指定文件中(而非保存在运行配置)
6 M( H+ E2 [# F  q [shell]# pcs -f ra_cfg resource show                          ## 显示指定文件的配置信息,检查无误后
  {- T2 M2 D& K! b0 _- G" |6 ? [shell]# pcs cluster cib-push ra_cfg                          ## 将指定配置文件加载到运行配置中
9 N" o% t. h; I, X
( n" _2 v2 c3 n8 y4 k4、STONITH 设备操作" Q& b  c' _+ v4 X& {
[shell]# stonith_admin -I                                    ## 查询fence设备
4 V5 K  I0 |; q& }" b [shell]# stonith_admin -M -a agent_name                   ## 查询fence设备的元数据,stonith_admin -M -a fence_vmware_soap9 s% |; X) _3 |1 _+ i, G' `
[shell]# stonith_admin --reboot nodename                    ## 测试 STONITH 设备
0 H4 @# i6 A/ l( U3 x+ a3 O8 d- s
$ P! n2 N1 Y# W$ U# h5 N* P5、查看群集配置" W; n  P1 i3 q) T! z) ~$ n. T6 i# P0 n
[shell]# crm_verify -L -V                                    ## 检查配置有无错误
1 o! E- e9 C; B$ P8 U [shell]# pcs property                                    ## 查看群集属性
. k# I& N& \/ I+ e [shell]# pcs stonith                                    ## 查看stonith  p( E/ ~3 O6 A5 G) g1 }, ^
[shell]# pcs constraint                                    ## 查看资源约束
1 @1 K5 s3 U- X [shell]# pcs config                                    ## 查看群集资源配置
7 }& ]& P( r( ]) t0 k+ o [shell]# pcs cluster cib                                    ## 以XML格式显示群集配置0 j, y! b) ?  b2 G: d' Z: P

, o* Q/ B8 _. {6、管理群集; T4 h9 l+ W3 a/ F0 `3 k" h! T
[shell]# pcs status                                          ## 查看群集状态
5 V0 Y: `- K; ^/ H2 ^ [shell]# pcs status cluster
5 [1 Y# s) P; F& @! l7 e' j [shell]# pcs status corosync! p$ q% b' E! G
[shell]# pcs cluster stop [node11]                          ## 停止群集
, Y% ^- b  l! u. c% n [shell]# pcs cluster start --all                            ## 启动群集
3 B. S/ f; ^# |: l [shell]# pcs cluster standby node11                          ## 将节点置为后备standby状态,pcs cluster unstandby node11 0 M4 x/ S2 e3 m
[shell]# pcs cluster destroy [--all]                          ## 删除群集,[--all]同时恢复corosync.conf文件, B% i" k/ T* U1 \: C$ ^
[shell]# pcs resource cleanup ClusterIP                ## 清除指定资源的状态与错误计数
' b4 u: r. C; O9 w" R( T5 a  w, c [shell]# pcs stonith cleanup vmware-fencing                ## 清除Fence资源的状态与错误计数5 H. L8 [' R# I$ P8 o2 S

+ K5 v( G3 B, n9 C+ ~2 S) _: [% D+ K& ]
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

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

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

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

GMT+8, 2026-4-8 15:24 , Processed in 0.047237 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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