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

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

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2018-1-6 19:22:20 | 显示全部楼层 |阅读模式
使用pcs shell配置corosync & pacemaker群集
2 J7 [) \$ p: X/ \) M9 i
: \2 H- b. Q  \' U) A  t
% n% `  s+ ]% [9 n1 BPacemaker5 o  ~5 H) ^' _
Pacemaker,即Cluster Resource Manager(CRM),管理整个HA,客户端通过pacemaker管理监控整个集群。/ Z, O& Y3 n7 U( E) `. W7 ^! k, p
$ G* {; r* h% q/ I3 _  i/ s& Q
CRM支持ocf和lsb两种资源类型:5 ]- g  C- _4 b# B9 O
1 G' ~5 c$ @; d2 `; L  @
ocf格式的启动脚本在/usr/lib/ocf/resource.d/下面。
1 I2 }# T9 Q# ]$ ?lsb的脚本一般在/etc/rc.d/init.d/下面。
- b6 N2 {- M# h# Y) x# T# f% z
6 F" P4 a% ]% r0 X8 w) U% B2 p5 S5 z' d- a2 P
0 }$ B8 h0 u5 c* L. c, a
1、常用的集群管理工具:
, i' P7 p5 X0 R. `6 C(1)基于命令行( I: M+ ?& i: }
crm shell/pcs% K* M6 W: T- k; n2 K
& @4 O3 s: t& Y4 S2 z$ X( `$ o
(2)基于图形化
8 \8 V0 f8 y, ]4 V; _9 upygui/hawk/lcmc/pcs
* b* z& e8 W$ i7 W
- W$ F5 U- N4 U+ P
. y. |9 v' {3 T% \* p9 P2、相关的资源文件:
% |' o& d& l4 }7 m+ e(1)/usr/lib/ocf/resource.d,pacemaker资源库文件位置,可安装资源包:resource-agents 获取更多ocf格式的资源。8 W* Q: Y7 ]1 {$ y# U9 k8 v
(2)/usr/sbin/fence_***,Fencing设备的执行脚本名称,可安装资源包:fence-agents 获取更多Fencing设备资源。3 n* V9 q2 d* B" R. w% X. |) a( R$ @- u

7 }$ E  s8 r5 `5 a+ F/ u3、查看使用说明:
% A! o3 H4 ?& C; u [shell]# man ocf_heartbeat_***          ## 查看OCF资源说明,man ocf_heartbeat_apache
+ m8 v, }5 m' i0 |3 B [shell]# man fence_***                  ## 查看Fencing设备说明,man fence_vmware5 T& Y$ r9 o2 C4 N0 D8 D
: C& V% ~- v# {; F* ]% M1 f
4、参考文档, d3 R% a$ J' J* s' ?6 J
https://github.com/ClusterLabs, ], b! G. k. p! k
http://clusterlabs.org/doc/1 `! s  e* `: \  j3 p
http://www.linux-ha.org/doc/man-pages/man-pages.html7 R& L# b; O& Y, ~
https://access.redhat.com/docume ... acemaker/index.html1 B' I; S3 [, L7 {2 N

. u+ u+ g; `, A! o在群集配置过程中参考了互联网上众多优秀文章,在此感谢原作者!!!; m2 f, M2 j$ K! j; `  k9 G
( e$ S* h1 h6 \0 c& g! `2 k
以下记录整理了在vmware esxi5.5 + centos6.6环境中使用PCS命令配置corosync & pacemaker群集的一些操作,由于本人水平有限,仅供参考:; A2 K: F- ?5 M/ _* c
6 ~' b+ f7 d; G) ^8 |' b$ n
--------------------------------------------------. g! w0 @! K1 p, E
5 c( e! a5 N: h% B
; `' ?* `7 W/ i8 s
1.安装群集软件:0 _3 y5 L! W* i/ U4 Q
[shell]# yum -y install corosync pacemaker pcs
9 Q4 b  t# K0 ?/ F [shell]# yum -y install fence-agents resource-agents
5 f2 x* k4 [/ Y! o# x" _
% A! ^: ^: q; y, C5 P2 [2.拷贝配置文件、启动脚本
0 J& h2 T! |. A1 s0 s [shell]# mkdir -p /etc/cluster/# i6 i1 a- d( Q3 T
[shell]# ln -s /etc/rc.d/init.d/corosync /etc/rc.d/init.d/cman
8 b+ c5 j/ b% A! \( v [shell]# ln -s /usr/sbin/corosync-cmapctl /usr/sbin/corosync-objctl# V" [' r" R$ D, C
[shell]# cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf
& H9 v& s$ |8 |( R# H9 k& }  H6 ~' M7 P0 A: g3 E% w

/ S' `) a9 O$ ?7 r注意:群集需要严格的时间同步机制,如果启用了防火墙需要开放相应的端口。# N- ~9 K, W; h
& I0 ?' w8 L- n  |9 E
--------------------------------------------------
, S4 G- Q# \" y: _/ J: w6 {& r& i" c# l; E( a. K
PCS(Pacemaker/Corosync configuration system)命令配置群集示例:
( [) h* `/ X% v2 s; L
4 _( g* `: ?; X: b6 P- z, i
( ^% n! V# L: S3 o, x* X, z一、建立群集:: C5 V) [2 M* l4 X9 v, q; B

- L/ y7 p  s5 F" }0 N$ G% p1、配置群集节点的认证as the hacluster user:
$ `5 S, N; v( l7 |4 r* ~ [shell]# pcs cluster auth node11 node12" B2 A6 P: B2 W
1 V' v6 M) J8 {
2、创建一个二个节点的群集
% r" W, B! p4 a+ D [shell]# pcs cluster setup --name mycluster node11 node12% Z+ H" Z! e3 ?( j: f
[shell]# pcs cluster start --all                                  ## 启动群集5 c7 C# N2 T" j! m

( Q4 I4 {  Q" U! U! u2 W( B3、设置资源默认粘性(防止资源回切)
, r) {3 d7 ~/ x0 k0 k [shell]# pcs resource defaults resource-stickiness=100* r8 b! v! s& c' K
[shell]# pcs resource defaults
1 q' J5 F6 ~  O. e+ l
4 s0 @2 f7 _' I: m4 G+ h* w- g4、设置资源超时时间
+ q9 {" N1 t; a- w% N6 D [shell]# pcs resource op defaults timeout=90s
" h; l, x2 ?* z, i( T" h- o* J' ]  u) P [shell]# pcs resource op defaults
0 w: v6 J, F' [$ e- A6 n) u) l* n2 c; y+ @7 T) w  y( T
5、二个节点时,忽略节点quorum功能
  S9 I2 Z7 Q8 _! d5 m3 U6 T [shell]# pcs property set no-quorum-policy=ignore' x1 ]5 M$ w) ]; L. e: E' i8 C* f
$ E- k6 N8 T0 y3 c0 n
6、没有 Fencing设备时,禁用STONITH 组件功能& W# c' G6 Y  n# D# ?* u
在 stonith-enabled="false" 的情况下,分布式锁管理器 (DLM) 等资源以及依赖DLM 的所有服务(例如 cLVM2、GFS2 和 OCFS2)都将无法启动。
1 q+ v8 i* `: m/ C' [, o [shell]# pcs property set stonith-enabled=false
* L0 P; R) p! I/ |' `# w [shell]# crm_verify -L -V                                            ## 验证群集配置信息
; s, z( F' N. C, i" N% {" O0 H
& ~- ?6 L. f# j1 f# h) T4 W) \: W% r0 |- W( g: S/ z, ^& {+ b( O

: o% }  c2 w5 F二、建立群集资源" n- w# @' Q/ y; s
) g6 x3 B* k3 p5 c4 D0 K
1、查看可用资源$ ^5 A% G; v+ t/ y" ~7 g
[shell]# pcs resource list                                         ## 查看支持资源列表,pcs resource list ocf:heartbeat9 i3 L  p0 L6 n( w+ |1 i! ~6 C2 h
[shell]# pcs resource describe agent_name                          ## 查看资源使用参数,pcs resource describe ocf:heartbeat:IPaddr2: t4 m; i4 O! S9 ^6 x

! k4 N# H% i- T9 u) W. S2、配置虚拟IP7 [6 ?6 V6 R( H4 |: P; h% u. B
[shell]# pcs resource create ClusterIP ocf:heartbeat:IPaddr2 \( Y+ e! F0 }- H4 Z7 F
  ip="192.168.10.15" cidr_netmask=32 nic=eth0 op monitor interval=30s
$ E4 M1 o/ g3 b1 E$ X3 ~: d  X3 P
3、配置Apache(httpd)6 s0 O2 f9 S" J  f. X
[shell]# pcs resource create WebServer ocf:heartbeat:apache \% U' ~! ~; V1 y1 N" E3 g1 m4 x  S6 O
  httpd="/usr/sbin/httpd" configfile="/etc/httpd/conf/httpd.conf" \5 y' \% D6 h$ R+ z& n! Z- w; h
  statusurl="http://localhost/server-status" op monitor interval=1min' m0 C& @4 j( k! ^
9 y% N& n" I9 j$ [3 H4 [4 _
4、配置Nginx
* _. W3 X( O; [6 m1 Y8 P [shell]# pcs resource create WebServer ocf:heartbeat:nginx \% J1 x* G6 `+ B4 ]
  httpd="/usr/sbin/nginx" configfile="/etc/nginx/nginx.conf" \/ j& e5 P* U7 j* ^. \* s8 O% ~
  statusurl="http://localhost/ngx_status" op monitor interval=30s& W9 I6 Z. s& U

1 ]8 w! e/ b8 c! {: y1 i% ?5.1、配置FileSystem
5 w8 l+ ~; m# n% ]* o6 w [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
+ J) b- ]; f, @5 {  device="/dev/sdb1" directory="/var/www/html" fstype="ext4"% M5 ~4 W' m$ h, \. q

) X: L+ d$ K2 i/ }" [ [shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \/ ~- r4 c9 a1 ^, z8 B- N& y
  device="-U 32937d65eb" directory="/var/www/html" fstype="ext4"
; g5 m4 o; P) z  Y/ M" C: V# F% \6 U$ I3 o4 V+ d
5.2、配置FileSystem-NFS3 e! O! X. A% g! I' C
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
% C3 [* [- x) A3 ]  device="192.168.10.18:/mysqldata" directory="/var/lib/mysql" fstype="nfs" \
$ |$ S7 T* |/ a- Z$ g# }9 [  t( M5 {  options="-o username=your_name,password=your_password" \3 Y1 o8 I& j/ W+ v+ ^7 b
  op start timeout=60s op stop timeout=60s op monitor interval=20s timeout=60s
; D+ l1 B' P2 Q( T( X: H! n$ y$ H' ~! {* M0 t0 J
6、配置Iscsi
" s2 a6 Q  N" j [shell]# pcs resource create WebData ocf:heartbeat:iscsi \
, u1 V; ~9 m7 d, E* K: ?6 K  portal="192.168.10.18" target="iqn.2008-08.com.starwindsoftware:" \
* T/ E3 t6 u# X: ?3 C  op monitor depth="0" timeout="30" interval="120"6 X# R; z$ s4 k7 y$ o
$ [% C) Z0 A7 T
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \# J' ^+ P* h! r* x
  device="-U 32937d65eb" directory="/var/www/html" fstype="ext4" options="_netdev"$ t6 S. I( Q/ ^8 O% M4 q

3 l' j- c1 t9 }) e. s, N( Y0 r7、配置DRBD( d5 Y) g- E9 B0 s
[shell]# pcs resource create WebData ocf:linbit:drbd \
' e1 I$ O# z7 s% l" j- K  drbd_resource=wwwdata op monitor interval=60s
& V! m3 ]3 d- L
4 M: ]+ `9 p9 E1 N3 H6 l! \ [shell]# pcs resource master WebDataClone WebData \2 }( m: v) i' y! P7 p0 q
  master-max=1 master-node-max=1 clone-max=2 clone-node-max=1 notify=true' r  S; r9 n; M* }
# d/ R$ x& G6 X( W5 v: C' N
[shell]# pcs resource create WebFS ocf:heartbeat:Filesystem \
7 T! j  ]! T; V* n2 U  device="/dev/drbd1" directory="/var/www/html" fstype="ext4"$ x9 `$ ~& d; m. W2 B0 `4 R
8 Y: e; X/ s5 k9 L% F, e. a
8、配置MySQL( ^% [( ^; M3 y% `
[shell]# pcs resource create MySQL ocf:heartbeat:mysql \$ W) R2 E' R* J& ?2 |) `8 P
  binary="/usr/bin/mysqld_safe" config="/etc/my.cnf" datadir="/var/lib/mysql" \8 v* \: i3 j4 M/ a& X6 h& j$ [
  pid="/var/run/mysqld/mysql.pid" socket="/tmp/mysql.sock" \
# W' G# m  N" k: j3 e  op start timeout=180s op stop timeout=180s op monitor interval=20s timeout=60s; O: h8 t: r5 q! T; v

+ W2 V! `% ~: R2 d% H2 o; ~* h; F( d9、配置Pingd,检测节点与目标的连接有效性
$ ?) q$ J  ?- _' O5 E [shell]# pcs resource create PingCheck ocf:heartbeat:pingd \
: [# s- p4 Y1 M& ]& l  dampen=5s multiplier=100 host_list="192.168.10.1 router" \
' v9 O0 j- C. M- ~/ @* ?  op monitor interval=30s timeout=10s8 c6 z7 U2 `5 l: T
- x  d, k0 X7 T" U
10、创建资源clone,克隆的资源会在全部节点启动
+ z: v; Y/ x: y [shell]# pcs resource clone PingCheck
9 x$ C5 f8 ?( r& ?. i/ W2 F [shell]# pcs resource clone ClusterIP clone-max=2 clone-node-max=2 globally-unique=true            ## clone-max=2,数据包分成2路
( V# W4 X: i6 {& p5 s6 b/ j [shell]# pcs resource update ClusterIP clusterip_hash=sourceip            ## 指定响应请求的分配策略为:sourceip7 e6 U% {5 r6 o4 p# U" ?
; O8 i3 ^; [& t1 R

4 ]5 h- q' {  z! ~8 `! K8 E0 j* ]  ?4 B6 h8 O) M3 ^
三、调整群集资源
( O* |6 Y% v$ U! `6 ?
+ M" {+ G5 t+ b4 ^2 k1、配置资源约束
: _8 N3 N5 N* a3 k4 Q3 V* O! T& q0 Q [shell]# pcs resource group add WebSrvs ClusterIP                            ## 配置资源组,组中资源会在同一节点运行0 ~  X8 b# a9 |
[shell]# pcs resource group remove WebSrvs ClusterIP                    ## 移除组中的指定资源. f) A' F4 h- g( f6 F$ B
[shell]# pcs resource master WebDataClone WebData                          ## 配置具有多个状态的资源,如 DRBD master/slave状态- @- ?* J# ^7 ?5 {/ k: V( ^* j  v
[shell]# pcs constraint colocation add WebServer ClusterIP INFINITY          ## 配置资源捆绑关系
% R# w7 G/ |/ Q, X/ Y. j [shell]# pcs constraint colocation remove WebServer                      ## 移除资源捆绑关系约束中资源  u) f  O& e4 ]  H; V
[shell]# pcs constraint order ClusterIP then WebServer                   ## 配置资源启动顺序
1 r' l+ A5 f( t( Y; B% M$ S [shell]# pcs constraint order remove ClusterIP                             ## 移除资源启动顺序约束中资源
1 |7 P( D1 c, I/ F2 K [shell]# pcs constraint                                                  ## 查看资源约束关系, pcs constraint --full
7 W4 c  `& ]( V
! J; a9 L( z4 T1 a* W2、配置资源位置* u6 Z1 N7 T9 q4 d# j$ ?
[shell]# pcs constraint location WebServer prefers node11                 ## 指定资源默认某个节点,node=50 指定增加的 score4 F8 Z5 c- T4 n6 M" T
[shell]# pcs constraint location WebServer avoids node11                ## 指定资源避开某个节点,node=50 指定减少的 score
. T+ i% u- o/ W. E3 i7 { [shell]# pcs constraint location remove location-WebServer                ## 移除资源节点位置约束中资源ID,可用pcs config获取
: A5 q1 h* ]  [, W+ w  ]( g4 e) y [shell]# pcs constraint location WebServer prefers node11=INFINITY           ## 手工移动资源节点,指定节点资源的 score of INFINITY
% X6 S/ m" v- ?9 Q# q% f; |9 d0 B [shell]# crm_simulate -sL                                                    ## 验证节点资源 score 值
; i' s5 _+ k! t3 `4 u! o1 @' l4 ^; |
3、修改资源配置9 Z. U* W. L2 v7 U1 ]
[shell]# pcs resource update WebFS                                            ## 更新资源配置
( E, ^1 w: ?4 S& ^$ l [shell]# pcs resource delete WebFS                                            ## 删除指定资源
! i3 ]  X! L) U% n  C, i! w" \8 Y" Y2 O7 j( x9 L( V# P* ^7 \
4、管理群集资源* `8 U  Y' X' w$ c; ^
[shell]# pcs resource disable ClusterIP                                    ## 禁用资源
- P# I: W3 d' ~; }- v6 ^# @# M [shell]# pcs resource enable ClusterIP                                    ## 启用资源+ S  {; n" a9 [/ R- g; R
[shell]# pcs resource failcount show ClusterIP                          ## 显示指定资源的错误计数; {: K3 i* L7 H' C  {$ N
[shell]# pcs resource failcount reset ClusterIP                         ## 清除指定资源的错误计数
9 r# y: y  m% o5 k; \8 L2 o6 F [shell]# pcs resource cleanup ClusterIP                                ## 清除指定资源的状态与错误计数
8 j1 A2 _0 C3 s. k; n9 }) P, p* |1 k- `7 C$ A; E! V6 {
+ E& P5 O3 k8 C5 D# ]+ T

6 q: R- t0 B/ K  j; b9 J7 O* k4 h
: O" i2 m& v7 Z$ Z  Y. }0 z. U四、配置Fencing设备,启用STONITH% z6 E( x1 g+ H
7 K' Q. a! p- w
1、查询Fence设备资源9 G. t" S4 K+ ~+ Z. n' h  B; v
[shell]# pcs stonith list                                                   ## 查看支持Fence列表
0 Z. c. E& U7 M: B& M0 \ [shell]# pcs stonith describe agent_name                                  ## 查看Fence资源使用参数,pcs stonith describe fence_vmware_soap! Q$ z( T7 Q9 P/ [8 r+ ?! C( z/ Y
          I& Y- l+ ~$ }% M- U0 `( m
2、配置fence设备资源
! @0 d8 @5 @: [0 A. h+ i. K5 y [shell]# pcs stonith create ipmi-fencing fence_ipmilan \
* `6 P' [/ X3 ~) l8 p" K  pcmk_host_list="pcmk-1 pcmk-2" ipaddr="10.0.0.1" login=testuser passwd=acd123 \0 d, f2 }2 v2 ^" w2 y* k" Y8 @4 H
  op monitor interval=60s
' M1 J8 y: {# C7 I+ m+ O# r% V! [0 X% h# h9 X
mark:
2 C, G0 d2 @0 z. h- X, YIf 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.
) U  F( `8 s: |+ c: o" w3 wIf 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.
2 y7 ~% J! E  vIf 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.. a2 S& d/ {6 u& s( q6 E4 R0 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.
. K! T6 n# \0 e( a4 f/ L. Rexample: pcmk_host_argument="uuid" pcmk_host_map="node11:4;node12:5;node13:6" pcmk_host_list="node11,node12"  pcmk_host_check="static-list"
! o& L0 C$ `" N3 i( o" e7 g
( t6 R6 m, q( v1 O4 f6 {3、配置VMWARE (fence_vmware_soap)
" {9 Q1 _& N, i$ s 特别说明:本次实例中使用了第3项(pcs stonith create vmware-fencing fence_vmware_soap)这个指定pcmk配置参数才能正常执行Fencing动作。( b' c- K9 q2 g5 i
2 |  [& T, W; I
3.1、确认vmware虚拟机的状态:
: l: q5 q1 H) m3 U. i; e; n [shell]# fence_vmware_soap -o list -a vcenter.example.com -l cluster-admin -p <password> -z                          ## 获取虚拟机UUID
, O0 }4 ~, {# o [shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -U <UUID>         ## 查看状态
# \. \/ t- D6 h, @ [shell]# fence_vmware_soap -o status -a vcenter.example.com -l cluster-admin -p <password> -z -n <vm name>0 g! f7 O  Y' @" r( l

7 n8 x' `$ j/ s. e, [0 c+ |3.2、配置fence_vmware_soap
% b4 T2 p  }; r& Y- s  w+ h [shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \
8 c, X: Z+ O4 X. K" P  action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \
. T! h* W* A& Q- {& N  port="node11" shell_timeout=60s login_timeout=60s op monitor interval=90s9 D4 h4 h5 _. E# \0 z

! M6 }5 k# v  A/ A" a8 B4 X5 k [shell]# pcs stonith create vmware-fencing-node11 fence_vmware_soap \/ P: h- k- F8 c2 O0 l; e7 |2 l
  action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \9 g& U( A, }: Y0 E! i$ @. U
  uuid="421dec5f-c484-3d69-ddfb-65af46530581" shell_timeout=60s login_timeout=60s op monitor interval=90s! S0 @" F2 q3 X' L5 B9 o8 l

, o% e8 D5 ?+ i6 o7 i1 D [shell]# pcs stonith create vmware-fencing fence_vmware_soap \
, l7 `; D" {: O" w% F, J  action="reboot" ipaddr="192.168.10.10" login="vmuser" passwd="vmuserpd" ssl="1" \
. A! Z; X; k; \6 x7 I4 \( N  pcmk_host_argument="uuid" pcmk_host_check="static-list" pcmk_host_list="node11,node12" \  G+ E, ]9 p5 ^& W
  pcmk_host_map="node11:421dec5f-c484-3d69-ddfb-65af46530581;node12:421dec5f-c484-3d69-ddfb-65af46530582" \
; n/ K2 L4 J% q& I" @2 J  shell_timeout=60s login_timeout=60s op monitor interval=90s2 V( B- Q  `8 J% T- C3 Z

# D+ M, g  @  f; \% \2 X" e: C注:如果配置fence_vmware_soap设备时用port=vm name在测试时不能识别,则使用uuid=vm uuid代替;
5 Q! u1 N- D( d1 e; p建议使用 pcmk_host_argument、pcmk_host_map、pcmk_host_check、pcmk_host_list 参数指明节点与设备端口关系,格式:
: b0 [; u( s, l+ 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"
+ P! e! I2 C+ H( @+ Y. _% R
4 T! q: W$ }' P  y4、配置SCSI7 q& Y2 J3 B& H
[shell]# ls /dev/disk/by-id/wwn-*                            ## 获取Fencing磁盘UUID号,磁盘须未格式化
0 s0 Z+ B) W( p: R [shell]# pcs stonith create iscsi-fencing fence_scsi \1 Z+ Z4 e4 F8 k# E, M$ O) m6 L
  action="reboot" devices="/dev/disk/by-id/wwn-0x600e002" meta provides=unfencing
( }5 e$ Q+ u9 f7 u& p( N* S& ^+ N0 D/ [5 X; L; h
5、配置DELL DRAC" V! d' U6 ^& I* d2 c+ l
[shell]# pcs stonith create dell-fencing-node11 fence_drac
( _1 h; u: N2 C, [% P  b1 j" R.....; d& E, p4 U3 o# z* L: M
+ f# R- |) V  o5 D. m% x5 {( n

0 Q9 Y! x  P9 Y1 C  A6、管理 STONITH
" v  \; s: r0 C% T+ D4 _' i5 i [shell]# pcs resource clone vmware-fencing                    ## clone stonith资源,供多节点启动# O; h3 E0 s# I, [
[shell]# pcs property set stonith-enabled=true          ## 启用 stonith 组件功能
% g2 E' y/ r# o1 F [shell]# pcs stonith cleanup vmware-fencing                ## 清除Fence资源的状态与错误计数
: Q* ^: b3 g5 l* _( Y# _ [shell]# pcs stonith fence node11                             ## fencing指定节点5 S' R+ L3 k- V: K2 P' Y3 ^1 P8 A5 ~' c

5 o/ O' W: `9 G! k. c2 e# K7 r8 o) F; \1 n% }* p2 A

% V5 ?- ^$ I8 A# K' C+ U% L
9 z' ^7 Y4 n& s  j& [) w五、群集操作命令7 P/ Q, l6 s9 f  V

) a( E9 |& G: W, c# q$ @1、验证群集安装8 T3 m* ^2 [" v& N% i) {  h
[shell]# pacemakerd -F                                    ## 查看pacemaker组件,ps axf | grep pacemaker) n. C9 m' i2 L
[shell]# corosync-cfgtool -s                                  ## 查看corosync序号
: K8 U  g  Z& P [shell]# corosync-cmapctl | grep members                  ## corosync 2.3.x
! q) ~1 @) }2 v; l. a [shell]# corosync-objctl | grep members                  ## corosync 1.4.x  o5 j5 X( b$ s$ _( {

9 [' U! ?9 }9 W+ m2、查看群集资源9 x0 E- t1 Y8 O. d
[shell]# pcs resource standards                          ## 查看支持资源类型% A! v" A* U4 H) C
[shell]# pcs resource providers                          ## 查看资源提供商/ u( j8 P/ q! e+ S5 V- O
[shell]# pcs resource agents                                ## 查看所有资源代理
/ n% a* B- V; H# S9 [: J3 l2 Z! u [shell]# pcs resource list                                 ## 查看支持资源列表
/ \( ^; u7 U9 W4 L [shell]# pcs stonith list                                ## 查看支持Fence列表
( s% f  P) `7 g [shell]# pcs property list --all                        ## 显示群集默认变量参数
: @" t/ I: N! g* v3 y# W  Q  a/ D [shell]# crm_simulate -sL                                    ## 检验资源 score 值4 H. L" a/ Y) K" |
1 r3 k7 F* s7 P
3、使用群集脚本
; J2 R( l% i+ P& p+ r& Y0 N [shell]# pcs cluster cib ra_cfg                            ## 将群集资源配置信息保存在指定文件6 b( ~& H' `+ T* E
[shell]# pcs -f ra_cfg resource create                    ## 创建群集资源并保存在指定文件中(而非保存在运行配置)7 }1 i( v. x1 q# r5 |5 K7 q
[shell]# pcs -f ra_cfg resource show                          ## 显示指定文件的配置信息,检查无误后
; k( C. W  e, N) i9 P6 ~6 } [shell]# pcs cluster cib-push ra_cfg                          ## 将指定配置文件加载到运行配置中- H) L$ J, }+ Y/ {2 `

# C8 V2 o/ _3 K4、STONITH 设备操作# e  ~) v1 H; |0 E0 c
[shell]# stonith_admin -I                                    ## 查询fence设备2 I) t# o6 }4 _1 J$ _5 a  z
[shell]# stonith_admin -M -a agent_name                   ## 查询fence设备的元数据,stonith_admin -M -a fence_vmware_soap9 ^8 E) E5 J) S6 R
[shell]# stonith_admin --reboot nodename                    ## 测试 STONITH 设备- S- T5 v' J6 [6 N+ X
6 h- W) L! z' K
5、查看群集配置8 r2 a/ w) i6 [9 u% E  a2 }
[shell]# crm_verify -L -V                                    ## 检查配置有无错误- [* e  i5 l1 Y  z4 I% I8 _. c
[shell]# pcs property                                    ## 查看群集属性
5 e/ s* |3 f7 [6 V8 X [shell]# pcs stonith                                    ## 查看stonith: o1 V2 Y1 \. b9 W& f9 a1 Y
[shell]# pcs constraint                                    ## 查看资源约束
. c# ~. N, t, P, E4 b) K [shell]# pcs config                                    ## 查看群集资源配置; ?" K: n( y8 X% N2 s! Z  e3 d
[shell]# pcs cluster cib                                    ## 以XML格式显示群集配置7 n8 a+ H- K4 ~4 r
) @  _- P6 ]- U
6、管理群集
) W+ i$ v2 ?% r8 E5 H' E [shell]# pcs status                                          ## 查看群集状态1 `0 C6 c( y7 S7 B# L! p, u
[shell]# pcs status cluster, |! t) r' \* u6 w/ w' }: T3 E2 C
[shell]# pcs status corosync8 V) Z$ |8 I. }, K8 C1 g
[shell]# pcs cluster stop [node11]                          ## 停止群集- E" d+ b1 i3 H/ m- o0 p, J6 r
[shell]# pcs cluster start --all                            ## 启动群集
! T( ?2 A4 D! e' P- g2 P6 F( z [shell]# pcs cluster standby node11                          ## 将节点置为后备standby状态,pcs cluster unstandby node11
2 L+ [$ f- y& b* t; n [shell]# pcs cluster destroy [--all]                          ## 删除群集,[--all]同时恢复corosync.conf文件
( x# u2 M% o7 Q3 o1 r: S [shell]# pcs resource cleanup ClusterIP                ## 清除指定资源的状态与错误计数+ T5 Z4 f$ H; }. A
[shell]# pcs stonith cleanup vmware-fencing                ## 清除Fence资源的状态与错误计数
; R) t! w- N7 p9 ~& k2 C% r$ q' x9 n
8 W* z  ]0 A7 {$ Y: g
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 05:34 , Processed in 0.018273 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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