- 积分
- 16843
在线时间 小时
最后登录1970-1-1
|

楼主 |
发表于 2023-12-22 11:54:34
|
显示全部楼层
crm options user hacluster) [& b8 x. H* `2 x4 r+ p
COPY! X! Y* u* A0 J$ M
Note that you need to set up /etc/sudoers so that sudo does not ask for a password.3 U8 s4 z% a& M Q4 k5 h9 [
) d: S' k5 p) Y0 D$ ?9 q
7.1 crmsh—Overview
& V- x+ l; y x5 H; T6 i9 J# s
d) Y! f7 K( m3 ]* K7 MThe crm command has several subcommands which manage resources, CIBs, nodes, resource agents, and others. It offers a thorough help system with embedded examples. All examples follow a naming convention described in Appendix B.
2 W4 _# ^: `: D) k( O$ D* l% C0 p: q$ N6 S3 k) z
TipTip: Interactive crm Prompt
6 @3 D v0 R# Y$ }( hBy using crm without arguments (or with only one sublevel as argument), the crm shell enters the interactive mode. This mode is indicated by the following prompt:8 }0 p: t2 w) \
* Z$ n1 e1 Z5 {6 {' u" F* ICOPY
+ q! n9 o' [5 r- s8 OFor readability reasons, we omit the host name in the interactive crm prompts in our documentation. We only include the host name if you need to run the interactive shell on a specific node, like alice for example:
* p: P, X, V1 m, y9 x; ?- Q7 m& i; ^3 n" f
COPY
' a7 `. d5 t; B# V& z7.1.1 Getting Help8 Z+ F% s+ j/ M3 C
! p3 P. F/ V) d0 O) f& B$ l
Help can be accessed in several ways:
; ^0 Z& d( @1 _" F' r/ C
* L! n6 `# H8 OTo output the usage of crm and its command line options:
$ f2 V8 Z. e( g9 R- W% y$ ?( ?, `" j* W5 c6 X
crm --help1 s% b6 y- f6 {" H$ a6 B
COPY
/ s& v d9 R( }8 O7 \. N/ BTo give a list of all available commands:
$ ~) k/ }. h# f% w7 g
/ X, g6 j/ k# H0 p3 Ocrm help
2 B ^6 t5 A& |( b$ q SCOPY4 Z* j" V* Z( k
To access other help sections, not just the command reference:
! R$ y) J6 c4 s$ v, u: z" m( `1 k/ t1 [, ^% t
crm help topics
4 i o R$ r9 Y$ u5 DCOPY9 r7 X# n: l0 n5 L! ?" }8 t
To view the extensive help text of the configure subcommand:
$ ^1 D% B( x8 n& q6 g9 ^7 ?5 {3 ^3 X3 @8 `
crm configure help
0 z, a% q8 L8 H) b1 t1 {( SCOPY
3 g9 k* @4 b5 e0 O8 D4 C3 rTo print the syntax, its usage, and examples of the group subcommand of configure:
4 x2 d: R5 y+ b' N7 R4 B$ F) {. C+ e% G' j* K2 L5 d* g* C
crm configure help group6 m/ N \, I9 Q6 T9 ?
COPY x. `5 @' L! X% a8 r! Z
This is the same:
* k* |, Z4 Z" U
/ c4 E% d. S" I7 W I9 ucrm help configure group% k! s7 O& K) Z* }0 L M3 T
COPY' G7 c+ w' w2 h# [6 d- B/ c5 {) y
Almost all output of the help subcommand (do not mix it up with the --help option) opens a text viewer. This text viewer allows you to scroll up or down and read the help text more comfortably. To leave the text viewer, press the Q key.
7 I2 Q4 i) ]/ O8 L! C! X, C' X, c' F- e; j) z/ M0 f9 q
TipTip: Use Tab Completion in Bash and Interactive Shell
5 G. G; Q9 r, C% W# \2 oThe crmsh supports full tab completion in Bash directly, not only for the interactive shell. For example, typing crm help config→| will complete the word like in the interactive shell.
& g( }0 l( z: g( ]4 |
Z4 f2 ~. B; V* B0 j7.1.2 Executing crmsh's Subcommands
+ K: Z) b Z/ g% H0 B: u; Z! S8 d; ~6 a) {
The crm command itself can be used in the following ways:
. V& v0 }0 e7 |# O* g* E2 {5 a
7 {) O$ A O; O4 SDirectly: Concatenate all subcommands to crm, press Enter and you see the output immediately. For example, enter crm help ra to get information about the ra subcommand (resource agents).% {1 D; K+ z B- m+ _7 U/ m" t# ]
; r1 ^* d y7 ^4 \It is possible to abbreviate subcommands as long as they are unique. For example, you can shorten status as st and crmsh will know what you have meant.6 o* n6 A+ j! @. h7 ^
$ S+ Q s4 [# _6 _$ oAnother feature is to shorten parameters. Usually, you add parameters through the params keyword. You can leave out the params section if it is the first and only section. For example, this line:
. I% B. y3 Z0 X; R" @ j7 K! v
; n9 }( R* Y9 d' P; J' Jcrm primitive ipaddr IPaddr2 params ip=192.168.0.55
8 c- g- [- W! ?1 _# LCOPY
' U* H) `; q% \; H2 vis equivalent to this line:
1 F( z6 a* `% g( ?, h. e
U9 r8 l! y0 u" A' I" p( ]* scrm primitive ipaddr IPaddr2 ip=192.168.0.55
" F. W$ _/ B+ CCOPY" ` b u7 q# I8 I6 Z
As crm Shell Script: Crm shell scripts contain subcommands of crm. For more information, see Section 7.1.4, “Using crmsh's Shell Scripts”.
$ M9 Z% r. X- w) _! o
o7 i# D% x6 o- ]& dAs crmsh Cluster Scripts:These are a collection of metadata, references to RPM packages, configuration files, and crmsh subcommands bundled under a single, yet descriptive name. They are managed through the crm script command.4 B. R0 e1 |8 r' I5 a9 }% Y: h) B8 t
8 o+ ?% K; r. |: G! K2 ^ ~Do not confuse them with crmsh shell scripts: although both share some common objectives, the crm shell scripts only contain subcommands whereas cluster scripts incorporate much more than a simple enumeration of commands. For more information, see Section 7.1.5, “Using crmsh's Cluster Scripts”.
g- v4 s: O& a/ ]% Y+ c" K4 s
6 E1 T7 v6 g9 n7 E6 PInteractive as Internal Shell: Type crm to enter the internal shell. The prompt changes to crm(live). With help you can get an overview of the available subcommands. As the internal shell has different levels of subcommands, you can “enter” one by typing this subcommand and press Enter.& u9 j* s9 i& S L
$ l) e+ |, ^ H
For example, if you type resource you enter the resource management level. Your prompt changes to crm(live)resource#. If you want to leave the internal shell, use the commands quit, bye, or exit. If you need to go one level back, use back, up, end, or cd.
/ V8 d/ N e6 h$ O& Y8 S
: Y+ S) k" N; R4 j, iYou can enter the level directly by typing crm and the respective subcommand(s) without any options and press Enter.
- B: u; [+ Y2 S ~9 S# K3 e5 u, s/ e# M1 Q0 l
The internal shell supports also tab completion for subcommands and resources. Type the beginning of a command, press →| and crm completes the respective object.
+ B5 a H) z- h+ C# o
% b2 V) A1 Q7 K9 Z" k, Q1 PIn addition to previously explained methods, crmsh also supports synchronous command execution. Use the -w option to activate it. If you have started crm without -w, you can enable it later with the user preference's wait set to yes (options wait yes). If this option is enabled, crm waits until the transition is finished. Whenever a transaction is started, dots are printed to indicate progress. Synchronous command execution is only applicable for commands like resource start.% ?) y( W: K, M: t
' D1 }( x( F9 f6 eNoteNote: Differentiate Between Management and Configuration Subcommands
) D, n4 X! ~3 b" q" P" f3 gThe crm tool has management capability (the subcommands resource and node) and can be used for configuration (cib, configure).
( t' _$ d1 o& z' |8 `
+ C+ C4 Z' c( CThe following subsections give you an overview of some important aspects of the crm tool.& b9 P/ _( c# E) S) X6 _
( N0 F$ P3 a) k% g7 U+ d& h+ A
7.1.3 Displaying Information about OCF Resource Agents
* Z, ]% g+ p5 ]. {/ P$ i0 E" q- u* Y
6 D3 @5 G+ {# K2 C# I' dAs you need to deal with resource agents in your cluster configuration all the time, the crm tool contains the ra command. Use it to show information about resource agents and to manage them (for additional information, see also Section 5.3.2, “Supported Resource Agent Classes”):
# r9 `; t d7 A1 z& x- c0 K. }% J6 f6 n6 c5 X8 b# M3 G$ b
crm ra2 A: \. z- Q5 y( R$ J
COPY: \& p: _8 |* d4 c# Z* X' a
The command classes lists all classes and providers:$ M3 O" T2 s* ~
5 e8 ?; l+ K# G- c% j! F7 V' i
classes8 }+ C7 t1 @7 p. H, u. w, j
lsb4 r3 e% R: d3 @
ocf / heartbeat linbit lvm2 ocfs2 pacemaker* |* m& t2 a: t E: b3 \
service6 q* L `" D+ }6 M* K# E' U
stonith) K3 l5 Y7 G/ A! N8 i
systemd
5 t" u* R6 P3 I$ T( c! ICOPY
% T9 j9 {( V7 e( w+ qTo get an overview of all available resource agents for a class (and provider) use the list command:
* A8 p/ V6 _( O F! P! j) A0 V! ?% C. [( I; a* c, s; e
list ocf0 ~6 n9 f: f& Q5 c: D
AoEtarget AudibleAlarm CTDB ClusterMon. `5 D! P/ L2 ? |
Delay Dummy EvmsSCC Evmsd
) _" N: [1 h! q6 ^& T( L/ ?: I0 aFilesystem HealthCPU HealthSMART ICP2 C) I' [' u; G2 h/ [7 f3 T" }
IPaddr IPaddr2 IPsrcaddr IPv6addr" r z( B+ m ]4 I$ v
LVM LinuxSCSI MailTo ManageRAID
3 m4 F% k: B/ e4 kManageVE Pure-FTPd Raid1 Route
# X5 Z8 @( i# c- n1 p" tSAPDatabase SAPInstance SendArp ServeRAID7 j( F% p v* r. ~
...
% B- w" k* u2 P" }- N5 c( {. ICOPY
; d4 q$ V b' c" }An overview of a resource agent can be viewed with info:
3 S$ T$ f" h( P/ F h
' u2 n4 q/ c* P7 e9 K0 D& Qinfo ocf:linbit:drbd
+ ?' n% y* k' S* J3 wThis resource agent manages a DRBD* resource) Q; o2 t9 U4 }/ s$ w( d
as a master/slave resource. DRBD is a shared-nothing replicated storage
4 T; L: a1 F4 I7 }device. (ocf:linbit:drbd)+ }' R2 r: X# h& p
" P/ G ?8 I% `8 s3 A0 r
Master/Slave OCF Resource Agent for DRBD
* C- [: l$ j# a& }" d* G9 g% H( R, A$ c7 v' O0 z( J
Parameters (* denotes required, [] the default):7 ?1 ?" ]6 v" o5 S1 O1 v* I
1 L0 n; ^! Y' F% p$ P# u" L! ]) H
drbd_resource* (string): drbd resource name6 ]" R" j" v$ ~) ~3 E* f% |
The name of the drbd resource from the drbd.conf file.
; I1 r/ T$ @4 c+ f; ~& v/ v% f
6 h8 ] a5 K: h7 qdrbdconf (string, [/etc/drbd.conf]): Path to drbd.conf
2 }" z( r8 A$ ]% { Full path to the drbd.conf file. W$ K) c# j) P: C
) \ ]& T$ V: G2 U i: V
Operations' defaults (advisory minimum):
8 m3 m2 T- X7 h3 G- i. `9 p! N0 @: X4 V4 @3 p
start timeout=240
* ?& D9 g4 \8 J5 u promote timeout=90: q" [! m& v: o+ x) V# R
demote timeout=90
" \: U9 @' S* x8 K! v notify timeout=90" a3 w, S1 t& n$ |! a8 m2 a
stop timeout=100) y( c$ }, Q9 ]- V7 p. @
monitor_Slave_0 interval=20 timeout=20 start-delay=1m
" i0 j: a' _; i" @# ] monitor_Master_0 interval=10 timeout=20 start-delay=1m
# b9 c7 }1 _* `; MCOPY0 d. X6 O! h! y7 U/ L
Leave the viewer by pressing Q.& U9 F1 X+ N: r! a. U
# A7 E+ |0 B0 LTipTip: Use crm Directly
0 d& _# M3 @$ n$ K8 }/ BIn the former example we used the internal shell of the crm command. However, you do not necessarily need to use it. You get the same results if you add the respective subcommands to crm. For example, you can list all the OCF resource agents by entering crm ra list ocf in your shell.7 H6 r9 U0 T7 Z
: R2 {- `% j1 t7 ], M1 U7.1.4 Using crmsh's Shell Scripts5 T/ R0 _ T8 o# J& t% a! E
6 G$ ?3 I& v$ `' N! M
The crmsh shell scripts provide a convenient way to enumerate crmsh subcommands into a file. This makes it easy to comment specific lines or to replay them later. Keep in mind that a crmsh shell script can contain only crmsh subcommands. Any other commands are not allowed.
# b# a- j( ]: J$ I/ U; z/ |2 f& J; x" U+ Q, f4 t
Before you can use a crmsh shell script, create a file with specific commands. For example, the following file prints the status of the cluster and gives a list of all nodes:* ?* L7 m+ A9 ?1 |, n
0 q/ x. M5 [, i/ H. d" H7 T
EXAMPLE 7.1: A SIMPLE CRMSH SHELL SCRIPT' z' B/ U( z- o' J( `! ]
+ o5 }3 H2 B' Q# A small example file with some crm subcommands6 c6 K& s4 |- c
status
, \+ j j* C% K% N" x6 b. T2 n7 I/ Gnode list
% R6 P' U0 ^' I9 B( {% j* lCOPY+ r2 W5 _. s2 n Q6 A
Any line starting with the hash symbol (#) is a comment and is ignored. If a line is too long, insert a backslash (\) at the end and continue in the next line. It is recommended to indent lines that belong to a certain subcommand to improve readability.
7 b& B& ^7 ]/ M# B. i8 J& s) @% I8 `
To use this script, use one of the following methods:! |4 f% E* l2 a P0 h
6 W# c* ^# n' _, a1 K/ p! e
crm -f example.cli, r% \) G3 y+ J' M$ j7 E
crm < example.cli
, x- U' R" \, T) YCOPY
8 O/ [2 H% a r) X& K7.1.5 Using crmsh's Cluster Scripts
4 f: b$ g' n' `& w1 S- h% i/ R" `0 B
Collecting information from all cluster nodes and deploying any changes is a key cluster administration task. Instead of performing the same procedures manually on different nodes (which is error-prone), you can use the crmsh cluster scripts.2 S( G2 L' A# |: \
0 L, [( k! y: G; SDo not confuse them with the crmsh shell scripts, which are explained in Section 7.1.4, “Using crmsh's Shell Scripts”.
* o/ D' {8 \4 [* G5 a, m$ g" B! [2 p* y$ q# Z) C- ^6 m5 o7 Y X3 C
In contrast to crmsh shell scripts, cluster scripts performs additional tasks like:. T+ i, k4 |/ G1 x) r
) `- j% ^; n5 a0 V
Installing software that is required for a specific task.) @( P G2 X8 J' W# `$ |3 w% ]
4 M; m, C7 w9 e# H" hCreating or modifying any configuration files.
+ M* R2 V, i4 E, d, S2 ?
z8 m+ C/ Z1 c5 _. uCollecting information and reporting potential problems with the cluster.
# c9 R. u/ Q0 Z, u; O
$ @4 q# i: |) p; E) O! a; RDeploying the changes to all nodes.
6 f9 ^& }6 I* p" h$ z1 C8 k6 s$ J1 T+ I% @, g6 U
crmsh cluster scripts do not replace other tools for managing clusters—they provide an integrated way to perform the above tasks across the cluster. Find detailed information at http://crmsh.github.io/scripts/.! A* I" ~: ]" t) v
' n* e. a6 o+ ?
7.1.5.1 Usage' V; v! k v, w2 D0 P* x `8 l
* y, W8 c# @ X
To get a list of all available cluster scripts, run:
$ E' Y, j: S( ?
/ G4 B; H9 I. d2 ^crm script list$ E7 R0 g, ]5 _5 d- g9 {( `
COPY8 l. s$ S" S" h7 }
To view the components of a script, use the show command and the name of the cluster script, for example:- l/ ?% U1 I0 o. \+ B: v
* B( I1 t8 D! V; s
crm script show mailto2 Z& }+ L9 m+ h
mailto (Basic). M- {' \2 C! ~. |7 M% x9 |# y7 D
MailTo
8 o. q0 X3 d2 a7 k9 v- i8 G' P" X* b/ e; ~. y0 X% o
This is a resource agent for MailTo. It sends email to a sysadmin0 `# L- H' f9 [5 u" E; s
whenever a takeover occurs.( R) [- n6 }1 o' A; V! }- h$ I
0 A) [' r: p+ a! p9 v1 Y# r
1. Notifies recipients by email in the event of resource takeover
8 E5 W, v% R# ^, |- }1 }2 p; J. q% \9 f6 b6 R; ]
id (required) (unique)
! {% j, m& r1 p; y0 @) u U Identifier for the cluster resource( a, b: T3 ^' Q: I! X* T \
email (required)
" a+ X1 i: A- _0 a Email address
/ n' V( \3 y8 L: p% e! d subject
Y. `) H- @& @) N Subject" R) W( O4 |3 A$ ] \: _
COPY
9 [4 U8 Q. h$ _The output of show contains a title, a short description, and a procedure. Each procedure is divided into a series of steps, performed in the given order.
, D$ H3 V! G1 D# f7 X4 {
" L6 F' G) E, x! j$ CEach step contains a list of required and optional parameters, along with a short description and its default value.$ g$ T0 f- w4 u; ~+ l
' q1 \6 O, {5 e2 z J, W, ~
Each cluster script understands a set of common parameters. These parameters can be passed to any script:7 a" v7 ?3 y: |$ h0 F. z: o( S
6 t2 r& v7 c3 b8 r: Q1 `2 jTABLE 7.1: COMMON PARAMETERS
$ ~; J% a9 D0 i7 s3 t7 b9 p! E
. t ^: L7 i+ Q3 cParameter Argument Description( X/ D E/ _& S, p% |( L
action INDEX If set, only execute a single action (index, as returned by verify)
; b* |4 F6 V6 Cdry_run BOOL If set, simulate execution only (default: no)
: a& m# A7 }, g6 S; V) H: Inodes LIST List of nodes to execute the script for
# Y, o8 l4 b* ^8 Lport NUMBER Port to connect to- g3 d3 h7 u+ G4 a
statefile FILE When single-stepping, the state is saved in the given file
6 @; a }7 H- ^! V9 u3 Fsudo BOOL If set, crm will prompt for a sudo password and use sudo where appropriate (default: no)
* x/ {8 a7 h3 z- l. ztimeout NUMBER Execution timeout in seconds (default: 600)
8 o3 Z. z3 V5 H; H1 wuser USER Run script as the given user5 ^+ q4 d& v( W! r, X8 ]' Y
7.1.5.2 Verifying and Running a Cluster Script
' {1 B" Q: T9 T \5 c, ?/ f
) R2 v: c; A3 g- m9 aBefore running a cluster script, review the actions that it will perform and verify its parameters to avoid problems. A cluster script can potentially perform a series of actions and may fail for various reasons. Thus, verifying your parameters before running it helps to avoid problems.! E, F" ~9 J' u, O* ]* a Y
8 G6 r# c4 n6 L4 Z; B
For example, the mailto resource agent requires a unique identifier and an e-mail address. To verify these parameters, run:
* F& p$ s3 g( M: T a8 x' q6 R* c: L* O0 A$ H
crm script verify mailto id=sysadmin email=tux@example.org3 j5 N+ }3 n7 I$ s, A4 ^3 Q. y
1. Ensure mail package is installed# H8 u$ W1 `& t9 k/ T5 O" ~
* N0 i# d6 r h mailx
+ e6 I* f( U+ i$ q! N+ [1 ~: X5 z" H# E0 ^
2. Configure cluster resources
9 c. J$ U4 u- m/ q9 F+ O& ]2 X5 r' j+ Z, |
primitive sysadmin MailTo
/ i7 E+ f+ E5 s9 e$ F email="tux@example.org"1 P4 g+ `; T% V5 L' e
op start timeout="10"2 B( `! s/ M* W* O+ [/ U$ r
op stop timeout="10"" b5 ^- h+ m. I# C
op monitor interval="10" timeout="10"3 r/ H- j& F8 B1 k9 p M7 c
3 g' x* O4 a$ ]* h4 h$ w
clone c-sysadmin sysadmin t- C- b+ S& r8 Z
COPY
( x2 _+ g# J* N+ L- ]$ ZThe verify prints the steps and replaces any placeholders with your given parameters. If verify finds any problems, it will report it. If everything is ok, replace the verify command with run:! Z, _" ?5 o( o" N* m$ Q- Z1 b; T
& ?" L' R* t/ v' l( b% [) Lcrm script run mailto id=sysadmin email=tux@example.org
0 d, c# {: V9 m7 b8 m# w0 }INFO: MailTo
" R3 P9 T7 U1 d9 R4 `& V3 AINFO: Nodes: alice, bob
& s- \; l2 ?1 l4 M/ L$ r( }+ VOK: Ensure mail package is installed
: [$ m1 M% x0 e: dOK: Configure cluster resources
: v8 M- v |5 h8 @% fCOPY- D% }/ X, Y( C* Z6 o4 M4 |
Check whether your resource is integrated into your cluster with crm status:
' B5 b/ D9 M/ k" T+ T1 [
3 j% s, }. p& xcrm status
0 F1 i% q: |+ [( c a% c[...]0 w6 T2 @- n2 C3 b" c+ `
Clone Set: c-sysadmin [sysadmin]3 _+ o1 o# n: \0 `8 Z
Started: [ alice bob ]
) b5 }( v6 y6 g J; p+ GCOPY! W& r o1 v( X2 D9 a s0 V
7.1.6 Using Configuration Templates
- i7 a7 _: @3 ^! t% [9 y
- X. _ @: h' v! b: {NoteNote: Deprecation Notice
' t5 J' j4 _; K# l$ g( E, A z4 uThe use of configuration templates is deprecated and will be removed in the future. Configuration templates will be replaced by cluster scripts, see Section 7.1.5, “Using crmsh's Cluster Scripts”.
. G" V; A7 Q* A) j3 y4 R
! u/ O5 A3 l+ l. T4 GConfiguration templates are ready-made cluster configurations for crmsh. Do not confuse them with the resource templates (as described in Section 7.4.3, “Creating Resource Templates”). Those are templates for the cluster and not for the crm shell.
6 [ T# A2 ~" ^5 D, P. G W/ s, c5 B8 z7 z2 ^6 L
Configuration templates require minimum effort to be tailored to the particular user's needs. Whenever a template creates a configuration, warning messages give hints which can be edited later for further customization.- U) l0 D7 { K4 C
/ I0 o. o% a9 }6 O) M: ]2 MThe following procedure shows how to create a simple yet functional Apache configuration:
8 n0 d9 i) d( p' ?( u. Z$ i: R) e& W# Q- a
Log in as root and start the crm interactive shell:
6 z3 s8 ^1 f6 d. E
# n0 ^! @9 r' {- z( v5 ?3 Ecrm configure
0 A8 p9 h/ A P W' S. W) ACOPY
, l$ x# C v, p4 m' O* W: F$ PCreate a new configuration from a configuration template:8 e! H- Q7 d# N
3 i* E9 F5 ^: y' W5 X9 y4 [
Switch to the template subcommand:
: u: H9 C. _5 U0 i! o& K0 ?/ A( U5 w. z1 D! b! [0 H D
template
. h& }: N1 s5 V9 x$ qCOPY
# L& [8 s3 Y8 E' DList the available configuration templates:. r- C9 J. ` V( z; T
4 Q! s/ j; w! c' u- a4 T! {list templates9 U. m- c% {9 m8 l
gfs2-base filesystem virtual-ip apache clvm ocfs2 gfs29 C3 S5 [! ]: @% p" H
COPY, w$ q1 k6 n+ x0 r
Decide which configuration template you need. As we need an Apache configuration, we select the apache template and name it g-intranet:0 L4 X' X: Z6 x: Y# B
0 Y2 y0 F7 q0 i& P2 E2 ~5 unew g-intranet apache
$ ~- ?1 @1 k E- @, j: m; QINFO: pulling in template apache# u% ~$ \5 i/ R; P% K. k
INFO: pulling in template virtual-ip
) Z' I- l7 F( v: RCOPY
" L( V Y0 d$ U. B8 `Define your parameters:) g- v5 ~" n4 C5 I* e2 o3 M f
1 r4 m( H# C; f; I: }List the configuration you have created:1 a( g5 m4 j" I: G9 x
6 G/ [, g* u; w: v# ` n5 v$ d; Z+ p' Clist
2 Q2 D6 ?# v% W# L! wg-intranet
* z* H$ S" b2 }+ J! BCOPY
Y* g% L4 s5 g9 k% \& N+ QDisplay the minimum required changes that need to be filled out by you:: ~+ G2 A3 ?3 h6 k: y
7 x# I; k5 T$ q5 |' w- Wshow: ]6 D2 B% J6 g6 v4 ~) U
ERROR: 23: required parameter ip not set
# [! R: X) h( U* `! n' pERROR: 61: required parameter id not set
/ a* K9 H$ s6 g8 z4 j I1 ?" NERROR: 65: required parameter configfile not set
" c$ c- M+ x: x. b5 ACOPY9 p0 x' v8 D9 l2 Z2 \4 N0 A
Invoke your preferred text editor and fill out all lines that have been displayed as errors in Step 3.b:) M8 ^4 r* O3 C7 S5 [1 E- Z* ?3 G
" d) J9 B2 n0 z, ?6 Z
edit- o* B8 ?! o+ h! I$ y7 Z* P0 J- ]
COPY N1 G- u* j# G) _8 B+ m
Show the configuration and check whether it is valid (bold text depends on the configuration you have entered in Step 3.c):6 k7 m1 T! A6 L7 E. V
* Z$ {8 X2 C0 ]5 i. r; O% T* vshow) [. V3 }( T+ \9 {5 |! C: D) i
primitive virtual-ip ocf:heartbeat:IPaddr \1 ^9 }9 D/ p; x* m% [5 r @
params ip="192.168.1.101"5 n4 z* R; |( n2 _# e
primitive apache apache \& D" E" ?3 o7 g0 |! J9 d+ Q
params configfile="/etc/apache2/httpd.conf"
) v/ Y* P, C8 C monitor apache 120s:60s
Y0 }5 p4 u& M7 K2 hgroup g-intranet \
+ E; d3 A* k% r: r& E4 S9 s' b7 Y apache virtual-ip, h" _0 a( B/ w
COPY6 k1 d+ q6 B7 o
Apply the configuration:
4 J% T) E+ {! K+ U7 P9 N6 e# F9 K3 z& N, [( {9 T/ u# _
apply; a. z! G7 ^& ~* l8 e5 _
cd ..
x3 Y7 X( u+ P1 G6 o! Eshow
! G V: Y( w0 j! uCOPY- P& M8 {" v4 g" D) x. N
Submit your changes to the CIB:
! u: K6 `" v6 I! e7 c4 I( u+ t
& I" L$ o3 c; V: Q# X! Ncommit
7 x) d) Q5 x3 V8 ^( V+ oCOPY
* _+ n; ]0 z) r7 P# } t- u! jIt is possible to simplify the commands even more, if you know the details. The above procedure can be summarized with the following command on the shell:& q$ l, u! {6 s$ P
& G! o; j# Q! l$ s$ Mcrm configure template \
* U) V' D6 ~9 i$ [3 N4 `9 \ new g-intranet apache params \
7 j4 c9 v9 F2 g0 u" h1 u' { configfile="/etc/apache2/httpd.conf" ip="192.168.1.101"0 s# C& P( @# J8 i: _
COPY! \( f! u+ @, z' \% Q3 Y' m
If you are inside your internal crm shell, use the following command:
7 n& R1 F% m7 O: s m
4 \* N; `: F5 z1 Jnew intranet apache params \, Y! f8 x& [- h- t! D7 q$ g
configfile="/etc/apache2/httpd.conf" ip="192.168.1.101"
) R* C; P: F# s: o1 o gCOPY
! w9 O8 C) q/ ~& l! c, P* gHowever, the previous command only creates its configuration from the configuration template. It does not apply nor commit it to the CIB.) U+ J9 N: }3 Q: ~# y! i
% r* Z9 k4 Q2 x. ^2 M6 m7.1.7 Testing with Shadow Configuration
5 X; [- i v: L; w/ y/ s c8 s1 ~7 O0 j- o
A shadow configuration is used to test different configuration scenarios. If you have created several shadow configurations, you can test them one by one to see the effects of your changes.
# P' a( G- M) n# [1 d
1 H: d. M! x1 P# M9 |The usual process looks like this:7 r2 K0 q K" O0 ]" R4 d8 F( W
6 J/ c0 u2 x* \- K
Log in as root and start the crm interactive shell:# j B( D5 _# m% W1 @9 L6 w
# X. P! A0 V) I6 Ucrm configure
. b; d( ^% W) \/ rCOPY
: i; C! R" @& x2 V% MCreate a new shadow configuration:3 B7 }, ]1 x/ u2 B2 M
" \. ]& D {- a; Z" icib new myNewConfig
" a! x" [8 f% R/ GINFO: myNewConfig shadow CIB created
# K& _# e) T/ u u! }' dCOPY
) O7 y4 I8 ^" h3 P; UIf you omit the name of the shadow CIB, a temporary name @tmp@ is created.
# _7 z. |! s- A r8 X5 F9 C
) v" v/ X7 g# p0 I# yIf you want to copy the current live configuration into your shadow configuration, use the following command, otherwise skip this step:
$ d. L; j( a- \2 B7 A3 t- N( B7 E* N1 k
crm(myNewConfig)# cib reset myNewConfig: i% q& ]" l( C) N1 T- E
COPY$ M) @; Z% p9 Q; D' y' U
The previous command makes it easier to modify any existing resources later.
+ f8 k3 d7 C. g1 ?- W& ?) E- n
R) ^1 Y% e" s' h& \Make your changes as usual. After you have created the shadow configuration, all changes go there. To save all your changes, use the following command:! s/ d7 e% K, j
- e9 A% W; @1 U. J& L2 x
crm(myNewConfig)# commit
( ]/ K4 D; t/ _2 BCOPY
4 }- q) w% ?) k, l9 g9 N: VIf you need the live cluster configuration again, switch back with the following command:
* {) m6 f, K) v6 ]; t3 v; |6 A) v
2 W0 q. J: ]" ?, G5 g0 r% ~, _crm(myNewConfig)configure# cib use live& r* W8 s* u* R4 {
COPY
1 l$ D- \- a% t" y: b& q n* \7.1.8 Debugging Your Configuration Changes
5 [% X$ q1 u- V& B E* g) }! D% o: f8 A) J! Q
Before loading your configuration changes back into the cluster, it is recommended to review your changes with ptest. The ptest command can show a diagram of actions that will be induced by committing the changes. You need the graphviz package to display the diagrams. The following example is a transcript, adding a monitor operation:
( D% e7 g3 z9 O# [: P, _4 F- ?/ s* G" \
crm configure* b0 v) t# _& c0 X: e9 V& u6 i. x
show fence-bob
+ ^4 C8 z* x! v2 b# wprimitive fence-bob stonith:apcsmart \
3 q& e4 X/ Z0 t& m9 v params hostlist="bob"0 J: Q5 S1 G2 x8 w# Q
monitor fence-bob 120m:60s, r+ b3 D. E, [+ s
show changed
6 A% }" g) r* q: ]primitive fence-bob stonith:apcsmart \
9 p# q' ~2 l$ i9 Q7 u6 C& t params hostlist="bob" \ a" F) `" @7 r( M. @0 |
op monitor interval="120m" timeout="60s"
/ A+ U% u0 Q3 U1 @9 _2 ]1 X8 ^1 Iptest
J" K6 B! X. j: Dcommit
( o0 l8 g+ R8 N2 q+ W, r1 t f2 `COPY
* c$ y+ n0 {' n+ z9 u7.1.9 Cluster Diagram
. ?4 A. _0 D+ X0 ^& ^! G9 s: x) I f0 K, P7 _. m1 ]2 c" N9 c; Q! O& P; E& f
To output a cluster diagram, use the command crm configure graph. It displays the current configuration on its current window, therefore requiring X11.
, f, h$ U% U2 J
0 f' M/ i8 ~2 s& C3 a# rIf you prefer Scalable Vector Graphics (SVG), use the following command:1 ~- `- T4 c; ^9 {' e- [' f
" W' v4 X( l& |
crm configure graph dot config.svg svg" V8 y) |. d- Z4 A5 e
COPY5 Z4 w. x' h& n/ a3 w
7.2 Managing Corosync Configuration
' J9 R+ _7 T6 ~2 C4 { n( V# k/ f7 P/ C9 p" h
Corosync is the underlying messaging layer for most HA clusters. The corosync subcommand provides commands for editing and managing the Corosync configuration.
1 G" L* | P) u; Y j' ?; Q" T
, p* B q! U) s fFor example, to list the status of the cluster, use status:
6 ]& }2 D8 F) |6 v$ E: W; T0 I" P' u d: e" B+ M! w; T
crm corosync status# F* A( u2 S; l7 `; b' v* g
Printing ring status.1 n# j" F; o4 e1 w1 N2 m$ ]% d
Local node ID 175704363
- [6 r3 A- S; p. nRING ID 0% Y" }6 O5 ?! e7 C0 T# _2 r9 `
id = 10.121.9.43
1 ~/ P4 q2 @4 ]9 V g status = ring 0 active with no faults
2 Y0 N: [# ~: s; k' O0 k5 @Quorum information
, Q3 y3 f. t4 ?------------------
Y$ b5 g+ z- S2 _6 C+ ^4 S4 RDate: Thu May 8 16:41:56 2014. Q/ V6 G' i0 D/ ]/ B U4 R8 m
Quorum provider: corosync_votequorum8 j9 t0 {$ c6 e8 q
Nodes: 20 v X( P) c C( B+ v+ s
Node ID: 175704363
) g; A# {. w9 b8 ^Ring ID: 4032* D# ?( {4 T. T) {5 a* r
Quorate: Yes
% }6 ]2 v9 t) {2 ]
9 S* R7 V& @- {; a9 |- IVotequorum information+ P- s& H( h# E/ t
----------------------
1 w0 q9 o! h [4 kExpected votes: 2
+ a+ i9 M3 R) ^ OHighest expected: 2
# U5 |3 T4 v' F( c5 w% \0 zTotal votes: 20 r/ n8 f6 }! |2 U9 \
Quorum: 2/ j j! r. i i1 d' \; p3 e
Flags: Quorate0 s q2 T' [3 n: C0 f
$ Q' e3 z3 j, `# L: X' ?* A" y
Membership information
6 x& r1 M1 c$ _ ` M7 C& L----------------------
# i! D. J) q% S; V, ~% j Nodeid Votes Name( S( V1 a3 L9 Y! ~) n- _
175704363 1 alice.example.com (local)( p+ R" K) L/ |. u+ c6 A9 n
175704619 1 bob.example.com
- i: `3 C# P( v4 |COPY
* a! ^3 Q( i" wThe diff command is very helpful: It compares the Corosync configuration on all nodes (if not stated otherwise) and prints the difference between:# k3 C) S- U5 x/ }
$ `' p3 s3 v- q7 D+ i( y8 j, e! ^; `crm corosync diff; E* o* m# c& p- A' P5 P7 ~
--- bob
! k, @8 b3 |9 ^! \. q: T. F+++ alice/ P4 M2 r6 [. R+ W; {( X9 t
@@ -46,2 +46,2 @@
- P2 k. Y# Y& O5 S- expected_votes: 2
# Y8 d( ~4 W3 ?- _. Y- two_node: 1
7 @" J. r+ Y+ S1 p+ expected_votes: 1
$ d+ B6 e7 K8 p. M4 r% ?$ h+ two_node: 0
9 W3 Q. @& ~% d" RCOPY
0 J, J- H& X( C2 F0 `For more details, see http://crmsh.nongnu.org/crm.8.html#cmdhelp_corosync.* R$ I3 k* U2 i0 D p( Z
$ G$ }" T* i7 [! L3 r8 ~* y4 A
7.3 Configuring Global Cluster Options
* g2 U' l. `) j" a+ a
+ M0 S: D" d3 D( V! B% NGlobal cluster options control how the cluster behaves when confronted with certain situations. The predefined values can usually be kept. However, to make key functions of your cluster work correctly, you need to adjust the following parameters after basic cluster setup:
4 c9 o q+ c: h. I
# ^6 y+ e: W, m1 {PROCEDURE 7.1: MODIFYING GLOBAL CLUSTER OPTIONS WITH crm
0 S6 d5 k c- X* x
1 i- i) G0 [! [0 r4 xLog in as root and start the crm tool:; A+ |/ m- o/ z
' P" M' S& c) u# q6 t+ o1 Kcrm configure) B9 ]" u& a% E0 S& w/ o6 I0 b; R. h6 l
COPY4 m. {0 J, ?! n" J5 H r. J
Use the following commands to set the options for two-node clusters only:8 B3 h+ [( }" ^; R/ {, T+ J; f
# v- A( M( C3 ?, L8 a1 T
property no-quorum-policy=stop$ f! [" E$ f5 Z. h! k
property stonith-enabled=true8 K. o5 [) u5 ]- E, t3 L' ^3 I
COPY
* p4 v+ k6 }* c8 u: ?. b9 ]" zImportantImportant: No Support Without STONITH
8 y& u4 r/ `, A! vA cluster without STONITH is not supported.
1 L1 T% }) J+ O2 O& ^' a( M, @8 w2 i, f4 w( ^+ R' H
Show your changes:. m3 X7 y( c6 F! h v
( `& v8 x" c8 }( J
show
& U% |5 @8 R G) S( qproperty $id="cib-bootstrap-options" \1 k( n4 f& X2 j4 K! s: |
dc-version="1.1.1-530add2a3721a0ecccb24660a97dbfdaa3e68f51" \
2 C p$ Y0 E3 j: L- Y cluster-infrastructure="corosync" \
0 S7 m7 x* T' P0 H( t+ G3 f: V expected-quorum-votes="2" \
4 m* |7 `# {" x5 j7 N) N* Q no-quorum-policy="stop" \6 h" \% U2 [0 ^* C
stonith-enabled="true"" x4 t# r* ?0 u/ S/ b. L+ `
COPY
. H: N. @, ? m! W3 c$ u1 }- ^' ^' HCommit your changes and exit:1 A6 c: P0 x% ^: v0 |4 I% J6 u
3 `! r+ g, m! q" k
commit
3 N5 V- U) `0 q( o6 wexit9 l% x" T E+ C4 P/ Z7 J
COPY9 N1 w$ D9 W8 A, c
7.4 Configuring Cluster Resources3 k7 g# g6 o4 K! k0 G
0 e- t( j6 M* j* ^As a cluster administrator, you need to create cluster resources for every resource or application you run on servers in your cluster. Cluster resources can include Web sites, e-mail servers, databases, file systems, virtual machines, and any other server-based applications or services you want to make available to users at all times.
% J% C0 b) Q$ C& t
. k u1 `( v- R6 g* L) Q1 mFor an overview of resource types you can create, refer to Section 5.3.3, “Types of Resources”.9 u p' n. e$ J! j- x# t9 j
; V ~4 d$ T7 X1 F4 S7.4.1 Loading Cluster Resources from a File# b0 ?$ P- b7 j3 f9 Q8 F! D
! |; Q& y- I: X( L/ s" @* M
Parts or all of the configuration can be loaded from a local file or a network URL. Three different methods can be defined:
5 k' Z% X2 `: B4 o% v8 D# `; d- {* J5 U0 r A2 u
replace
/ W) U3 A- g+ O5 K3 H4 E& V: eThis option replaces the current configuration with the new source configuration.7 A2 N6 s& b; F0 d/ t) n. N
7 E C" G* R7 ]0 P! yupdate
# d8 I9 H; a/ wThis option tries to import the source configuration. It adds new items or updates existing items to the current configuration.: a O9 J; b: X; ]8 G5 _
! N0 k5 D/ h3 S) u2 }( V8 o
push
3 H" p# w$ N4 z5 ~0 [This option imports the content from the source into the current configuration (same as update). However, it removes objects that are not available in the new configuration.
6 a, e: @0 e; p/ V4 @
& |0 {* s8 a; {, m! |) m% BTo load the new configuration from the file mycluster-config.txt use the following syntax:: L0 ~. g1 N- \3 L4 M/ E J Z
' W! K6 F$ j+ w7 w1 {% R1 Ncrm configure load push mycluster-config.txt
* f" q) n2 H9 J% g2 }2 mCOPY
. a! M$ H/ |- v% B0 \: W7.4.2 Creating Cluster Resources& n! r2 J# y6 Z: A6 N1 G2 J
2 Q0 h3 _6 c2 E& bThere are three types of RAs (Resource Agents) available with the cluster (for background information, see Section 5.3.2, “Supported Resource Agent Classes”). To add a new resource to the cluster, proceed as follows:
9 N' j8 |8 m. y7 ?$ P
3 H6 O7 s T+ C: c9 g: w. Z& r6 w: ?Log in as root and start the crm tool:
& D8 \- y6 B* c9 {1 C5 g8 b0 q8 ^4 F' p& S# R8 B6 M% m7 |
crm configure4 Z7 f* O3 x* z7 q3 \) j! x, B
COPY$ l1 h9 e4 }& p' }( u
Configure a primitive IP address:2 z: t+ T& x; J, q
( W Y8 m8 c; F/ |" P( t. _ h. I
primitive myIP IPaddr \; w; c. O N5 O* f
params ip=127.0.0.99 op monitor interval=60s# b" u6 w y6 W+ X3 i
COPY
! U G2 S" H! h( N) pThe previous command configures a “primitive” with the name myIP. You need to choose a class (here ocf), provider (heartbeat), and type (IPaddr). Furthermore, this primitive expects other parameters like the IP address. Change the address to your setup./ x' G2 G% q) c- v3 v
4 l+ K; ]" e) ]5 J# p2 D3 h6 M( ?Display and review the changes you have made:# T( W" I: }8 B( k
6 `# F$ n4 h- Q, k/ G3 w. v+ B8 ushow
$ _( C, B2 B9 D6 i: C+ ]COPY3 w+ G# k4 C3 y5 }8 L
Commit your changes to take effect:& i P# t& L% J/ K5 k
+ Q! ^% l" H* n: y2 F3 hcommit
- R, W, P. z2 C2 @2 [2 {: i' W7 ]COPY
5 V3 y" O4 I( i) f# E$ m, T7.4.3 Creating Resource Templates& P% c% ?# N' a
+ r& x5 m9 W8 v0 }9 A0 uIf you want to create several resources with similar configurations, a resource template simplifies the task. See also Section 5.5.3, “Resource Templates and Constraints” for some basic background information. Do not confuse them with the “normal” templates from Section 7.1.6, “Using Configuration Templates”. Use the rsc_template command to get familiar with the syntax:
w6 V9 l; G( t" ~+ i* j. v* C: C! g5 f0 l/ t
crm configure rsc_template! v/ o# L' x$ B! e& s
usage: rsc_template <name> [<class>:[<provider>:]]<type>' Y$ w3 H' V% A
[params <param>=<value> [<param>=<value>...]]8 A/ @9 a( l: X9 I! v" e2 a7 l
[meta <attribute>=<value> [<attribute>=<value>...]]- H/ a. m8 S) d, n- d) B
[utilization <attribute>=<value> [<attribute>=<value>...]]* S9 D* y/ `7 l( k7 w3 J
[operations id_spec l9 n9 O) ?+ G
[op op_type [<attribute>=<value>...] ...]]
5 A* H+ W6 B: s e1 f4 DCOPY
& Z; o3 `3 k1 { YFor example, the following command creates a new resource template with the name BigVM derived from the ocf:heartbeat:Xen resource and some default values and operations:; S- U p. R- T) D) v
. M0 }2 I) H8 M& }+ G
rsc_template BigVM ocf:heartbeat:Xen \1 X" w) u5 L, I% e
params allow_mem_management="true" \6 z% u @/ ?7 s/ v+ f
op monitor timeout=60s interval=15s \
2 `* g. y; F4 `# Z) d+ R2 d/ _8 h op stop timeout=10m \* O8 p1 y: i7 f! F1 j' M
op start timeout=10m
: B; J; k: G6 }2 g5 ]" T3 cCOPY
# g5 N& B- K9 j5 yOnce you defined the new resource template, you can use it in primitives or reference it in order, colocation, or rsc_ticket constraints. To reference the resource template, use the @ sign:6 X2 u" h( W# z8 v+ |
9 t& X6 m- f* A
primitive MyVM1 @BigVM \* J- @, T e: L4 c
params xmfile="/etc/xen/shared-vm/MyVM1" name="MyVM1"# ?% W" a! [2 s0 R ^
COPY
& m- ?( {1 `+ k- GThe new primitive MyVM1 is going to inherit everything from the BigVM resource templates. For example, the equivalent of the above two would be:8 u3 z4 s/ X% \9 r3 H, t- s
- m* [$ J4 z) E K; J" C
primitive MyVM1 Xen \; ^ O$ y% c5 R* o3 a4 m, k
params xmfile="/etc/xen/shared-vm/MyVM1" name="MyVM1" \5 h& p5 W3 K) {0 A S9 z' \7 V4 P
params allow_mem_management="true" \, Y" ~( S, ~5 J
op monitor timeout=60s interval=15s \
$ M* I8 _! z# y- F! O' T y2 e op stop timeout=10m \$ A1 g( w0 _6 v H! c8 W
op start timeout=10m
; p1 k, ?0 F9 i" p+ C+ NCOPY8 x2 n9 ~* ^1 l# \, }
If you want to overwrite some options or operations, add them to your (primitive) definition. For example, the following new primitive MyVM2 doubles the timeout for monitor operations but leaves others untouched:3 L/ l4 ^2 Y( A# w `5 X
$ ~1 \$ r9 ]9 \8 v
primitive MyVM2 @BigVM \
9 X% e/ B8 d$ s3 {* K) T8 l& n4 H. p params xmfile="/etc/xen/shared-vm/MyVM2" name="MyVM2" \
0 |7 [5 F0 e2 ~5 C; o0 \3 n u. w op monitor timeout=120s interval=30s3 j" K: f, @5 p) C2 | h* G
COPY
4 l, ~( z" q7 X1 a# D& `8 @, ]0 eA resource template may be referenced in constraints to stand for all primitives which are derived from that template. This helps to produce a more concise and clear cluster configuration. Resource template references are allowed in all constraints except location constraints. Colocation constraints may not contain more than one template reference.
4 o9 [; p3 A4 u: ?+ T6 Y+ Z; m# A" s+ C6 r1 f
7.4.4 Creating a STONITH Resource
- Y1 i( O$ t( B( W1 i/ v e9 d9 `/ U* ? `" d# b
From the crm perspective, a STONITH device is just another resource. To create a STONITH resource, proceed as follows:
! e; y" P b1 {" E% R. o+ S) k5 l* F
. A" |8 {/ o4 I+ V; jLog in as root and start the crm interactive shell:8 h+ R; z; F, b3 f) ^2 W" ^
2 H) a8 X/ Y: n2 mcrm configure- c5 s; g7 B! ?, H0 W7 j6 I
COPY [. ?0 Y; ]2 v: m) ^7 E i; C
Get a list of all STONITH types with the following command:. t e* K _% R3 `. G7 ]. F. m
1 {% K \4 u9 e' lra list stonith( B) _; I, X$ S3 \/ B
apcmaster apcmastersnmp apcsmart5 _: ~3 z. l- h. p6 d' ^
baytech bladehpi cyclades# X( |. c O& I( q+ Z6 P
drac3 external/drac5 external/dracmc-telnet
8 i! S. a0 X6 Q& u1 }external/hetzner external/hmchttp external/ibmrsa1 K+ v! r: q5 `7 B. p! {" _ d
external/ibmrsa-telnet external/ipmi external/ippower9258
2 @+ ^8 ]" k7 ~; M0 qexternal/kdumpcheck external/libvirt external/nut0 D( o1 q8 g8 L3 P4 ^; r
external/rackpdu external/riloe external/sbd8 O1 p. t" |3 f4 \& n
external/vcenter external/vmware external/xen0/ \# O7 _2 ]6 \5 }) @
external/xen0-ha fence_legacy ibmhmc$ k1 @. Q5 m- @! i
ipmilan meatware nw_rpc100s: b) H( d) I+ e0 d
rcd_serial rps10 suicide; |$ ~& z5 t6 A
wti_mpc wti_nps4 M, g7 F; k% g' ~' w
COPY
9 l7 U$ e/ ^) @7 j0 ]' B8 ?9 J- H6 UChoose a STONITH type from the above list and view the list of possible options. Use the following command:# ^" g. b7 H7 S1 X* T- f) V! {
# s9 O2 X3 W1 V! T2 L7 Rra info stonith:external/ipmi' g, M* s; N7 D" L- o; i
IPMI STONITH external device (stonith:external/ipmi)
* N; y- c6 S! \+ j1 J- h
% j3 E+ Q" X) X+ m( c/ Lipmitool based power management. Apparently, the power off
; J$ |+ I1 x2 I+ k1 U Hmethod of ipmitool is intercepted by ACPI which then makes! X' X9 T6 t) T; _2 f" f4 G4 L3 l
a regular shutdown. If case of a split brain on a two-node" _8 b4 R; e$ r& A' ~3 z) ~- b' N
it may happen that no node survives. For two-node clusters
8 V3 Y# o6 T' O4 muse only the reset method.' y; s: h- u( H0 B q
, Z7 w( ~% {* l. iParameters (* denotes required, [] the default):; A3 K: `: L+ q9 b- K5 F/ q; _
( f/ }. p2 A; V1 Uhostname (string): Hostname2 O, N% R+ |/ y) U5 `7 X0 z$ V
The name of the host to be managed by this STONITH device.5 r# c: b3 A. |7 }. w. h8 A
...7 U$ T$ j! ~* \0 M: K: T6 |
COPY8 U( I: u: A% o7 q: m) b. ~4 i
Create the STONITH resource with the stonith class, the type you have chosen in Step 3, and the respective parameters if needed, for example:9 U" }2 X% I0 i w
j& e7 R4 V; j' Y7 aconfigure
8 o( A7 L# L3 \) d% dprimitive my-stonith stonith:external/ipmi \
: q+ x9 L7 R5 ~ params hostname="alice" \
8 c2 W/ \. r9 s9 O0 M4 e4 u5 a ipaddr="192.168.1.221" \
( A4 O! G6 H. D% _ userid="admin" passwd="secret" \. A( {, w7 y+ J1 {
op monitor interval=60m timeout=120s* x8 P9 |6 U( ]; M6 o
COPY
/ W9 r1 @8 ?# R& `2 q8 v- [6 J7.4.5 Configuring Resource Constraints
! J! o0 c7 }3 d+ U6 B) Y5 L% ?2 p: { f7 U4 J* ]5 H- S4 D
Having all the resources configured is only one part of the job. Even if the cluster knows all needed resources, it might still not be able to handle them correctly. For example, try not to mount the file system on the slave node of DRBD (in fact, this would fail with DRBD). Define constraints to make these kind of information available to the cluster.: T0 `" j: E6 G/ G. t8 @! h0 }9 M
2 T7 [; p: Q: r. l& J& }For more information about constraints, see Section 5.5, “Resource Constraints”.
2 W0 p% j: c* w# [$ ~
) ^, l2 I3 A! \7.4.5.1 Locational Constraints6 A& d; ^) `; b& G& T; s
6 N0 l! h! z* `8 [
The location command defines on which nodes a resource may be run, may not be run or is preferred to be run.
2 p3 \$ L% q' s. ~' E9 m
! K2 C( q8 t4 U4 sThis type of constraint may be added multiple times for each resource. All location constraints are evaluated for a given resource. A simple example that expresses a preference to run the resource fs1 on the node with the name alice to 100 would be the following:1 W9 j0 M. `5 C8 h
8 w/ R$ j: d8 j) a( I; W9 Y
location loc-fs1 fs1 100: alice
, V9 C/ X' U8 t. d0 @! k$ eCOPY
* d9 ~7 Z5 @; G d+ ?- xAnother example is a location with ping:) e9 T" e- I4 l( v. ?
2 m: `: o* G# R* I8 v& |0 Oprimitive ping ping \
8 C. x$ u# a5 ^( w! }1 ^ params name=ping dampen=5s multiplier=100 host_list="r1 r2"
$ l* N; O$ ^7 M3 A/ }4 m1 _: |clone cl-ping ping meta interleave=true+ X+ X$ k2 w7 |3 V5 s
location loc-node_pref internal_www \
% P# M0 Z5 m5 J rule 50: #uname eq alice \, B: l$ \/ R- o$ c* P5 y+ x
rule ping: defined ping
w% k# h# s7 L# { H4 wCOPY8 ^: a% M2 E' A2 m1 y3 I O2 c( w3 [
The parameter host_list is a space-separated list of hosts to ping and count. Another use case for location constraints are grouping primitives as a resource set. This can be useful if several resources depend on, for example, a ping attribute for network connectivity. In former times, the -inf/ping rules needed to be duplicated several times in the configuration, making it unnecessarily complex.
; l: y9 A }9 {: P- U$ `/ o5 W! e
' d9 N$ ]/ v' wThe following example creates a resource set loc-alice, referencing the virtual IP addresses vip1 and vip2:% I1 E2 E' n; O6 p, Q5 k& C
3 A% K+ U! m8 A3 b0 s% I Eprimitive vip1 IPaddr2 params ip=192.168.1.5
* u# H- Y% ~( x4 bprimitive vip2 IPaddr2 params ip=192.168.1.6
- N4 n' D8 D4 A8 q/ |& Hlocation loc-alice { vip1 vip2 } inf: alice% G, C/ ?; v- {; G, Z- _9 d
COPY
. @+ |" J. T* }# i4 dIn some cases it is much more efficient and convenient to use resource patterns for your location command. A resource pattern is a regular expression between two slashes. For example, the above virtual IP addresses can be all matched with the following:( @+ q3 c4 N, Y/ S3 [5 k' r
/ H% B" l5 d, J" m1 s: tlocation loc-alice /vip.*/ inf: alice
s/ r. e" ^. S" e1 `COPY0 I' a* l% o/ z0 {! ]
7.4.5.2 Colocational Constraints
* G. K* e' ]# v1 ~, N0 R
% }. c: i6 i- C) Y1 `, MThe colocation command is used to define what resources should run on the same or on different hosts.
P1 o# B8 T6 N C7 r, W: v( g. [9 h( [. ?
It is only possible to set a score of either +inf or -inf, defining resources that must always or must never run on the same node. It is also possible to use non-infinite scores. In that case the colocation is called advisory and the cluster may decide not to follow them in favor of not stopping other resources if there is a conflict.* _& w- a3 d. m' T2 q; Q/ i; T9 M
2 ^9 i8 m: |6 q( w+ z5 C" Z1 y
For example, to run the resources with the IDs filesystem_resource and nfs_group always on the same host, use the following constraint:; C& r5 E4 _& q8 z
( Q$ `/ V" y1 `7 u; {; R% zcolocation nfs_on_filesystem inf: nfs_group filesystem_resource
, {) r7 }& S6 w5 V' ICOPY3 e+ h+ d3 _$ Q9 H; A( A
For a master slave configuration, it is necessary to know if the current node is a master in addition to running the resource locally.
) o) D/ b" d( x% h8 c
+ M3 [; R) z' n, J0 E, p7.4.5.3 Collocating Sets for Resources Without Dependency. v' O: `* j9 A4 m
: ~. H4 ?- p& \* h3 o; Q1 Y6 n
Sometimes it is useful to be able to place a group of resources on the same node (defining a colocation constraint), but without having hard dependencies between the resources.
4 @: h$ J+ |6 T, n; [+ _! Q" S) X7 i+ d$ w" c
Use the command weak-bond if you want to place resources on the same node, but without any action if one of them fails.
$ V' z* X; x7 N; | Q
& {) N( B. g* e0 Z7 h \crm configure assist weak-bond RES1 RES2 v: |9 g& P# A2 P+ x& W
COPY
; a* l2 V6 V6 h+ tThe implementation of weak-bond creates a dummy resource and a colocation constraint with the given resources automatically.
, R& B* |, c: h' n% n1 v- Z8 `7 B1 f/ s# G( J( d, \
7.4.5.4 Ordering Constraints" j9 y n- P5 h- ]
+ f9 N5 m: c4 C+ e9 Z1 EThe order command defines a sequence of action./ Q/ `$ g/ |: t( J6 h
; e2 B7 z9 K6 _& u# TSometimes it is necessary to provide an order of resource actions or operations. For example, you cannot mount a file system before the device is available to a system. Ordering constraints can be used to start or stop a service right before or after a different resource meets a special condition, such as being started, stopped, or promoted to master.0 a7 }6 W6 f3 J" O' C6 K: i+ t: A
$ n7 ~8 a: m5 O& ]
Use the following command in the crm shell to configure an ordering constraint:
% K: L5 L0 b& r6 ]2 l7 g
7 z' O# @/ y6 z \order nfs_after_filesystem mandatory: filesystem_resource nfs_group) _: l" E6 ~" v) R: g7 P" M4 C
COPY
( J3 l4 G5 T: R2 _% x$ ?4 u, f7.4.5.5 Constraints for the Example Configuration p+ b0 M3 [0 t1 n- t3 C
" ~7 ^9 q6 M+ HThe example used for this section would not work without additional constraints. It is essential that all resources run on the same machine as the master of the DRBD resource. The DRBD resource must be master before any other resource starts. Trying to mount the DRBD device when it is not the master simply fails. The following constraints must be fulfilled:( s9 ]4 v9 z) j( m$ W2 ~' l5 N
' ]% V+ v3 \2 r5 o$ h) EThe file system must always be on the same node as the master of the DRBD resource.
7 r0 t! n; l( n/ k2 e" _8 \& b
; X* _! Q& t4 l8 ^" qcolocation filesystem_on_master inf: \
9 N! ]0 x" P, C- _ filesystem_resource drbd_resource:Master
9 V, k8 l& ^1 ?! o0 hCOPY2 N1 \4 L' E: t7 [( N( k
The NFS server and the IP address must be on the same node as the file system.5 |7 f. j. F% u; P. S- ]1 O
% X6 ^8 X$ t8 ^' ~/ I' v4 m9 Qcolocation nfs_with_fs inf: \! E4 K5 M" x6 `* b4 n' W" T6 Y
nfs_group filesystem_resource
& ~+ y3 }: k- ?( CCOPY
7 s5 N0 Z- @, E2 D0 G# w5 lThe NFS server and the IP address start after the file system is mounted:
* M& K; x# I8 x8 [( \) R0 L1 h6 v2 d9 @, \# Z: V& e
order nfs_second mandatory: \
& {# [" s* Z$ u* Y; C! _, X filesystem_resource:start nfs_group9 L7 [3 T9 G8 t" ` h% L" K
COPY
$ y0 @0 I k+ ?# m' OThe file system must be mounted on a node after the DRBD resource is promoted to master on this node.
U% L) @$ J. y) L: ]2 d C. X u9 Q; S3 C% Y
order drbd_first inf: \
0 |0 L! E. J5 o. E' x drbd_resource:promote filesystem_resource:start/ v) D" o- K' t0 i; p0 F
COPY. o0 ~5 o6 M; } J3 }& \3 M* ^
7.4.6 Specifying Resource Failover Nodes
: s0 T, G$ I% f& X0 s3 W9 E- T. p8 h1 e4 |- C
To determine a resource failover, use the meta attribute migration-threshold. In case failcount exceeds migration-threshold on all nodes, the resource will remain stopped. For example:3 i5 P, O# B: N4 l Z
& h& s( p7 |" \/ Z0 t$ rlocation rsc1-alice rsc1 100: alice
/ R3 C% P, s$ Q8 \COPY1 }) T( U/ W1 g \# h" Q
Normally, rsc1 prefers to run on alice. If it fails there, migration-threshold is checked and compared to the failcount. If failcount >= migration-threshold then it is migrated to the node with the next best preference.
( F" z$ D6 f/ D; }& x' E8 M( n
) Z$ O" l& w% w+ U2 A: nStart failures set the failcount to inf depend on the start-failure-is-fatal option. Stop failures cause fencing. If there is no STONITH defined, the resource will not migrate.
, C. L& E6 c: N- {9 Y. }
3 t. n7 F$ a) Z. @4 MFor an overview, refer to Section 5.5.4, “Failover Nodes”., Y( t( a$ I+ l8 n& |3 M
8 m. C! k( N: d; v0 l* a
7.4.7 Specifying Resource Failback Nodes (Resource Stickiness)
5 l" P& F: [$ T G3 Z1 ^8 f5 c' j( N
A resource might fail back to its original node when that node is back online and in the cluster. To prevent a resource from failing back to the node that it was running on, or to specify a different node for the resource to fail back to, change its resource stickiness value. You can either specify resource stickiness when you are creating a resource or afterward.
. x5 s: S# @+ Y3 v6 j. r
7 G3 R; I9 [( t! \/ N( JFor an overview, refer to Section 5.5.5, “Failback Nodes”.+ l. a5 \& O" J. y% i8 e/ }" Z8 @
+ w7 T1 ], Z( I! A5 x: O7.4.8 Configuring Placement of Resources Based on Load Impact
+ `# Z1 @- ?! r+ p
3 C7 G4 ^4 | K' QSome resources may have specific capacity requirements such as minimum amount of memory. Otherwise, they may fail to start completely or run with degraded performance.
: [, e5 [" `% u3 Q" ?
/ r* s5 B' ]) P4 ?To take this into account, SUSE Linux Enterprise High Availability allows you to specify the following parameters:
% I5 H7 A& T# M7 ^
2 d& K1 L: X" W. }The capacity a certain node provides.
, D, F5 i, o% @
- l! h6 w) ~' x; PThe capacity a certain resource requires.
/ A6 y9 R, u8 d. j4 Y7 v% B/ g5 w L' O4 c; h/ g2 J
An overall strategy for placement of resources.# `! S% }& y$ D6 i- e& ^# V
/ Z, y* R3 V: S, g3 T5 R2 s5 Y, mFor detailed background information about the parameters and a configuration example, refer to Section 5.5.6, “Placing Resources Based on Their Load Impact”.1 E& W$ X9 e4 J+ E9 F4 [4 k! ^
, ~5 s B* G9 G( }% d( ]To configure the resource's requirements and the capacity a node provides, use utilization attributes. You can name the utilization attributes according to your preferences and define as many name/value pairs as your configuration needs. In certain cases, some agents update the utilization themselves, for example the VirtualDomain.8 ]0 x5 k3 O+ A c. A1 {: d
5 k2 D& F* t: d2 C* G8 M/ [# zIn the following example, we assume that you already have a basic configuration of cluster nodes and resources. You now additionally want to configure the capacities a certain node provides and the capacity a certain resource requires.
0 N; U# n# E: O9 J+ ~; A" a7 ^5 h
PROCEDURE 7.2: ADDING OR MODIFYING UTILIZATION ATTRIBUTES WITH crm9 k% u: E% |- M5 r/ Y6 ^& T' F) u
: a* e* ]1 F* N) GLog in as root and start the crm interactive shell:% B$ x. m+ {. P5 H
% _. U+ z! D, q" G' b. z$ j
crm configure0 {3 d+ z) p$ z: I( Q+ B0 I# J" R& w
COPY
2 O9 {# w$ h! s0 `' fTo specify the capacity a node provides, use the following command and replace the placeholder NODE_1 with the name of your node:" `! ^& S! Q! v1 P- N6 b% v
; b/ X$ ]6 X' k
node NODE_1 utilization hv_memory=16384 cpu=8# h, Y" e3 X5 x) d* I& r5 c8 A
COPY
9 g- i8 z3 h2 e8 o. |With these values, NODE_1 would be assumed to provide 16GB of memory and 8 CPU cores to resources.
2 j0 w" g' [6 {% u1 i+ B, g- b6 }# n) V+ |- ]5 Q
To specify the capacity a resource requires, use:6 e' Y" E4 t- |5 W0 ~
8 h' d3 o, k; hprimitive xen1 Xen ... \
$ i. h& L3 I8 j2 A utilization hv_memory=4096 cpu=4
, F6 u+ `; r3 s% rCOPY
1 \2 W+ C! w* j2 |% DThis would make the resource consume 4096 of those memory units from NODE_1, and 4 of the CPU units./ f+ F& E% l# I& I" c
! \9 U6 v' |/ ^! h8 FConfigure the placement strategy with the property command:' X$ \5 p- y! r; e+ O
0 Q4 D; U2 w1 C9 i
property ..., X/ n c/ d4 K6 J5 [1 o
COPY
( U7 P8 z E* ?The following values are available:
, v3 w$ ] V8 G* c: q2 _! k% n5 F2 P0 I! g6 b2 k* N/ j
default (default value)7 J# i$ U- u1 N) l1 ^2 k# y- u
Utilization values are not considered. Resources are allocated according to location scoring. If scores are equal, resources are evenly distributed across nodes.
4 s5 [; ?3 R! ~1 Z6 `5 d3 K f. M; U2 V* S- w3 S
utilization g' x8 X& s, B& }
Utilization values are considered when deciding if a node has enough free capacity to satisfy a resource's requirements. However, load-balancing is still done based on the number of resources allocated to a node.- r, J9 E* v" `5 _; L
$ W5 F! p9 ?6 t# p7 a, W1 L% z/ }minimal: Q; F; ^3 ?) V
Utilization values are considered when deciding if a node has enough free capacity to satisfy a resource's requirements. An attempt is made to concentrate the resources on as few nodes as possible (to achieve power savings on the remaining nodes).
0 K' o. ^* }+ Y5 y* @* x, w* L. `5 J! ]: ]- @
balanced
8 ^' e2 {$ o9 a0 Z, `' B1 mUtilization values are considered when deciding if a node has enough free capacity to satisfy a resource's requirements. An attempt is made to distribute the resources evenly, thus optimizing resource performance.
' t5 N% K) ^ W3 v$ }- [! Q+ X7 O' z
NoteNote: Configuring Resource Priorities: p$ }* Y* |; h# g$ E- f4 \" A
The available placement strategies are best-effort—they do not yet use complex heuristic solvers to always reach optimum allocation results. Ensure that resource priorities are properly set so that your most important resources are scheduled first.
8 o1 d9 f) }$ V$ y! P0 V8 F5 v: L3 h0 z
Commit your changes before leaving crmsh:8 m# W5 m- C, u# Y
6 r. F! q& w+ E- Z
commit/ z2 v4 l7 e# i% B) N
COPY0 Y9 C" c. b7 C. g* g
The following example demonstrates a three node cluster of equal nodes, with 4 virtual machines:
' \2 S- }- \% j7 }* ^$ m# D0 Z* h9 v
node alice utilization hv_memory="4000"# P) E$ G+ ]# C
node bob utilization hv_memory="4000"3 k( J3 {! v, r, w2 P) }& K
node charlie utilization hv_memory="4000"
7 C+ R6 i# O- {! D+ Z |3 ~primitive xenA Xen \
$ ^& y& I2 P6 g utilization hv_memory="3500" meta priority="10" \( y' s/ O! j7 [1 I5 M- K! X3 P0 D
params xmfile="/etc/xen/shared-vm/vm1"! [3 j- Z6 X/ z/ t5 ^
primitive xenB Xen \1 D9 a0 ^/ i- d/ N2 a5 p
utilization hv_memory="2000" meta priority="1" \/ q6 D$ h/ O. g2 z, I
params xmfile="/etc/xen/shared-vm/vm2"
X3 n# Y/ v$ w2 Eprimitive xenC Xen \: X/ {9 k, s O) U: {# W1 Q
utilization hv_memory="2000" meta priority="1" \
7 S. a( J# h, a ]2 z" D _2 ^+ H# y params xmfile="/etc/xen/shared-vm/vm3"* x1 p4 l, E" ^. n: h' O
primitive xenD Xen \
" v. e) j) P$ d utilization hv_memory="1000" meta priority="5" \$ y- o( }, B* {: x8 |
params xmfile="/etc/xen/shared-vm/vm4"& L" o( S5 P" B8 p
property placement-strategy="minimal", F2 g9 a& | F6 Q
COPY/ f( d+ B' _8 B6 M4 K( Q7 l, j
With all three nodes up, xenA will be placed onto a node first, followed by xenD. xenB and xenC would either be allocated together or one of them with xenD.0 h# N/ z, ?3 j
% |7 ~! m! }+ T: r9 l- O7 ]- u
If one node failed, too little total memory would be available to host them all. xenA would be ensured to be allocated, as would xenD. However, only one of xenB or xenC could still be placed, and since their priority is equal, the result is not defined yet. To resolve this ambiguity as well, you would need to set a higher priority for either one.
1 S$ Y: J8 ^4 Q8 [* |
; ], ]" b Z* d6 _- @( C2 O! F7.4.9 Configuring Resource Monitoring k" S& i9 M" C; @, k: q
; {7 e# }& ?: t& k1 I# t6 r& qTo monitor a resource, there are two possibilities: either define a monitor operation with the op keyword or use the monitor command. The following example configures an Apache resource and monitors it every 60 seconds with the op keyword:) W& I5 T# \7 [$ _' D
( `! B! Q& [5 J+ d& y5 g; d
primitive apache apache \, J J3 [ Z0 \' @3 C; l' c" J
params ... \8 `; s1 w& I* P/ b6 I; i
op monitor interval=60s timeout=30s
1 \4 c/ }( T5 }COPY
1 j! G! Q9 u8 B' L$ N# U6 UThe same can be done with:4 j) q: ]9 d& D2 h3 L
+ J( d$ `3 J3 s/ w# F
primitive apache apache \
2 A8 S4 A1 k& _& V9 m& h; ^ params ...
' T6 C+ ~: \/ o Gmonitor apache 60s:30s& ~% G5 c3 N5 J. m+ O8 \# C
COPY, C) B9 w- \( B: V- g
For an overview, refer to Section 5.4, “Resource Monitoring”.
% |/ U* a7 D7 o& Y; N$ v% L/ c
. P) ?. p1 D- C) \& ~8 u7.4.10 Configuring a Cluster Resource Group$ L8 h% ]9 z. R( \5 R) {9 z
) B# ]% F z8 j: FOne of the most common elements of a cluster is a set of resources that needs to be located together. Start sequentially and stop in the reverse order. To simplify this configuration we support the concept of groups. The following example creates two primitives (an IP address and an e-mail resource):
$ O7 V2 u% e# j; N. W9 W9 ~8 {) e2 y3 I
Run the crm command as system administrator. The prompt changes to crm(live).
+ t Y5 I |% M# b% i1 I% \2 h7 u
2 S/ {! {3 p/ H, Z1 l) T. W) w6 u! uConfigure the primitives:
3 v: i! r' I8 M0 y% b
. |/ w+ R0 O- ]# b9 kconfigure5 m z/ @/ }( P+ _. e" G6 `* y8 Q0 ?
primitive Public-IP ocf:heartbeat:IPaddr \
* n$ D, C, Z1 h$ K params ip=1.2.3.4 id= Public-IP% ]' j" E. h* o7 K' g
primitive Email systemd:postfix \; n6 U% ] N1 y
params id=Email9 M+ i F/ q2 T" L
COPY
/ U0 h+ s8 }8 Y0 p) EGroup the primitives with their relevant identifiers in the correct order:: |6 t' Y- x5 {) @
5 I4 ]! ^0 d) u# p
group g-mailsvc Public-IP Email
$ a" x, Z! g6 c9 WCOPY( Y1 _: f$ e4 N$ m) @3 o
To change the order of a group member, use the modgroup command from the configure subcommand. Use the following commands to move the primitive Email before Public-IP. (This is just to demonstrate the feature):7 ]; `6 j1 \- Y5 a" j" ?; L
! N& s1 F$ P5 a& q! h- v3 Amodgroup g-mailsvc add Email before Public-IP
; v u$ R6 X, Q' n% cCOPY
* Q7 E q( O6 F+ a( n" h, ZTo remove a resource from a group (for example, Email), use this command:! U: O _, ]$ S' _7 W
" Y/ H5 h# |5 f9 F1 gmodgroup g-mailsvc remove Email, L2 G7 h6 T8 C) x5 y, `: l; r1 q
COPY8 j- _/ z& O! }# o& X
For an overview, refer to Section 5.3.5.1, “Groups”.
8 b, p, Q8 c" t- v, s# Q5 \: U% i! m7 d" x! }$ r' E: h
7.4.11 Configuring a Clone Resource5 f! l) V" o* @" E4 ^" O9 C" a
2 h. T5 C9 I# j. R" uClones were initially conceived as a convenient way to start N instances of an IP resource and have them distributed throughout the cluster for load balancing. They have turned out to be useful for several other purposes, including integrating with DLM, the fencing subsystem and OCFS2. You can clone any resource, provided the resource agent supports it./ n/ K& `; w3 j( _
2 a( o' Y1 h) H1 ]6 C
Learn more about cloned resources in Section 5.3.5.2, “Clones”.
# Z% G5 a3 l) u+ S I
% z: f3 X( |- z0 t7.4.11.1 Creating Anonymous Clone Resources
, E( X9 u7 C4 i& Z/ c3 D8 s8 Q
3 N% A: `5 J9 K# m* Y2 r" v& YTo create an anonymous clone resource, first create a primitive resource and then refer to it with the clone command. Do the following:
4 m/ O$ W+ \# P `7 G' l, H5 W# Z2 ?8 m0 g
Log in as root and start the crm interactive shell:+ p I: T8 L( {2 S
/ S" t3 b: |3 Q6 lcrm configure
h+ j. s4 ]" w% Y( P% ^$ P @COPY
) M* L( f7 Q; ^' JConfigure the primitive, for example:" ], d O" c/ s) R3 d
, n8 ?6 r% n3 |2 C5 }7 r2 }2 K5 ]primitive Apache apache
& P9 j# Z' v8 v4 p# aCOPY7 J$ H' a# o4 T* _# D: `' y
Clone the primitive:- n( Z0 @- j1 Q5 ?
/ D# i7 @) H9 p/ ?
clone cl-apache Apache
, f! Q* a$ H) ?" l4 S7 i* kCOPY
1 k1 M% D! {0 h9 ]3 [' ~2 D; O7.4.11.2 Creating Stateful/Multi-State Clone Resources
- I& E5 C+ h% Y3 r: q
8 `! E8 _ T& @) B( j7 q: r8 ZMulti-state resources are a specialization of clones. This type allows the instances to be in one of two operating modes, be it active/passive, primary/secondary, or master/slave.! j# ]: c& \) c2 q: Y; s
4 T% W) `* ~+ m3 x; \8 @$ w( OTo create a stateful clone resource, first create a primitive resource and then the multi-state resource. The multi-state resource must support at least promote and demote operations.
% ~* E( Y! |. E0 A# o) b; a7 R3 H- N) }* h
Log in as root and start the crm interactive shell:2 H2 v/ g* ~2 f/ g7 Y1 T; C7 H( ?7 z
3 f6 m7 |. w% P$ ^
crm configure* q }) L6 s% u+ f) o
COPY
1 g) L" d8 ^# H. I) @Configure the primitive. Change the intervals if needed:6 s+ k; b7 U/ L, i
6 N; d+ v" T! T" t* t7 h& F; dprimitive my-rsc ocf:myCorp:myAppl \0 \/ ^( N; u/ H& }7 J3 O1 {
op monitor interval=60 \0 o( g2 L5 b& S# K
op monitor interval=61 role=Master; ?+ E! g* f5 K7 `
COPY, ?2 c3 M( y- P; k, q" C" H
Create the multi-state resource:/ h! ]. r$ J: [/ c! c, }" b
/ e2 t5 Z2 V% m1 }7 }. a
ms ms-rsc my-rsc/ ?; u+ H6 Y6 [* v4 y& c7 ? J. c
COPY
0 x7 U4 D2 R" f5 R( K2 f' d% d4 |7.5 Managing Cluster Resources1 b' ~' J( ?& r5 O
0 f: H1 N0 M- n$ Y
Apart from the possibility to configure your cluster resources, the crm tool also allows you to manage existing resources. The following subsections gives you an overview.
$ k6 U5 H7 m+ w8 A7 I3 Q* b4 J1 \
7.5.1 Showing Cluster Resources
9 s: L$ P0 I" W7 G& f% S& G& e
When administering a cluster the command crm configure show lists the current CIB objects like cluster configuration, global options, primitives, and others:
: L( ?; B6 R4 c( O9 ?
5 c% j1 @! x8 ?. n5 T- c! rcrm configure show
: C4 u5 R L# y9 h" A1 Xnode 178326192: alice
2 ~* ~( s' E# Qnode 178326448: bob
# `+ ^9 ~0 ^4 ~6 I) B9 oprimitive admin_addr IPaddr2 \) P* N; p9 G5 @+ p7 n) q
params ip=192.168.2.1 \ v' J% G7 s7 y* X
op monitor interval=10 timeout=20; ?0 q p7 k3 i9 z1 S# ~& _
primitive stonith-sbd stonith:external/sbd \
" L4 C* d. \; I8 ]+ O% |/ F) i6 R params pcmk_delay_max=304 r, `8 V7 C! R, t0 R# A
property cib-bootstrap-options: \% `( g: B6 r5 e
have-watchdog=true \, a# @5 k. \2 u1 I9 N
dc-version=1.1.15-17.1-e174ec8 \$ ~0 a% d$ ~/ k; F5 a8 \7 A1 K. U
cluster-infrastructure=corosync \2 }, D/ ]6 i6 x2 u
cluster-name=hacluster \
+ _0 N' G6 e3 @ F stonith-enabled=true \
7 q; Y1 Y" H- P4 [. c6 |4 m5 o0 ? placement-strategy=balanced \
q9 i" @/ D5 F# b standby-mode=true& j' m5 L: E9 E' P/ N2 U& z
rsc_defaults rsc-options: \" m \- Q8 Z7 }9 D8 m, T/ ~1 T
resource-stickiness=1 \/ {! B. k5 Z! B/ e; U3 V o7 J5 W! S
migration-threshold=3 s% o. S! S5 k5 c i
op_defaults op-options: \9 l/ p% g+ ~. ~ T
timeout=600 \
5 L' y. i% }7 d* Q" U" c record-pending=true; B/ J# l7 C: X
COPY# u" p/ J; j' x, }* g4 |+ [) Y9 L& R
In case you have lots of resources, the output of show is too verbose. To restrict the output, use the name of the resource. For example, to list the properties of the primitive admin_addr only, append the resource name to show:4 k3 a& `' i/ q" { e
4 w5 Q3 d+ `& w4 c$ k1 U9 I: [crm configure show admin_addr9 C6 O8 p9 H2 i7 k, }8 F' _4 L
primitive admin_addr IPaddr2 \* p" r. H5 c4 Z3 ?
params ip=192.168.2.1 \
- _# ]/ n! r3 B( C7 |9 W op monitor interval=10 timeout=202 ?- ~& a* H, b9 j3 m- F' D4 E; {
COPY/ f2 U. ~' T4 h, M) w6 [
However, in some cases, you want to limit the output of specific resources even more. This can be achieved with filters. Filters limit the output to specific components. For example, to list the nodes only, use type:node:0 A: }7 l# V' A2 _
2 A! K/ a8 g: i: P8 o5 f7 Zcrm configure show type:node
3 L+ X: l% \6 O/ p1 O& rnode 178326192: alice
9 D, L- \! q3 j( A% hnode 178326448: bob3 V% b; {! @: W. k7 u5 n9 K
COPY$ Z2 ^; `; P& i" v O" K" H4 D9 v
In case you are also interested in primitives, use the or operator:
- a/ k' |* x3 h4 ~2 Y
/ \7 K6 A; @7 _2 ?& f3 z7 k* ncrm configure show type:node or type:primitive
( U, U. m8 s: ^8 L1 Anode 178326192: alice
$ o5 e E( a) Vnode 178326448: bob
6 M) B# R& R3 @primitive admin_addr IPaddr2 \
3 k8 @1 v5 {+ ^ ^0 W5 q9 w( U params ip=192.168.2.1 \
; R; x c3 @$ b. A8 U% G op monitor interval=10 timeout=20# d* Y4 v) U% D& Z0 ~9 ^3 }3 a
primitive stonith-sbd stonith:external/sbd \
0 ^4 B& C$ q, h r8 {9 { params pcmk_delay_max=30
7 L1 W: n$ _6 C4 }$ ~9 u. SCOPY
2 j' q9 Y v' d# R8 ~% h5 eFurthermore, to search for an object that starts with a certain string, use this notation:) n c9 t" ^" o9 P7 X
6 o) W" p1 I- P% i/ [
crm configure show type:primitive and and 'admin*'( r) u1 T& ~6 l _6 B
primitive admin_addr IPaddr2 \( _$ b% L- B1 S
params ip=192.168.2.1 \2 L0 ^! E# o/ v+ v$ C
op monitor interval=10 timeout=201 U0 H7 A3 Z9 H
COPY+ Q6 k; m: V% o
To list all available types, enter crm configure show type: and press the →| key. The Bash completion will give you a list of all types.
7 ^0 Y% V/ G a) {2 F. {6 {1 a
* C8 b) ?( `% W7 u/ v5 |9 a0 h7.5.2 Starting a New Cluster Resource
9 E) E* S2 U: W2 @) K# y( n+ l1 c# v4 \
To start a new cluster resource you need the respective identifier. Proceed as follows:
0 |/ S8 F8 b+ }+ j, r: z9 ~) l4 c2 v2 c0 O- ~- s8 M h5 Q1 a
Log in as root and start the crm interactive shell:9 d& ~8 x' w/ T/ p7 c
' \+ F" F6 L' K) r2 ?! vcrm4 v7 a& a; b$ c9 r$ b2 V9 C
COPY
' b7 F# a6 b( W0 C" d. `9 m1 g- iSwitch to the resource level:7 t; E% p+ K9 I
5 s3 \( w% N8 }5 s0 S5 e3 ?resource8 f& C8 t/ E9 u; W2 c& S
COPY
$ E- D& j7 \1 E7 M+ S, KStart the resource with start and press the →| key to show all known resources:
& O+ i( r& y6 J: D
8 W6 r' _1 {& Z7 C$ h% v5 P) Fstart ID# w' _7 W5 E3 i1 U) z& U p
COPY
: |8 ` _$ U3 Q. [" l7.5.3 Stopping a Cluster Resource
- ?/ Q- V4 t" H8 E% N/ L8 o+ R: I7 Z, ?/ i
To stop one or more existing cluster resources you need the respective identifier(s). Proceed as follows:- @* V. A# G, t/ ]$ D, Q- a+ Q
! I X7 v% K/ y6 Y
Log in as root and start the crm interactive shell:
0 |- w" H$ g5 |0 U; k# s! r+ h
9 p. C) u7 v3 [0 b8 J# i, @" R, ccrm
+ F8 z( k: D! Y; v2 N3 RCOPY" x. l% ]0 y7 U H% E
Switch to the resource level:
' l. w' q5 Z* ?& I d: I/ Q' o! @4 n/ m! i2 t
resource
6 R% h5 J! s& z x4 H; d5 |COPY
& g1 V& n1 ?8 Q6 GStop the resource with stop and press the →| key to show all known resources:1 X, X/ \9 \: f! @5 K
4 B% J- e) g) b8 z6 Y2 G# |( Gstop ID! v4 g/ }1 ]# Z+ }4 F1 l
COPY
5 w8 u: e' F9 H4 J8 _It's possible to stop multiple resources at once:: j: ^$ M E3 D V2 u0 U) y; D
3 E6 s$ w2 ~: L& ~- q" G6 V
stop ID1 ID2 ...
9 f$ S+ Y# G! |5 b, rCOPY
9 a% n3 q) V* k. Z) x8 J Y, C7.5.4 Cleaning Up Resources
: y* ]* ]; L& i; X( {4 G& @0 Z- P: X* T: [0 Z s, {
A resource will be automatically restarted if it fails, but each failure raises the resource's failcount. If a migration-threshold has been set for that resource, the node will no longer be allowed to run the resource when the number of failures has reached the migration threshold.
) N$ [* Z, Z: C. Z# [! d" f+ o. Z5 z' @6 k
Open a shell and log in as user root." b% J9 R0 y2 m) t
* {6 m+ i) b3 n" t- W% AGet a list of all your resources:
: \5 S) i* U/ t4 Y+ U. V4 a; D
; N/ I5 J% U y. q/ f8 Ncrm resource list
s* F8 }8 P7 `- s ...
) {/ ?5 S/ Z. D. K( H1 ZResource Group: dlm-clvm:1
' }4 I# q6 B& T. i dlm:1 (ocf:pacemaker:controld) Started* f% O+ B3 b b' ^
clvm:1 (ocf:heartbeat:clvm) Started9 e0 D" N: c& y( `( v% b9 ]/ G
COPY
$ ?% e( f* V Z& ~To clean up the resource dlm, for example:" x- ?' t0 }0 C% k" r
4 ^ }6 W1 b2 Q3 L, `crm resource cleanup dlm
# {* y% O# M! t" oCOPY# @( W5 R, x, i
7.5.5 Removing a Cluster Resource
4 c6 q: r- j6 P+ K# b
. P- S6 H/ X) [, i' h8 QProceed as follows to remove a cluster resource:
* _) H1 A* N, J+ y$ z9 v
f& b# D; U5 P$ {Log in as root and start the crm interactive shell:+ O& S% Q6 G$ v8 G9 b# e/ `! G
+ Y; w( B# ^( V5 tcrm configure
, ?7 o7 e, C1 g# O& V% H" MCOPY% `: j* d8 [! F) Z9 p B. f
Run the following command to get a list of your resources:, r& Y g; U- [, d) } u( _
w" ]: H, V0 F+ A+ D' vresource status
9 z q0 N' m, Y+ A5 G, z& BCOPY# G F' i' Z+ Y! l- K4 E9 _0 q# a
For example, the output can look like this (whereas myIP is the relevant identifier of your resource):6 J* K2 i) e2 Z$ u
* d* I" @4 z) @% X. o: o/ g& ]
myIP (ocf:IPaddr:heartbeat) ...
2 M# o1 j1 z" ^4 W' Y0 HCOPY: p# g2 F: R) C1 l2 @+ f* q' Q
Delete the resource with the relevant identifier (which implies a commit too):
+ Z8 M8 r7 e6 A) X) X2 `6 u/ x
$ ~# E5 G8 i8 B& h; u8 d* Jconfigure delete YOUR_ID5 @$ Z! h' r" l1 s6 d6 Y
COPY! O5 R3 K' a( \/ d) I! ]
Commit the changes:% X6 f& w- _3 [) N5 b
/ ~5 j0 d4 i/ _: c' hconfigure commit
0 p B6 b5 T8 v# _! o# K8 p- c6 u2 XCOPY
; ^. O/ a" Y* z4 P7.5.6 Migrating a Cluster Resource
5 ?; C1 E3 N2 u/ h- N
- K2 D( Y1 D3 E' m0 w5 `! ]Although resources are configured to automatically fail over (or migrate) to other nodes of the cluster if a hardware or software failure occurs, you can also manually move a resource to another node using either Hawk2 or the command line.
$ Y# o1 g, o+ j* q
2 @# U! C4 N5 O) n0 k% b+ O$ d1 [' DUse the migrate command for this task. For example, to migrate the resource ipaddress1 to a cluster node named bob, use these commands:
; }+ D; V |: c& c8 A# _ X- G6 d: d% p, A9 G
crm resource, s" k8 f' A9 Z3 [. h4 O) V! x+ z
migrate ipaddress1 bob7 L! ]6 E' b: p9 S) h/ a
COPY- }& a w( u5 Y
7.5.7 Grouping/Tagging Resources$ @5 K# h7 S4 y' N. F3 E; f& b' [( @0 m
* N# `6 N3 H/ J! L, NTags are a way to refer to multiple resources at once, without creating any colocation or ordering relationship between them. This can be useful for grouping conceptually related resources. For example, if you have several resources related to a database, create a tag called databases and add all resources related to the database to this tag:$ M# T6 u b* z( s; w
$ T2 o2 w7 ~! |0 D; Acrm configure tag databases: db1 db2 db3
9 O, }, o; {8 h) ]COPY5 ]/ v- p: ]6 \/ h) g- Z
This allows you to start them all with a single command:3 Y3 J$ @" M. U
5 t c: {" Z( q3 \! }+ b6 @. xcrm resource start databases0 c4 U# I# w9 l! b/ w! z; E
COPY1 p9 q9 _* _# I c: a6 q8 s
Similarly, you can stop them all too:
, Y2 A) [) a; z1 L( d7 R, W) S) a: w# P4 @+ h% O$ A1 w5 e
crm resource stop databases. r5 ~0 U/ H3 _6 H4 L
COPY( e$ J: E9 J \) }
7.5.8 Getting Health Status
% q3 k2 j5 S9 D$ k& H
" } a; x3 G3 F9 z c* L3 aThe “health” status of a cluster or node can be displayed with so called scripts. A script can perform different tasks—they are not targeted to health. However, for this subsection, we focus on how to get the health status.3 ~& c- T- T, M! f. T
2 [5 b9 M! Y. q4 Z
To get all the details about the health command, use describe:
" |4 z' z% X% r0 W8 A, U8 a V6 ]0 Z; ^
crm script describe health. U6 m& ^4 r0 V' ?& s6 F- w5 w
COPY* p" `- p& |( K" T7 a8 ]0 N
It shows a description and a list of all parameters and their default values. To execute a script, use run:
( i4 D: l V1 w- S, A! k) a _2 z% V# q) d% y6 ]6 K* x- P
crm script run health
! f+ n- q1 f5 I# XCOPY7 z$ D2 e$ D2 H' p4 Q% l o
If you prefer to run only one step from the suite, the describe command lists all available steps in the Steps category.
4 @/ C0 `& r+ e' T: n1 e
" ?7 S& |0 I: e/ F4 `9 j( ^For example, the following command executes the first step of the health command. The output is stored in the health.json file for further investigation:
h: n. h6 A a+ Z5 y* f+ h) L+ G
crm script run health
D6 ?6 ?( Y0 C a1 N+ p statefile='health.json'
. o- Q6 ~. Z+ A1 b! ^9 g& WCOPY3 B9 C' ?: g3 c t. _
It is also possible to run the above commands with crm cluster health., ?( w" r1 I' h9 e7 Y
* l- G5 \2 F8 t1 R: l2 S j- i
For additional information regarding scripts, see http://crmsh.github.io/scripts/.
$ H/ O1 Z, J: h4 E6 o2 F# [0 ~! v: q* @0 E' t+ G) P9 I
7.6 Setting Passwords Independent of cib.xml
# S% `/ f: I: a8 `% ]8 o( O. T
# D; T: m W. LIn case your cluster configuration contains sensitive information, such as passwords, it should be stored in local files. That way, these parameters will never be logged or leaked in support reports.
8 g4 m2 T8 K$ ?9 H& v" R2 N0 [+ [( |& E/ ~( v9 p, M) _
Before using secret, better run the show command first to get an overview of all your resources:
$ e+ f+ b" H. X* E4 M: I X4 J" K$ o/ x5 o4 {$ z
crm configure show" [( t) s: r Y" N7 T+ d4 `
primitive mydb mysql \
5 g T4 c/ D2 j# V, s" r2 B9 m params replication_user=admin ...
# h0 z8 ^4 {" M5 y- H1 @COPY
! {3 l9 y, p4 j uIf you want to set a password for the above mydb resource, use the following commands:% m+ x: g- ?8 g G X% d3 R
' a& r7 D5 n5 @% K, Z# h/ h5 m1 Tcrm resource secret mydb set passwd linux1 H" D P6 n6 s) ^- N. ^3 A6 |
INFO: syncing /var/lib/heartbeat/lrm/secrets/mydb/passwd to [your node list]
2 j6 {+ y9 `/ }" b8 j) L' [! ECOPY
4 q* K( g) T8 L' L6 P g8 @' }You can get the saved password back with:
8 Z1 n. O, `/ i+ q
2 K I2 c0 [+ k* ?1 ccrm resource secret mydb show passwd+ P: Z$ {1 g% _, I* @
linux6 E3 L4 M' P+ [. H
COPY
7 ?- H2 B9 g' p9 o9 v0 }Note that the parameters need to be synchronized between nodes; the crm resource secret command will take care of that. We highly recommend to only use this command to manage secret parameters.
s: B& A" f+ N7 z. n, Z$ J
. f( L* e( Z6 ^. f4 e7.7 Retrieving History Information! R2 |4 U! f* ], J; O5 e
! V# V& T& ?8 Q) h: N2 W# IInvestigating the cluster history is a complex task. To simplify this task, crmsh contains the history command with its subcommands. It is assumed SSH is configured correctly.
3 {/ p( {) Z: }! `2 b7 r5 b9 n6 `6 N5 n8 Z
Each cluster moves states, migrates resources, or starts important processes. All these actions can be retrieved by subcommands of history.
2 V+ Z( ^( @& _
( b3 }- _' c6 I# r& i( sBy default, all history commands look at the events of the last hour. To change this time frame, use the limit subcommand. The syntax is:
0 _3 T/ x9 P8 h' f) ~
8 @# L0 R* S) H: y/ @& Lcrm history. D# {( r- i9 A0 }' W6 J
limit FROM_TIME [TO_TIME]- g- Z- D: s) B& q8 k
COPY _" }$ A, U4 |2 `3 m3 D
Some valid examples include:
# Y# `. @. Q! `& k' O
. b" R0 T9 X8 t7 B4 Y/ E2 {- O2 `limit4:00pm , limit16:00, t5 j9 H- Q+ ^7 q( e
Both commands mean the same, today at 4pm.
, A" e$ w, k7 v
% ]# N/ \9 f8 r3 Ulimit2012/01/12 6pm
. m! V, F5 v4 ?# D- u2 vJanuary 12th 2012 at 6pm
1 c" ` a+ E6 g# w" p+ X& k( Z
/ A, |. g9 I9 I. nlimit"Sun 5 20:46"( r/ f- Z) H3 K$ E6 a8 f3 L
In the current year of the current month at Sunday the 5th at 8:46pm9 S- Q) J( i' e) {# X' Y! L* _6 ]
% Q$ H1 S6 [1 A6 n$ p# r
Find more examples and how to create time frames at http://labix.org/python-dateutil.
0 {% r/ H; [) g& J4 F! F6 p3 u5 U; {* w. K4 Z- t1 ^% A
The info subcommand shows all the parameters which are covered by the crm report:
$ v( `% \% u I
4 u6 L) @3 s2 |& j5 pinfo. r+ d m& j& |
Source: live' z& {& T2 Y, H, G' y$ U/ `: Z
Period: 2012-01-12 14:10:56 - end
a4 Z- w+ p7 @5 F9 MNodes: alice/ `: r& q, {* z/ S9 Z" t: U# a6 R( L
Groups:
/ G' v( J4 L7 Y' N4 ]- V1 y4 lResources:
* F4 m- B& t. |- Z2 oCOPY
5 M- F' E/ G# b4 l0 r2 nTo limit crm report to certain parameters view the available options with the subcommand help.8 G( Q# e) Q5 ^
% C( \8 c( P8 x7 d& {# gTo narrow down the level of detail, use the subcommand detail with a level:
. A" ~ E+ [8 p; m
! d8 G9 k' Y3 ~) U9 adetail 1% e" J( `( @; m; h: T2 \8 G5 Q% Q
COPY
0 q4 |3 p) v+ E: P, XThe higher the number, the more detailed your report will be. Default is 0 (zero). r' a$ O& ^$ i- E( h. |
7 p8 F$ a% R! s- X/ _5 t, I) i) kAfter you have set above parameters, use log to show the log messages.* F: M8 @ L! V, p
* X' |9 B: ]# C7 O7 E
To display the last transition, use the following command:
3 M% B w! R8 D4 y& s$ ?3 n& ^
( C! I, _, h! U2 ]2 g% _transition -1
6 S( e: ]* ]9 }( o) U- C0 oINFO: fetching new logs, please wait ...
m# }, U* J" D" g5 VCOPY# m/ V0 O' Q% c2 y9 F+ J
This command fetches the logs and runs dotty (from the graphviz package) to show the transition graph. The shell opens the log file which you can browse with the ↓ and ↑ cursor keys.
1 A: m Y% o5 x' w ` j5 _0 q1 j
; }$ M0 v5 `/ g1 [If you do not want to open the transition graph, use the nograph option:
% L$ E- i( C: e+ i* u% z1 ^
5 v1 d0 z' k, t) b+ V R2 Dtransition -1 nograph
4 k7 |$ R) c$ O: J9 i% Y8 { |
|