|
|
楼主 |
发表于 2023-12-22 11:54:34
|
显示全部楼层
crm options user hacluster
: A+ L# A# y( d/ `- LCOPY/ a+ t. _) l+ E
Note that you need to set up /etc/sudoers so that sudo does not ask for a password.( `5 L/ E' M8 Y" d1 K7 \& p H
- s0 T$ j. K- S2 A/ K
7.1 crmsh—Overview
" K. l3 C% W$ r7 p" x, O _, h! L7 k5 o1 M+ u" z3 D3 s
The 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.7 {- r( b1 B) i
3 [! [, Q1 E" H. p# U, T6 ~
TipTip: Interactive crm Prompt) C5 w5 _" |: u8 K U
By 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:
- u! j1 F& p, E# m
$ W$ ^( i: {$ } k- ?5 _4 cCOPY
# S- D0 f+ u0 b4 L1 NFor 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:
: F1 H# |) C1 m
, w) M/ K$ B& s! L- h8 {* \! lCOPY
) i0 V+ L4 f) K# u% e7.1.1 Getting Help: `) t9 R W& K
3 z0 r6 ^6 S. i* c8 f: @Help can be accessed in several ways:
' x3 s! v- |& m# G& \- w, n8 O' T3 F: c
To output the usage of crm and its command line options:: K* `: l& d8 ?. `' {0 s. U
: j$ ^: _# C0 W( T4 L! ^
crm --help6 |5 s1 l7 f: t7 M. |: d, p0 u
COPY9 t* O; `/ O6 q. d d3 B3 F
To give a list of all available commands:
4 J9 K( F. b& l
' E! ^4 S# r' Scrm help
; {8 b6 p1 { h4 U4 ~COPY% r3 c0 _) _0 z' L; J4 ^2 q1 m
To access other help sections, not just the command reference:
: G' D) K* E4 Q2 }4 c: a& i
% O& D3 L4 ^7 P" o; o+ m7 j" ~crm help topics% @8 p1 a* Q" Z7 d$ v6 ]9 Q1 T
COPY& p+ _3 z% n1 S
To view the extensive help text of the configure subcommand:
7 _* b/ c' T! P8 P1 _+ }; E* L# L8 G% @( U" i" J7 [; K, ?
crm configure help
: R' q8 O: U' ]# ^$ }+ OCOPY
3 @+ u6 V+ X/ d Q# K# ZTo print the syntax, its usage, and examples of the group subcommand of configure:$ K0 p( N+ {' R0 B% P
" X% [5 t( |8 y& N
crm configure help group1 X" s( h& R8 z3 E+ |. s9 l
COPY. R9 K* D/ N: ]% n9 y
This is the same:: L5 ~6 J5 j' p* f- E( ]7 D
; Q3 P3 u6 A* T: A8 X
crm help configure group) a" g! f. t; B! C
COPY
0 G! a" x- A/ p* @6 @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.
! B6 h2 P7 B1 Z8 S0 ~8 k2 h; K2 Y8 x
TipTip: Use Tab Completion in Bash and Interactive Shell
7 i$ n4 T5 Y% z) U# s4 [* ]% w1 vThe 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.
" m: {9 }" P+ ~' `6 t: s" c R3 [0 b( Y) t/ s' g) T* T: P: F
7.1.2 Executing crmsh's Subcommands
7 x8 P# V: l2 O# o/ g- g/ d- a l7 C$ E2 F y) {9 u
The crm command itself can be used in the following ways:; F( x. P( n2 e- ?& |3 B$ ]
' ~/ j; }6 m* @3 l2 E/ ^: y" O) l
Directly: 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).- [: t& O6 N, r k D
( a) Y% M* b! k' I! j! fIt 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.
+ c+ G8 G; G2 X9 c7 O6 m. }$ _; E" x* i" F* ?1 N& a
Another 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:+ h- T+ V' j7 L2 K' B
5 m0 n7 p# K: {9 ]1 H. n
crm primitive ipaddr IPaddr2 params ip=192.168.0.55/ {/ X: q/ m" b
COPY+ a, \4 H* q5 Y
is equivalent to this line:- c! |! ~, Q5 C- g
# S/ T/ s5 c& T/ G
crm primitive ipaddr IPaddr2 ip=192.168.0.55
; `5 Z! N& @2 E7 iCOPY
5 u' F- ~+ p! a0 n3 g9 }: k. dAs crm Shell Script: Crm shell scripts contain subcommands of crm. For more information, see Section 7.1.4, “Using crmsh's Shell Scripts”.+ f# u. p# B( f5 N
8 S( `& p# Y3 X2 q i$ j) RAs 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.- `' e" w. t" ?# y$ n. f
0 J! O5 T: Z" @5 `; y
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”.$ A% r6 Q% K/ F, i. y" Y4 w
, j9 ?( N" A' U3 W) K9 l! yInteractive 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.
2 g/ H% D% u# O" c, e5 H
" Z8 g! U ~/ Q7 o3 \! nFor 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.
8 \3 m1 Z: {. O5 l: f2 @1 ?+ c/ c9 X
You can enter the level directly by typing crm and the respective subcommand(s) without any options and press Enter.
& g0 u: M9 ~8 D4 L
; o G! x" |% N Q- cThe internal shell supports also tab completion for subcommands and resources. Type the beginning of a command, press →| and crm completes the respective object.
Q/ I8 a/ W7 a) @) R7 W
9 v5 L7 V0 y2 n4 n4 qIn 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.
2 k2 y: G% J% ?
; d; C% c/ `6 L' z: n1 k) [NoteNote: Differentiate Between Management and Configuration Subcommands
1 Z6 y' p% V; G% x* VThe crm tool has management capability (the subcommands resource and node) and can be used for configuration (cib, configure).! ]+ O; g. b l2 {& o1 F: n+ l* j
( M, x8 N8 J+ T5 ~0 s9 V# H R
The following subsections give you an overview of some important aspects of the crm tool.4 V8 {* {6 d1 E( e& D
; ^9 C9 M" @4 v7.1.3 Displaying Information about OCF Resource Agents% u, {, S3 W. c# D
0 }& g3 D5 {+ T' [: L* f
As 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”):# {* o3 [" N" R( q+ |
- m% E6 V# e2 Q' c8 b& j
crm ra
3 T' _, R# H2 u) ]# }- a1 M3 WCOPY7 g) P [* _0 g1 Y+ ~1 ]5 m
The command classes lists all classes and providers:
0 ^8 B4 i8 y+ M3 H* N
% M/ m5 {% ~: Y! g/ e4 Aclasses. W" x; V( U6 t5 b& _- C
lsb
- ]. b/ W- j9 {: a7 c: ^ ocf / heartbeat linbit lvm2 ocfs2 pacemaker
+ N( k: C1 L6 I3 Z/ L" D" h z service
% {# Z! J: h$ V; Q7 n w: Q g stonith P7 m/ [1 ?9 k4 X* u, g# M( k
systemd
( @' f4 A# ?& \/ F4 bCOPY z9 O% z8 I1 G1 U4 k
To get an overview of all available resource agents for a class (and provider) use the list command:9 ?1 }, s9 X; ]- u s' i
$ p) w2 X9 b; e1 Qlist ocf
6 U# `( ~+ ~1 wAoEtarget AudibleAlarm CTDB ClusterMon8 E o+ T9 B5 y/ Z o7 f, h
Delay Dummy EvmsSCC Evmsd
6 a) {- f1 {4 O* g3 f. O) oFilesystem HealthCPU HealthSMART ICP
( x8 @$ }) @8 _- LIPaddr IPaddr2 IPsrcaddr IPv6addr
9 M: i6 \0 ?! l0 M( GLVM LinuxSCSI MailTo ManageRAID8 F" c1 }; e7 j: s
ManageVE Pure-FTPd Raid1 Route
% j: |% k0 [8 L- q! E% d7 QSAPDatabase SAPInstance SendArp ServeRAID) Y% ^! u' C( e: s( U+ Q
...( H6 o* h$ n# s/ v `# \* S% S
COPY
$ `1 F9 w8 {* ^' J$ \# kAn overview of a resource agent can be viewed with info:" t. v4 t* z7 A. r3 v/ ?" J
: U7 i8 u* `5 a2 x6 ~
info ocf:linbit:drbd
' Z4 b+ C; F! p4 \This resource agent manages a DRBD* resource
, ]2 O% a0 F3 V0 _1 T$ Pas a master/slave resource. DRBD is a shared-nothing replicated storage
! ~( @$ O# B5 @1 ]device. (ocf:linbit:drbd)' c! y& i/ U" p' B$ {* g; c
9 q: Z, E' c, J2 E8 l
Master/Slave OCF Resource Agent for DRBD" J( M+ w# s6 c# c
4 _& q5 j( E# m+ p. T
Parameters (* denotes required, [] the default):
$ Y( ?/ [3 W& R& T5 K0 I2 [
0 s/ d1 F) C# r2 ?# Y7 v% Ydrbd_resource* (string): drbd resource name) f5 n) ?3 [! i& i: R3 R
The name of the drbd resource from the drbd.conf file.# |8 D( q* M F4 k" ^
% L! N& `, O% w# U( Q' p0 k( u9 A
drbdconf (string, [/etc/drbd.conf]): Path to drbd.conf
+ ?8 P& G7 l/ o9 ` ` Full path to the drbd.conf file.
) y5 ~; B* @, T. _. O6 ?
X5 o* ~2 {& `Operations' defaults (advisory minimum):
$ q2 O) n2 O+ l1 m: l5 T( y# g& c% B5 D8 ~, }: j: J+ y) Q
start timeout=240
2 f& P3 _ z/ J' V2 y promote timeout=90+ |" b; [$ X5 o/ J9 t
demote timeout=909 H7 W# ^, {+ M; @- O f
notify timeout=90
3 h5 K* r% I5 g9 V stop timeout=100
( l2 W" ~( b+ J) N. _ monitor_Slave_0 interval=20 timeout=20 start-delay=1m
. t& m# x5 n: \3 t monitor_Master_0 interval=10 timeout=20 start-delay=1m/ u! @( s0 H7 C1 b% W x
COPY
! x2 _3 n4 y$ t" i6 x) j) u1 M7 j( YLeave the viewer by pressing Q.
7 r- i( I6 P6 [% C) p- W
9 ?+ Y. [ z! KTipTip: Use crm Directly1 c/ x" o; ]' i) D- D
In 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.) f# } h2 f( B8 J/ L6 X; o
: L) g* [9 e' m0 G
7.1.4 Using crmsh's Shell Scripts$ l" j' a+ t: T3 g
2 G' s: g) W, Z: _2 n( t) [6 ~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.
/ t& \, d/ v' z6 F+ }% m; Y* v
1 M8 q9 f j6 l& F- J3 ^4 ^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:
7 {2 z" P6 ]* R2 ~% d6 n L
8 Q& `- j" A4 G( n I2 K9 I+ fEXAMPLE 7.1: A SIMPLE CRMSH SHELL SCRIPT! o$ c* Y4 f9 h2 V
# n" ^8 W2 l9 _7 q
# A small example file with some crm subcommands {1 w) u! u8 U7 W
status( I0 N. }8 }2 T" ]$ D
node list
2 A( c& H) R! L) Z3 s1 {7 y/ @COPY
0 t6 j% ]# m) NAny 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.
* H* N6 E0 g/ U- P! _
2 A, B. i: _$ y ]' bTo use this script, use one of the following methods:7 U: a( h2 N) ~
: o8 V) r: X% hcrm -f example.cli% M& V7 H, k: A
crm < example.cli2 F! Z9 C5 g5 D) u w1 P* t( r
COPY
5 t+ G# p2 W+ }/ }# g+ N" X9 V7.1.5 Using crmsh's Cluster Scripts
2 E9 k" T4 |. \; B% j5 n$ `1 x5 [4 @9 v
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.+ C* t2 _' \, P) F8 ~3 E W1 i! m
! p! I+ S! Y) Q6 z# a* i1 s8 yDo not confuse them with the crmsh shell scripts, which are explained in Section 7.1.4, “Using crmsh's Shell Scripts”.# F, Y8 j e: M0 d" y
! N: p5 Z" Z; ?2 EIn contrast to crmsh shell scripts, cluster scripts performs additional tasks like:
0 s8 J5 a8 T$ ?) ~3 _* j9 [: \7 x0 o3 `; W* z& m: x$ o
Installing software that is required for a specific task.
2 c% s# h$ o; T! d# {3 M( c! z
0 I- j0 Q% x; sCreating or modifying any configuration files.0 u7 G8 {6 F5 K7 R. u
; t5 f& k0 N9 S) E. u' M* SCollecting information and reporting potential problems with the cluster.- K2 D: o9 w; D) q
# Z! V2 d2 f! j$ s4 b; P) J, iDeploying the changes to all nodes.
6 k' J) d1 x$ [5 I! H9 t
, {. x# M6 O9 h" V J) n4 ]' w: scrmsh 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/.& [0 n7 x6 W. W, g+ ^- z
s5 q9 d8 T9 C' u1 L
7.1.5.1 Usage
- c& e( J3 m3 P
+ q. k2 O6 X2 p9 ?/ A3 ^To get a list of all available cluster scripts, run:! u% L+ I& x# i# W
- H' W0 n S) q& d, Y& t
crm script list) i. j$ m5 n3 ?. n; F! U
COPY& m1 L: j, U5 P9 v$ R5 J" V
To view the components of a script, use the show command and the name of the cluster script, for example:' J& P! C& E3 ?# `: L4 g) V* n
V7 A( W5 K/ Q' m3 I
crm script show mailto" I" p, E& k9 Q' o, k, i
mailto (Basic)+ p5 q% S* w; o m% f% {' p
MailTo [+ ?2 z5 M* L7 l$ B
# V* _: P3 o) w
This is a resource agent for MailTo. It sends email to a sysadmin
, e+ G- L' P2 H. b1 pwhenever a takeover occurs.
. p% @% J& R6 I; S# N! \0 C/ j, b; m2 O* ^, c
1. Notifies recipients by email in the event of resource takeover: G8 m+ _' Q5 R9 b4 E5 s \
0 B: f/ s X+ s) t. ` id (required) (unique)( j8 D; B* @5 Y4 r. G
Identifier for the cluster resource
: b/ `# z. _# } email (required)
. Z: m% D1 e! V f0 U2 A Email address' b: F6 y/ G4 Z3 o# M- e. v
subject
6 T0 [- f- f$ }; M Subject7 S8 R X: \! m$ X* k) e
COPY u+ Y: h# t! d- F( O
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.
9 w8 o- ]2 ^$ H& t9 R" _
7 A* b- X1 @5 f; f9 T! Z0 R: U: FEach step contains a list of required and optional parameters, along with a short description and its default value., `" M0 @' ]' G- d
5 Z- _# }; H& B' c
Each cluster script understands a set of common parameters. These parameters can be passed to any script:
9 f, }8 @+ }9 [" M
2 U6 j9 N( _8 I* R3 f9 U% NTABLE 7.1: COMMON PARAMETERS( M a ]; U+ E g* Q9 i
% d; Z$ C+ r. e5 G5 d
Parameter Argument Description) ?& x: z8 K+ \* H
action INDEX If set, only execute a single action (index, as returned by verify)4 |* G X3 u& Y) K1 d% o
dry_run BOOL If set, simulate execution only (default: no)( o: J3 U% v* ]$ J0 u( z
nodes LIST List of nodes to execute the script for
/ K6 P) h8 e5 B# h5 zport NUMBER Port to connect to# q2 M s; t4 c! y; y4 l6 F6 {, C
statefile FILE When single-stepping, the state is saved in the given file* _( Y- u% m C$ t6 u& b2 i
sudo BOOL If set, crm will prompt for a sudo password and use sudo where appropriate (default: no)
7 e- E8 \" ?5 j8 m; V* z( }timeout NUMBER Execution timeout in seconds (default: 600)
8 d5 ` b3 m- [# @& ruser USER Run script as the given user9 ?# \( v$ y- o- P
7.1.5.2 Verifying and Running a Cluster Script3 p1 D. {# ~1 n
: ~% C+ D7 _1 {Before 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.0 z- X$ b) `9 ^, R- m) z. G% a
8 H7 e: J. B9 [4 `6 T
For example, the mailto resource agent requires a unique identifier and an e-mail address. To verify these parameters, run:
' V% y2 h0 V3 C
. Q' n& a8 U ^. _crm script verify mailto id=sysadmin email=tux@example.org, A; e2 g* v' [1 o
1. Ensure mail package is installed; _" A0 ~" V+ g) s h6 y3 F
- r( h8 b' ]4 j: ~
mailx, }0 ?9 r* N& O9 \
; J# k" L4 w8 M% g1 S2 h
2. Configure cluster resources
. ? l: }) \/ Q" I% s4 l% V7 G/ W, x* R X
primitive sysadmin MailTo& F. h$ \7 d& l1 p
email="tux@example.org"
2 k/ l0 f% ]- h1 K op start timeout="10": S% m# j1 v! d Q( {
op stop timeout="10"
" {+ Y/ M5 Q) Y" R/ m! Y op monitor interval="10" timeout="10"/ I6 F, }) e" I: |
$ K4 d( U) ?: k8 f0 G clone c-sysadmin sysadmin
1 F% T4 K {, G5 @COPY
5 x% |9 X; t: vThe 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:5 Y" X! l3 T; y- u
8 v: N# l& G# M# B; }7 n K
crm script run mailto id=sysadmin email=tux@example.org) l$ G w$ h( d3 \; b
INFO: MailTo7 b3 H5 p+ q2 a4 L; T
INFO: Nodes: alice, bob: S7 {: ~+ ~" l
OK: Ensure mail package is installed- a5 `: g5 o J+ W$ i ~/ {& R
OK: Configure cluster resources
, M: {, u8 j% `( S( W1 \" @) ?* PCOPY% [" B1 D! ]6 _
Check whether your resource is integrated into your cluster with crm status:
$ w3 U: g3 S6 A M8 g. \; R/ }, ^. l# V) D
crm status
0 i4 ~ V3 M7 M2 X[...]
) v% [' D6 G& i. J [ {# m5 g+ { Clone Set: c-sysadmin [sysadmin]
( z" d9 J% P- E, G9 v4 c( ? Started: [ alice bob ]$ c4 U( a4 o! @* h1 h/ P8 ?' k0 K
COPY9 s) S7 b/ {: { |, F# x# s
7.1.6 Using Configuration Templates v5 ]% d" {; n5 r
; @2 z7 l) \! ?* r% `; c; `NoteNote: Deprecation Notice& F j' E' }- [+ {" i
The 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”.7 L* O) C/ N- V; K
7 q: _3 o) A# p+ C; G% x, F( G
Configuration 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.
0 i8 z, `" S/ {0 Q
* O& A" V; G, p6 vConfiguration 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.- d" [& N# ~, ~, k
# Z. Z) j( g; n, T
The following procedure shows how to create a simple yet functional Apache configuration:
, M7 V9 F1 h* V" z( _1 ~
. L" G; J- m7 zLog in as root and start the crm interactive shell:% |& |% Q' H( x1 o" k4 |# t8 F
. t1 u4 a( K- c/ V( c( \) Scrm configure
6 V$ c) c3 H; `" B; Z, M7 TCOPY" g, a ?5 R0 J5 J& q
Create a new configuration from a configuration template:
3 H- o) E9 Q. Z9 Y8 U* r' J9 ?, c* g9 s9 ? r
Switch to the template subcommand:/ Z& l, {: I {) |) d P
" h1 m: S" ]& O6 o& r. O2 k
template
- u3 c" ?" X' lCOPY/ _" n( X4 g7 `& _
List the available configuration templates:
: M* c+ g ^+ K6 t/ ~/ n$ o/ m+ v$ h
! U" j @7 Q0 l v9 Z9 qlist templates2 A' `7 a# o8 f
gfs2-base filesystem virtual-ip apache clvm ocfs2 gfs2
2 z) R$ L) G% K- v* h, ECOPY
( ~& F1 m. O) {# l8 [: L1 FDecide which configuration template you need. As we need an Apache configuration, we select the apache template and name it g-intranet:
7 b! Q! l! N/ ?/ |5 |7 u3 [
6 j9 h! F7 g0 G( a/ Ynew g-intranet apache) Q% j1 |9 q5 G' k/ @; p
INFO: pulling in template apache% w. s2 |3 I' _7 {2 ?
INFO: pulling in template virtual-ip" D: a5 I3 l6 D* c" V/ _
COPY
* \1 Y- K7 L, cDefine your parameters:9 s( |2 B/ [8 i- \' \! O( j
1 a$ T6 I* a) f: F8 y1 S0 XList the configuration you have created:
# m* Y- @$ w& m; W2 \
$ t4 ^" v4 \, n9 B. C4 glist3 ], n6 F! A1 r
g-intranet) S; Y& z( o/ B& X
COPY
: x1 \+ r3 A2 c( J9 Q& j) @( k2 d; tDisplay the minimum required changes that need to be filled out by you:1 E& r+ j" t$ `) Y- h
5 H6 X" J4 @9 }5 Xshow
, v9 C8 [+ W: S2 C! E# m7 ]0 IERROR: 23: required parameter ip not set
" F6 a& l8 F& sERROR: 61: required parameter id not set+ k$ r6 L/ w+ X, e, O, q' z
ERROR: 65: required parameter configfile not set
0 K) t4 g# a# D" ^: @COPY' x( `# n2 n: P* q! f9 r1 H/ p
Invoke your preferred text editor and fill out all lines that have been displayed as errors in Step 3.b:
; o0 P3 a/ G; j9 |
5 A* X0 V' E6 B. m0 y- _edit
# s; i5 N+ Q5 Q: {: _8 e, |6 Q" iCOPY) ~0 Y. N! i$ h% z9 w
Show the configuration and check whether it is valid (bold text depends on the configuration you have entered in Step 3.c):7 e5 Q% E& t/ u$ B
1 E# F4 t8 S4 l$ W
show
0 E' ]/ T& a! [1 o7 T& h3 Xprimitive virtual-ip ocf:heartbeat:IPaddr \
m7 N% h. B F3 I params ip="192.168.1.101"8 z8 @; c' U% D# S6 s
primitive apache apache \9 Z( L$ V7 r" C& E* b6 N/ g
params configfile="/etc/apache2/httpd.conf"" p& q. R7 C/ M" I0 Z, {- q
monitor apache 120s:60s
$ ?, X3 r, [5 sgroup g-intranet \
; K; m+ [3 f6 {5 \ apache virtual-ip) M* R2 n3 _) J
COPY
/ U2 Z0 u2 g0 {& UApply the configuration:
( M; m5 V$ X+ L+ @8 ]1 ^% i/ m9 S$ g4 C) O
apply/ [, V3 C2 B9 G0 F) G; R
cd ..
6 \6 I: W+ k( d) P1 Bshow& \! _4 H) J6 L/ T% [- a2 h
COPY
# L' v4 v1 y. M4 @* s+ ?Submit your changes to the CIB:' `9 ~* x' h' h! Y' M; Z M
- X3 y/ i( O" D
commit
/ @+ x* V# C6 @COPY5 [- W% s1 Z$ r7 D
It 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:; c0 a9 ?0 \8 Y; v
$ S2 n5 f- [1 ~. _0 F U6 j
crm configure template \
3 q$ {! [% o9 |4 K2 I new g-intranet apache params \
# t$ J( h, H8 ~. L! ~8 }2 N: n configfile="/etc/apache2/httpd.conf" ip="192.168.1.101"
2 ?% \7 d; i0 Q5 a0 m* A5 o8 eCOPY
2 m2 V _6 A) B8 ]5 q+ m& l' CIf you are inside your internal crm shell, use the following command:# l/ |7 ]) G# z9 l# C& l+ I+ ~/ `, _: W
+ C/ f; c B+ y! N0 ?; D4 _$ S
new intranet apache params \
( |5 J# E% J2 }4 M. d0 i configfile="/etc/apache2/httpd.conf" ip="192.168.1.101". v9 \& A) D1 {3 _' q$ L. M
COPY; f( H/ k9 U& I9 Z# f
However, the previous command only creates its configuration from the configuration template. It does not apply nor commit it to the CIB.
+ _% ~% s7 @) E* b/ f9 n8 R: m% J: g: E$ I# o6 w0 u" [
7.1.7 Testing with Shadow Configuration$ v2 c$ g& h f7 z* V+ l
8 j. P; t, m7 R% s* }. x
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.
9 k) s: A6 D; V2 g
% S7 N" `6 s$ j6 m) xThe usual process looks like this:6 u) J3 V$ }/ q, t# |0 U2 K
+ V( _9 b" ]* X5 ?# z
Log in as root and start the crm interactive shell:
! f4 d; @4 {. E5 [! q, @9 x- @ M* M5 l5 T( E* N. ?# F
crm configure# A" J7 }5 T( z; F
COPY% h2 H* \( r2 k( ]+ h. t
Create a new shadow configuration:+ a. j j4 p4 g0 h6 P5 ?
) O- T. O( q3 Y0 O( s/ c1 | J: S" ocib new myNewConfig) e3 u3 G" j; Y9 H
INFO: myNewConfig shadow CIB created
4 T+ W5 Y6 \9 c6 ?, {- s1 m6 @) RCOPY5 O9 b& m/ `/ D1 d7 V
If you omit the name of the shadow CIB, a temporary name @tmp@ is created.
, N* E1 E" n- t4 |! c7 ^3 a
0 X$ s: s' e: u3 }; ]% wIf you want to copy the current live configuration into your shadow configuration, use the following command, otherwise skip this step:7 u, p6 F6 R' d& a& p
3 @3 F7 X* k. tcrm(myNewConfig)# cib reset myNewConfig
* R7 E; ^" W# d' BCOPY) O- b$ Z# i2 ]2 ~8 m# `* a
The previous command makes it easier to modify any existing resources later.0 e0 J b: J$ A8 y) Q8 v
1 z @4 F$ c; Y
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:
) H5 T* j7 Y4 ?9 K3 N3 N' N/ E
! X% O, G6 n" M; ]$ @- [& vcrm(myNewConfig)# commit
5 G( k. q/ c# `6 I8 DCOPY! |4 o) W* L( c. m) ^
If you need the live cluster configuration again, switch back with the following command:
0 P z* T* [8 F- ]8 |5 ~" c5 \" M: z; K3 a6 N. k
crm(myNewConfig)configure# cib use live9 N J: ]+ I" h5 E2 X4 ~+ e4 r- _+ V
COPY1 v0 T) B3 A- Y# A a4 x
7.1.8 Debugging Your Configuration Changes
. K$ [5 y/ a0 W: H7 o) a
7 h* P9 J1 f* c* MBefore 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:% L. C% R3 i. `9 V( }5 m
\2 }. n* n1 }) @0 c% F" Scrm configure: L8 ?6 \7 g- ~# i4 e
show fence-bob
3 _3 R- X7 I, nprimitive fence-bob stonith:apcsmart \
( e2 H, i$ p- ]3 j$ z params hostlist="bob"- t* s; J& \% A, I
monitor fence-bob 120m:60s; l8 R4 Z+ x4 A1 s
show changed
8 i9 f. F; Q/ ]' i* x! q( xprimitive fence-bob stonith:apcsmart \- A( }8 x) P- P7 `% |8 `
params hostlist="bob" \2 E, o+ o' X; J! i# P$ w. J3 l
op monitor interval="120m" timeout="60s"1 C: ]/ B+ }# ^" V& J, x
ptest5 L2 \/ K; w p* t2 b. N% w
commit/ h2 {- j& W+ t; a
COPY
. U( E# T/ M" Y1 X7.1.9 Cluster Diagram$ b8 b" N. b+ z2 O" r% X( z
/ ~+ A6 o4 l: g, V& h' D
To output a cluster diagram, use the command crm configure graph. It displays the current configuration on its current window, therefore requiring X11.
6 H5 e; Q# W( P
9 S7 [4 g- L3 i6 n8 uIf you prefer Scalable Vector Graphics (SVG), use the following command:' @) x+ I6 o! @" O1 }; X
& G1 M2 B% w% s; X+ |& I# ~
crm configure graph dot config.svg svg2 X$ E1 m6 W' S. W# c
COPY
" U) m$ k2 Q3 |9 k7 j/ m4 }8 m" b7.2 Managing Corosync Configuration. [. C* h# q* u9 q- x. o: M: w
% m9 P( E* E2 }5 K2 b$ ]. D3 D
Corosync is the underlying messaging layer for most HA clusters. The corosync subcommand provides commands for editing and managing the Corosync configuration.2 b1 e }( P J) Q; n9 u( {
/ P$ X9 @. @# q @- k' PFor example, to list the status of the cluster, use status:
# z9 h9 w5 N6 s% q# V5 D! D
$ X( R4 `6 E9 n% H0 K, Tcrm corosync status+ s/ ~) m' {7 p; }8 T# S
Printing ring status./ ?- p" ?! Q1 L
Local node ID 175704363: h8 q6 e5 w5 |9 H! ~, ?
RING ID 0
' T, y0 ]% L; p$ y0 v, F5 o: v& Q id = 10.121.9.438 T$ ` `1 p% i
status = ring 0 active with no faults% N- J, a, ?5 c( k
Quorum information1 l/ ^ w/ g$ H" P u; u C$ u K3 O
------------------
8 W/ y. U: c0 n" R6 YDate: Thu May 8 16:41:56 2014, E0 p7 R: }5 A. V% J- p% G! r/ s
Quorum provider: corosync_votequorum
6 r0 m1 r# x% J, {+ FNodes: 2% d. c8 o: L4 q7 A: M; C: B; I
Node ID: 175704363: x& E$ O B: {8 f
Ring ID: 4032" H" m, J- v8 G' ~. g6 Z' v
Quorate: Yes
6 V4 w! o& r# s; X# `+ A1 e- S( ^- G; w% o+ Q7 C
Votequorum information' W) k6 ]" @; { z5 }# ]' R
---------------------- u% }5 x5 w0 Z: A+ r
Expected votes: 2
4 e/ B* z- _* XHighest expected: 28 e) w# w6 l* W! P$ @
Total votes: 2( A6 W. H6 d& C, Z) |
Quorum: 2
9 W' p: v+ Z' _) X; AFlags: Quorate; d1 }, O3 k+ e, Z8 [: ?0 K- G/ h7 l! K
" {" ]+ e3 p+ A& sMembership information
. ]3 k: G. J' Q" i# w* B1 [ \---------------------- l' C7 }8 K" p5 u _+ ^& a
Nodeid Votes Name
& ?# D8 U- {8 \ 175704363 1 alice.example.com (local). m- v# r3 G" N+ ~% X) D5 c
175704619 1 bob.example.com7 s; b# m: i. E
COPY' S7 R q4 r, p5 _: |: U! |
The diff command is very helpful: It compares the Corosync configuration on all nodes (if not stated otherwise) and prints the difference between:
) Y4 I: L; p+ T( Z* ~
% T3 L) e+ p% zcrm corosync diff
% w+ n# M. Y) X* ~, O--- bob
* }+ ^' K6 t! v, t+++ alice
% u& _. R9 g" I# B2 X$ d+ m' ?5 j@@ -46,2 +46,2 @@8 n7 r5 l/ `( ?: Q# D
- expected_votes: 2- }% B. u5 Y, L& [
- two_node: 1- U0 f$ y# B, \+ I
+ expected_votes: 1
1 H3 @8 e9 N+ J4 Q5 \" {+ two_node: 0
" ]* T1 S, o( ^" Q" m3 m5 N/ ZCOPY* B& ]9 q. g4 [; H% d6 O
For more details, see http://crmsh.nongnu.org/crm.8.html#cmdhelp_corosync./ N/ `: ?! P- T, ]
7 l" V# x7 _6 ~1 M4 I7.3 Configuring Global Cluster Options$ A+ v7 a. b- w$ D% ^
* z4 h. }( ^: s4 V- E0 C$ {Global 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:, U" K- I: L0 O7 v2 j$ k6 A* f
. B7 F' y: d# M5 O% V5 L
PROCEDURE 7.1: MODIFYING GLOBAL CLUSTER OPTIONS WITH crm
6 {- e: J) M0 N+ C; K! @1 x$ _9 l/ d& H, |2 f3 Z5 x! @8 ^
Log in as root and start the crm tool:; T! @' R# E" U! ]* [) d' f) B
$ Z2 o- \$ _) @7 W% {: _& q5 M* ucrm configure
/ |$ z! B$ v2 R/ K4 t1 `. {COPY3 Z/ i+ B8 v6 X% Y* U* S- H. @
Use the following commands to set the options for two-node clusters only:
" }: s) b. f3 [1 T+ S9 x
2 C% R) H* @0 P+ O3 d, f4 |property no-quorum-policy=stop
: _; ` r" g5 D6 lproperty stonith-enabled=true! G" J: n5 g5 ^/ v1 a; d# t1 ?& Q3 E
COPY
# m, H" Q! t. D! ~4 TImportantImportant: No Support Without STONITH
D# t+ n/ ]4 g3 R3 `A cluster without STONITH is not supported.
* f: s* q+ o9 w8 T& `9 ? U/ G# g6 {9 ]6 W# @
Show your changes:
. l% z7 ~: M8 i9 J7 g+ z% p
5 e' [& o* I0 m$ U; ]( {show
# m9 U8 l( _" Z8 |- ~0 \; mproperty $id="cib-bootstrap-options" \
* e1 K! O, \9 Z) ^5 q& s dc-version="1.1.1-530add2a3721a0ecccb24660a97dbfdaa3e68f51" \
6 e: l0 c( m& t" j cluster-infrastructure="corosync" \
M# J8 { `2 E& d2 h1 O4 _ expected-quorum-votes="2" \( S! f4 ^! `- H
no-quorum-policy="stop" \
c# |& F7 }: F2 h stonith-enabled="true"
/ U3 [7 j+ k( J' JCOPY( s; q6 w! e Q4 c% E" O' z% b, m
Commit your changes and exit:0 ]4 N, z) p/ ?. y
3 O- ?' ]) ~5 @& v) Xcommit
* `+ e/ [9 v- F% M7 V. v- ]exit
) ?" ^( h8 ]5 h; Q4 Y5 R8 g; NCOPY- O; D& F% x; O; p$ @
7.4 Configuring Cluster Resources
3 r# k) g+ w/ K2 A
# k& v" h, X+ oAs 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.
( R @8 P! g) z R0 N
1 W' H; C, x# }; O$ j( b" MFor an overview of resource types you can create, refer to Section 5.3.3, “Types of Resources”. L: \# ~3 U& N
: C- ~0 w$ K) E9 F0 {* f- ]5 e4 |
7.4.1 Loading Cluster Resources from a File
# P# }1 o2 t+ ~, W \. w% I* p$ @1 P0 q
Parts or all of the configuration can be loaded from a local file or a network URL. Three different methods can be defined:0 C+ `. U- e) w# i8 q6 s; n
# e) w* f$ o" ]% L( N
replace
& [( s9 ^$ L- W7 cThis option replaces the current configuration with the new source configuration.
5 m& |. S0 s3 ]4 w4 @2 t% I+ e
_8 F/ f( |) I, c* }! Dupdate& t* C% J5 x# G- W4 U. W9 }
This option tries to import the source configuration. It adds new items or updates existing items to the current configuration.
0 j3 U1 @. G3 _3 k6 r1 z! i. a
5 U& Z/ T) J# ]: Z+ Ppush
4 o& I7 y1 v4 p' e7 P+ WThis 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.
4 _5 I/ z; ~" c8 {/ w, f; m+ m) V6 ]; O, l6 R
To load the new configuration from the file mycluster-config.txt use the following syntax:
n `% r2 o6 S& I+ f4 P( L- ?- E. ?* Y! I2 O
crm configure load push mycluster-config.txt& o2 m) y9 l7 W9 {2 [9 q
COPY' r3 u' |$ s$ J4 s& z3 e7 ]
7.4.2 Creating Cluster Resources: _5 [* C( [, |1 x4 }6 y; i
1 z& D7 Z6 f1 Y1 dThere 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:
; m" E" `5 k$ }/ s9 w
! p6 P6 A5 v" V' r7 z. t3 `Log in as root and start the crm tool:7 w: p1 a2 t0 m# {' M. _2 K2 z& {
9 S: C# a7 s' |6 c' [
crm configure+ \' a) l9 z1 J8 j" s
COPY
, E* ?) g: Z4 {Configure a primitive IP address:
9 F% ^$ U! Q5 Q: X/ Z: J3 o4 F6 X9 d6 h" U+ C
primitive myIP IPaddr \% F( ^: h1 C/ |- O& a
params ip=127.0.0.99 op monitor interval=60s
3 t9 U: Z; G. H+ v. FCOPY
' t( U ]; E' p3 T& [The 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.+ ?3 t) S: E- d. a& p3 Y8 N
7 g0 h9 g- k) V" U- u
Display and review the changes you have made:
1 V( T9 M5 C7 b$ g3 Z3 E0 z# U& H$ t8 q, s! f/ G4 b
show
- v0 i4 {3 @$ W) u7 FCOPY
9 D8 `5 B4 {1 |" H6 g, [( iCommit your changes to take effect:
9 ]# Q$ |1 s9 x; K1 M
) E& ~3 @/ {1 z9 F/ R) p0 N6 rcommit5 l: h5 l6 W( ^# V2 w7 H
COPY
% x2 z: p( Y/ {" I& c' q& k7.4.3 Creating Resource Templates
% n; p6 K; F+ |( Y- @' o$ b1 \4 |
2 I6 }! Q+ h' ?. q- @If 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:
% u+ M- D, ^/ ^. o1 p; k
, S' |8 U- ?7 K; k; xcrm configure rsc_template8 l% }+ `; E2 I! }2 \
usage: rsc_template <name> [<class>:[<provider>:]]<type>1 Q( @1 @5 E9 F b0 E
[params <param>=<value> [<param>=<value>...]]7 R( H+ B2 t5 E( Q4 q5 |0 A8 r
[meta <attribute>=<value> [<attribute>=<value>...]]
) Q8 O/ m {, r3 M6 _: `0 _) @ [utilization <attribute>=<value> [<attribute>=<value>...]]' c* R( S2 a7 T
[operations id_spec/ ^4 i& y$ n0 }! M
[op op_type [<attribute>=<value>...] ...]]
- \: [7 j4 W) ^/ q2 GCOPY, R7 ?( K; k/ E
For 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:
. \ @3 E1 I( Y2 W/ z2 H/ L+ x. v, b5 Y7 u5 A
rsc_template BigVM ocf:heartbeat:Xen \
& A" I1 e! \3 x. }* c+ D8 H params allow_mem_management="true" \
8 r6 z4 T% y% q( q/ Y ^ op monitor timeout=60s interval=15s \
: [" W8 l$ E: t) n op stop timeout=10m \
' a2 ]- C1 S7 r1 F+ | op start timeout=10m
# s7 { I9 g3 L) C8 `COPY
& _3 C2 C* R* y# k. j* zOnce 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:
! m: K& v9 m/ I# r/ F w% H" U. N- ]& v5 r) w
primitive MyVM1 @BigVM \
! {. h) M6 f$ x- t' P7 j params xmfile="/etc/xen/shared-vm/MyVM1" name="MyVM1"" `1 x. K* R$ M5 Q: i* ~0 _
COPY3 P P1 C1 b4 X& Y
The new primitive MyVM1 is going to inherit everything from the BigVM resource templates. For example, the equivalent of the above two would be:
) s5 f9 o: D0 j* |, D8 g# C8 c' {
* S7 L" G n! I! Oprimitive MyVM1 Xen \( `6 c& F# \$ q% c2 K. x/ p# [; Z3 T5 u8 `
params xmfile="/etc/xen/shared-vm/MyVM1" name="MyVM1" \ b' E1 p& `9 Q
params allow_mem_management="true" \
8 l, f' X" [1 r8 H' |1 m op monitor timeout=60s interval=15s \
" I I7 R& l+ Q* T* u+ r/ y0 O op stop timeout=10m \9 H/ ]2 G% Z' O9 o2 Y$ Y' Z
op start timeout=10m# |# B- c- q9 N* B, K' B' W
COPY
8 T1 g6 U+ }0 T0 [! _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:
% S# o7 `, ]% I! d m+ P t3 E. V) q
primitive MyVM2 @BigVM \
; V. x/ n$ X: t9 e, C! r& e/ f params xmfile="/etc/xen/shared-vm/MyVM2" name="MyVM2" \
1 s, S5 @9 D8 y6 ? op monitor timeout=120s interval=30s
' ]$ r) q* y; hCOPY% }( M7 k8 d5 t- x2 I, m7 P% t }% Y
A 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.7 j, G( d9 g7 P( e% t- g8 h6 @# a
, r) N% y1 a. V4 C7 [- v |9 G
7.4.4 Creating a STONITH Resource- c: j$ g7 n% V8 R3 @
* B& t' F$ U( C9 t9 [From the crm perspective, a STONITH device is just another resource. To create a STONITH resource, proceed as follows:* }7 X, D. S- `3 S
" Y4 I# r7 T$ ^, m4 I% O
Log in as root and start the crm interactive shell:
' d h3 g; [! J. Y7 q( n$ Q, | Z( s/ ^: g1 z4 |4 p
crm configure7 {, g# ^ K4 x' [: q/ j
COPY
. D: j& b8 a: j0 f g7 Z- D: bGet a list of all STONITH types with the following command:
4 m9 Y8 s R) X+ Q+ o' h) G
# C3 W9 s9 v/ p! A' wra list stonith2 ?' l1 l+ S) n. {0 {
apcmaster apcmastersnmp apcsmart
$ t {; a5 w8 j" vbaytech bladehpi cyclades3 b" k* \" y" u
drac3 external/drac5 external/dracmc-telnet w- A u7 ^3 l$ ~6 b4 |
external/hetzner external/hmchttp external/ibmrsa/ z5 ^4 h$ X7 s9 a, [5 X4 D; X
external/ibmrsa-telnet external/ipmi external/ippower92581 O! n$ H2 i8 h' _2 U- E
external/kdumpcheck external/libvirt external/nut
% I3 ?6 S0 p6 a% q% Zexternal/rackpdu external/riloe external/sbd0 `; r7 f2 r5 R; r& _
external/vcenter external/vmware external/xen0- A- T1 \7 h2 \1 \
external/xen0-ha fence_legacy ibmhmc/ A% f1 R6 K4 n2 J) o1 ]
ipmilan meatware nw_rpc100s
/ _# g. t; G# m1 v# ~9 {, C1 prcd_serial rps10 suicide
9 v. J1 Z/ U- V8 M# Z6 Z) ?wti_mpc wti_nps
* r* f# C: L6 _' ^+ u, w9 A% H/ n) hCOPY' b+ S# O3 Y& E' L4 p3 g
Choose a STONITH type from the above list and view the list of possible options. Use the following command:
0 r* Z: y1 L6 u; b- i' O& a& N5 T3 J3 F, Z1 A: O6 `
ra info stonith:external/ipmi* l$ F1 {. j- m. k7 Z
IPMI STONITH external device (stonith:external/ipmi)# U* m/ _3 n, N; H6 p
4 g3 d2 W m+ p9 z4 P' \ipmitool based power management. Apparently, the power off
# F- x/ O }2 X* w) ~method of ipmitool is intercepted by ACPI which then makes! [( ~1 S) \+ ?6 F; G( _. T. x, B
a regular shutdown. If case of a split brain on a two-node
0 [" E/ ^7 m _* }$ i0 uit may happen that no node survives. For two-node clusters
9 j5 W; V, _8 Z7 \9 juse only the reset method.5 I# X; M$ y/ e8 G+ o
' ~, I) a s3 U- Q7 q) O0 A s/ A0 e
Parameters (* denotes required, [] the default):
4 R6 n' d1 T/ B" j, d$ i# P& q9 u Q; V5 z2 T9 Q
hostname (string): Hostname
/ a0 i! A/ i* e3 X. } The name of the host to be managed by this STONITH device.
+ ]7 O" z- _* w. b2 ~...
* w% T n- B. K: z- OCOPY' k; C. t$ C, }# P; L( V
Create the STONITH resource with the stonith class, the type you have chosen in Step 3, and the respective parameters if needed, for example:
8 x: Z- [5 c ? F* {0 T) q: [$ k. u u' @& I/ W+ M% Y; Z
configure# |4 [4 H" V# g1 F2 Q
primitive my-stonith stonith:external/ipmi \
' ] v$ a# ?' W, q/ `8 e params hostname="alice" \' |# E3 d" c6 g9 [
ipaddr="192.168.1.221" \5 }0 [/ ?! g8 j. i9 g! H3 ?: U
userid="admin" passwd="secret" \
' x# s6 ?6 i8 o" d4 {5 ] op monitor interval=60m timeout=120s' U" s5 c# k' m
COPY, Y3 B# _7 t, I- k( J
7.4.5 Configuring Resource Constraints
2 q* f l8 U% e& ] D9 L
, F/ P) W/ q; P- qHaving 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.
" Y7 t% t$ u4 w1 k8 R# p
p1 o2 R$ |# j3 F! J# YFor more information about constraints, see Section 5.5, “Resource Constraints”.* y; j5 c: c R# b
4 q6 Q% H. O9 O5 t
7.4.5.1 Locational Constraints4 u6 E' K! _ o6 x" W+ @
% ?, o; N$ d$ w* |
The location command defines on which nodes a resource may be run, may not be run or is preferred to be run.
& @( T. u8 H5 z* G" d, w( Q# z! o* ?
This 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:
# o! ^" l$ n( g% U, v- i) F$ F4 n$ q
location loc-fs1 fs1 100: alice2 K P' e" B$ q0 Z
COPY" Q- c! }$ n w- W
Another example is a location with ping:( s; q' u1 E. `5 G, m8 d7 q
9 G) V" K8 \2 i. V. P, E( N; Eprimitive ping ping \
( d% F$ w8 V; E2 K/ _ params name=ping dampen=5s multiplier=100 host_list="r1 r2"
9 ?, n W5 A4 C6 F$ D# v9 R! z. w4 zclone cl-ping ping meta interleave=true j4 V$ U$ G( {
location loc-node_pref internal_www \
% T" O' l5 s6 d1 i" K( f+ i rule 50: #uname eq alice \
: p# X5 k5 h, h' l: L$ M4 { rule ping: defined ping
0 M0 j$ `2 c1 J" u* |COPY
. }3 G8 }! ?# m1 w7 F% NThe 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.
5 \9 I( a, d/ X9 C5 c! E {! c
( M- ]8 B) n; T( ]1 b. `9 k1 R5 ^The following example creates a resource set loc-alice, referencing the virtual IP addresses vip1 and vip2:! ?) ^) r9 s' _, \, ~1 G) O
5 F; W, z% ]/ {/ O0 M( ]
primitive vip1 IPaddr2 params ip=192.168.1.5, }6 u* J) P" K! D* R L- j
primitive vip2 IPaddr2 params ip=192.168.1.6
8 J9 O! P8 W) {; I3 V( slocation loc-alice { vip1 vip2 } inf: alice8 z. f* B+ E$ G( b; f5 ~( B
COPY0 ^2 w, Z' f+ Y$ L, x- c: [+ X2 o, X
In 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: W' p7 b6 M" _
3 b; J# A: R( [! v
location loc-alice /vip.*/ inf: alice
; F' @1 u$ w9 `1 k( FCOPY3 V1 @) u) l( _' A' Z
7.4.5.2 Colocational Constraints
3 v1 A3 _0 |1 H/ g# V# N1 U, C6 W, N3 L* r
The colocation command is used to define what resources should run on the same or on different hosts.' [% Z+ P, s T6 ]8 V# P: X
- q0 w7 _9 ?& U+ ^
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.% e: H7 Q, ~2 V0 j" `; W& Y2 Y+ Y
' o4 T: }+ I" H) N) Y3 {8 }
For example, to run the resources with the IDs filesystem_resource and nfs_group always on the same host, use the following constraint:8 P" A7 n- W) G0 f& e: _
- W6 X1 ]4 u8 x$ l1 P( M% Bcolocation nfs_on_filesystem inf: nfs_group filesystem_resource6 C8 X: P% T) X
COPY
# _1 t' u$ `0 y e/ u! D) BFor a master slave configuration, it is necessary to know if the current node is a master in addition to running the resource locally.: {" L0 e2 B; h! U! D7 f0 j1 y
: c2 i5 Q" k! D# ] X' z- h) ^
7.4.5.3 Collocating Sets for Resources Without Dependency
7 ]0 ~! l+ r: q9 X9 t$ j+ a
0 [- M$ w2 n. B5 d1 Z4 S) cSometimes 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.
2 O3 @0 Z9 o6 @/ L3 l* F6 C" \! Y& d0 g) b! Z
Use the command weak-bond if you want to place resources on the same node, but without any action if one of them fails.
2 s$ i7 v9 e3 T* E$ |, p7 ^! [+ @! r r1 Z1 H* A! E! X
crm configure assist weak-bond RES1 RES2
! ^# @, A1 i, r! }* e3 YCOPY9 M5 P$ q. ?2 ~, `
The implementation of weak-bond creates a dummy resource and a colocation constraint with the given resources automatically.0 ?1 Y" C% u2 I6 [) b3 H
* ~+ l5 `0 o) X$ n; v8 G
7.4.5.4 Ordering Constraints
9 I/ ]1 x) Q2 R* X1 d) A5 K* O
% i5 J$ o8 x8 d, zThe order command defines a sequence of action.6 u, j! F6 ^# I
! G7 s1 K0 z7 G% V( T6 a5 s# v
Sometimes 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.
. A4 e% H5 i3 [9 N
; Q# G: L/ p$ [( iUse the following command in the crm shell to configure an ordering constraint:
1 g1 ]1 N+ X; {+ H I) K9 b3 L$ W
. q$ k+ H7 [/ X) lorder nfs_after_filesystem mandatory: filesystem_resource nfs_group
6 k8 }' x& z$ c2 I8 OCOPY
. ~4 q- G3 x' O+ F' S7.4.5.5 Constraints for the Example Configuration
: j0 |9 c0 e6 K# t% Z H
! Q; j( @0 D7 ?; _: P/ dThe 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:) H6 X: e. }" w$ e- N' s8 U! @2 _. O: L
, ~$ d& y) l8 U4 H8 _
The file system must always be on the same node as the master of the DRBD resource.
. L# C$ m" J$ S, p5 v( R* j! `7 i4 l2 Y) ?2 ], e! t0 d
colocation filesystem_on_master inf: \
5 w, @6 Q% H9 y. Z: v filesystem_resource drbd_resource:Master
' V7 Z1 s' m/ I+ ICOPY3 i& m+ h1 [9 N1 y
The NFS server and the IP address must be on the same node as the file system.
. r+ P" h3 b" T* }! \8 k
4 R0 _5 U2 [, u Hcolocation nfs_with_fs inf: \
# P$ N: W+ t' p! b nfs_group filesystem_resource4 F+ J% Q M% b& `0 _8 C( g: R
COPY: ^% \0 b9 H, Z: ^6 W, {( I
The NFS server and the IP address start after the file system is mounted: D# _2 B+ G6 |3 c! p" R
/ ~: }9 S2 D/ F |, i3 G
order nfs_second mandatory: \% F) |6 \; Y; Z# ~
filesystem_resource:start nfs_group
: Y- x2 Q5 L. ]- i: ?' ACOPY
* o8 L! d' t' J- @- z. j$ jThe file system must be mounted on a node after the DRBD resource is promoted to master on this node.6 d7 t0 b: k/ f
0 H$ F; w! E6 ]# |
order drbd_first inf: \
/ V( ?3 T# {& Q! G* ~- e drbd_resource:promote filesystem_resource:start
* A* p, T: J; y' h& \3 r$ @8 eCOPY. ~! y' a% @; b# v4 i) e
7.4.6 Specifying Resource Failover Nodes2 M; u$ b1 `" G8 r, _2 S0 w
8 {. d' i# Z# c1 hTo 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:
+ y- H+ H: w7 o
6 ~* J0 k& ?& clocation rsc1-alice rsc1 100: alice S0 \) a# l8 A1 D A) r
COPY h( l# ?. j5 o" n3 b t
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.
9 E8 Z7 m* D( u
0 \* U. C) @$ k* W$ ~Start 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.
! \. }8 x2 `. E% Z3 y: \- z% x4 N& s1 [2 i+ [
For an overview, refer to Section 5.5.4, “Failover Nodes”.( u3 p$ P' f: h% _2 T N- M7 ]: l
( S$ a' Z2 H9 o
7.4.7 Specifying Resource Failback Nodes (Resource Stickiness)
! R, Z3 D; W! p
8 ^: F" R) N4 e/ K ^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.
# t2 ~. ]+ T3 v' V, @, F' q* I+ U/ \/ \9 M- }, T
For an overview, refer to Section 5.5.5, “Failback Nodes”.
9 J6 Z9 t# d6 |" G
/ Y. [6 a9 P2 s6 S. t7.4.8 Configuring Placement of Resources Based on Load Impact4 J* D$ e1 k+ L) V' s# i
& y; l/ T# ]9 a. H1 P9 YSome resources may have specific capacity requirements such as minimum amount of memory. Otherwise, they may fail to start completely or run with degraded performance.
9 K% W# S1 P7 B1 U
0 I+ q7 G; K+ \* bTo take this into account, SUSE Linux Enterprise High Availability allows you to specify the following parameters:
1 m, J0 y! x2 ]# d/ k# g+ M
$ a4 j) P+ @6 |1 B# m( p/ a% wThe capacity a certain node provides.
/ {- L8 ~# g+ Z+ V& v& ~8 o/ G- T: P$ M& s
The capacity a certain resource requires.* u0 a3 W9 y" g
7 b. K7 a, G# u" D. e7 m( M
An overall strategy for placement of resources. n& W+ a P8 U. ?1 Z1 h
5 ]% K$ b' K! cFor detailed background information about the parameters and a configuration example, refer to Section 5.5.6, “Placing Resources Based on Their Load Impact”.
0 ^/ G" _3 ~% q1 t, Z- E) |+ f3 w& d, _3 h% C: w. A
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.( u7 C6 j% A! B
8 i& M" j, \& a- `( X$ DIn 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.
4 K: h( P" D( z6 V9 { U) j0 I& U7 ?
2 d( r, ^9 J# `; a9 t4 oPROCEDURE 7.2: ADDING OR MODIFYING UTILIZATION ATTRIBUTES WITH crm
3 d; \, {1 s6 }8 M: V
4 v! B- }9 L; |; ULog in as root and start the crm interactive shell:, ]/ k/ D7 S- n& U7 |
# Q, e @; V* ?. |2 @# v% \
crm configure, W; B8 ? Q, T" f1 V- M2 i, B
COPY
/ t+ \$ _9 ^ N) g6 L% W, i+ m8 zTo specify the capacity a node provides, use the following command and replace the placeholder NODE_1 with the name of your node:$ a2 B) n+ Q9 {/ q! w3 O
# v+ r% P9 `4 i: J* z
node NODE_1 utilization hv_memory=16384 cpu=8
: K) {5 @/ o; G+ v* xCOPY
0 ]2 y8 x$ n' i) X* I' TWith these values, NODE_1 would be assumed to provide 16GB of memory and 8 CPU cores to resources.5 D& ]1 \; |7 w: m( m4 E
2 \' J+ \, ^: x3 Y- [) LTo specify the capacity a resource requires, use:* u( u& _8 Z7 }& l% @
3 p% r6 \$ U9 x
primitive xen1 Xen ... \
: C3 T" Z6 y8 F! v8 U, q( Q utilization hv_memory=4096 cpu=4" A) { F- c* c ^& ?8 M
COPY' u4 g, e1 a! m& D; M
This would make the resource consume 4096 of those memory units from NODE_1, and 4 of the CPU units.0 q+ \+ O* T U( f& ^, \
2 M' N9 \* ~* z
Configure the placement strategy with the property command:" T* H* ^! B& O# y! x% S: Y/ O
; L2 x3 C2 M! J. n7 p) b1 ]4 d: oproperty ...1 Z8 k g; j- [9 e
COPY
3 t' q4 j% B$ }+ `; ? OThe following values are available:4 X: C. K0 G0 L: O7 f! r: E- s) D+ |
|" T( G: E! h' H% s( d. edefault (default value)
& q6 h0 l c! Z3 bUtilization values are not considered. Resources are allocated according to location scoring. If scores are equal, resources are evenly distributed across nodes.
0 K% L! h H. d M W" |$ {
* b* F" i4 H& }utilization! T/ v! k: u, _0 R" d% c
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.* n4 \# L" U2 G
/ S) P4 n' M9 Bminimal- o! X, G: B J" B
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).
% Q; F, G! [4 D; [/ ^) g* H( Q$ s" x2 T0 _* H/ c2 d# V
balanced
7 Z9 I$ O; S5 w- f. J2 zUtilization 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.& S9 ^: K5 h$ v: P2 E( G! S$ L
8 F9 B ]9 ~, U1 I" o, \NoteNote: Configuring Resource Priorities* l. }0 h* o* e: |3 q) V- O. N
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.& q- N5 o' z% Q I* V, p
9 O1 D, i0 \2 ?4 a
Commit your changes before leaving crmsh:7 p$ p; l8 U' M
$ a6 ?, J$ H' U4 xcommit" s/ g7 y% }3 K% c! N
COPY
, Q$ X3 m! U) x4 }. z" o) eThe following example demonstrates a three node cluster of equal nodes, with 4 virtual machines:
6 g% z4 a# n- f0 m6 r6 o% M, V# ^/ Y3 N
node alice utilization hv_memory="4000"
0 {& o6 E# |1 ^# L3 Y9 w0 w; c) ?node bob utilization hv_memory="4000"
t/ f; O5 X1 r# B Ynode charlie utilization hv_memory="4000"
. m5 R) G4 r, g% E3 oprimitive xenA Xen \( S- t) t% A5 i# G7 |4 }: ~+ F5 y
utilization hv_memory="3500" meta priority="10" \
$ ~9 ]- l$ r& m, A8 G8 Y params xmfile="/etc/xen/shared-vm/vm1"
; r* q# H! j$ w. c; {$ Iprimitive xenB Xen \
. _4 G" l1 u9 M4 ?( { utilization hv_memory="2000" meta priority="1" \6 F0 l# K/ N; e# `+ M
params xmfile="/etc/xen/shared-vm/vm2"
6 N/ l/ q9 i5 q8 n4 Wprimitive xenC Xen \
* g% N" ?: b/ p8 G8 _" h- `9 P) D utilization hv_memory="2000" meta priority="1" \
7 y% H% ]+ L# U' c, t' r% i params xmfile="/etc/xen/shared-vm/vm3"' Q- e. C8 Y% w
primitive xenD Xen \
) Y2 _# }- k" g1 f) A3 H/ c utilization hv_memory="1000" meta priority="5" \
Y( u$ P& A, g, ] params xmfile="/etc/xen/shared-vm/vm4"
6 G% B' @4 n6 F: vproperty placement-strategy="minimal"
0 B, M* N& s* f! _. OCOPY
" ^! f! s/ t* P0 w1 E/ z7 i8 vWith 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.2 j6 c0 x+ \1 L0 [" Q
: U* N( Q2 U4 D) @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.
3 t# [7 s: q% R- B0 a, y) ]
- M! e8 f3 S+ w$ t7.4.9 Configuring Resource Monitoring
% _: A* @9 r8 ]9 w. }* w; I# V: n
7 c- F/ e* Z+ Z4 h0 h" W9 bTo 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:
6 F" m8 n% {6 B* B( w8 h. s! \
8 X2 w3 U" j5 w# Vprimitive apache apache \' Z p2 Q! E% Z( ?8 z$ h% e
params ... \- F8 X- C2 Z: U2 N; a3 V
op monitor interval=60s timeout=30s6 B: m2 w1 F2 N
COPY
! {- l9 f1 t! F3 B5 g4 R+ dThe same can be done with:
/ V$ d4 U' t/ D6 z6 u: c f9 Y3 {8 A s5 h5 H1 i$ l! Z3 _
primitive apache apache \; `9 a: s- [9 d' p! s
params ...! A% a! w4 _- Q Y- n( r
monitor apache 60s:30s+ s: j1 h" p0 x" }. J7 Y1 G7 X
COPY
* g O2 G; \3 u: t& }% oFor an overview, refer to Section 5.4, “Resource Monitoring”.
7 t* r; d7 A/ k
$ x% ^0 s: J* ~/ o3 S' {- |7.4.10 Configuring a Cluster Resource Group
. ~' d0 D {1 `5 q0 @" r" J- Q( J* y" V
One 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):
8 y: U5 G9 M+ [9 F0 ^
. k' Q; H8 l. i; Q+ XRun the crm command as system administrator. The prompt changes to crm(live).
4 c; W1 w2 d0 W: a: P- d' a9 m$ ?: L1 f5 N7 o
Configure the primitives:$ J8 T6 _; P5 \* H7 V9 v* l! q
# }" n7 v! }( X
configure
& Z- i$ [, G" t& w" N' d7 R$ pprimitive Public-IP ocf:heartbeat:IPaddr \( q' `, ^+ M+ J- K# b5 U- X+ @: x
params ip=1.2.3.4 id= Public-IP0 H& @) p- s$ a* D+ p7 ~6 K& A1 N
primitive Email systemd:postfix \
) a) @2 o @0 k! f; T" } params id=Email8 |1 l0 B# {: D
COPY8 Z) k4 K; B I5 s" q* r9 o0 C
Group the primitives with their relevant identifiers in the correct order:
. @$ M. M* Z; S3 m! `& E# o T7 Y& b% {2 N" H7 L
group g-mailsvc Public-IP Email% T$ s) Q0 B) J5 Z: d
COPY: U9 ~2 E: `2 O8 }/ `! P; v* W
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):! r8 |: v) Z3 w/ z" v" k# b
* x4 ?$ ]& \6 Y) [1 U& b' z% emodgroup g-mailsvc add Email before Public-IP
- y6 K, ?1 O# L' ?COPY
J4 y" W' |% }5 p5 c' GTo remove a resource from a group (for example, Email), use this command:
! R8 b) B- E' a
4 r% A2 o! i! r6 x: X3 Rmodgroup g-mailsvc remove Email
+ W1 e3 l# b) Q7 xCOPY' F( i6 y9 _) {- F' x3 Q# a }
For an overview, refer to Section 5.3.5.1, “Groups”.9 W6 E K+ k) d+ S4 p
$ L: U, G: p% q4 l4 R
7.4.11 Configuring a Clone Resource: ?: m4 W% S! ]% M# [
+ r6 r" Q5 _8 X
Clones 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.
$ {7 K B- H9 x! p
: l0 W) f; b' k, ~3 cLearn more about cloned resources in Section 5.3.5.2, “Clones”.- ]) x2 U4 D' E% o+ I5 \) h
6 h7 z5 v7 ]! H* w) X. y
7.4.11.1 Creating Anonymous Clone Resources
3 S+ I, O& I# Q& V
% A# I# D6 c' a# b! K) ?! yTo create an anonymous clone resource, first create a primitive resource and then refer to it with the clone command. Do the following:
3 [, c2 h) e+ C8 \, V0 O1 ?; G6 K3 t
( J C# V" p; D* t) BLog in as root and start the crm interactive shell:( [5 P4 g% w' `( |
+ ?, _6 z8 W, K' \. A& Y$ {* I
crm configure9 I: h" }: b( x; s* N4 J
COPY. ?. ?% P: k. c1 _. O7 H1 I
Configure the primitive, for example:+ h) B2 j) A. r, y# R
4 ~0 |, k+ b; S6 ~! a) [) Pprimitive Apache apache
# u% @+ D1 a3 x& i- c- _COPY
7 s+ ?3 y% e4 Q( I& l* tClone the primitive:
, o/ R3 |! j& @& E2 W( i
- J! r I6 |$ |' r, a8 @clone cl-apache Apache
4 Z5 z w8 {5 S0 W0 G( ]COPY7 k, m1 m+ X1 j6 j$ Z" o# k
7.4.11.2 Creating Stateful/Multi-State Clone Resources
' t( E! R6 @& w% V, f/ |! \
2 G m* J5 e BMulti-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./ ~" e0 K, K8 I$ d
8 P. p& b; F) p( TTo 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./ k; B& c0 }+ e
) [! _ o+ Y7 X& p( M
Log in as root and start the crm interactive shell:, A; ~6 K" _$ u" ^
3 H0 }9 [ | J. x( ~0 e. a X; Y
crm configure
$ l' X2 V( X' F! {2 F5 A7 hCOPY
: e3 c+ f4 [0 W, ZConfigure the primitive. Change the intervals if needed:
# q8 p6 j) u a7 j3 ^( Y( Z& y* K* K+ H" i/ r& g6 J+ x
primitive my-rsc ocf:myCorp:myAppl \
: x; u. u$ X: b$ F9 y op monitor interval=60 \- A5 _3 o7 @0 ?( ?- v0 {9 K# R
op monitor interval=61 role=Master9 @. @' w; ]6 v
COPY
# [/ e1 w A' [" ^5 n S& L% ^Create the multi-state resource:
- x# I( _' A- R) _. g
8 r, [$ k4 G2 v) j$ ^: F' vms ms-rsc my-rsc& C) X3 E8 n) `4 W9 f! L5 n0 S
COPY
" M9 b8 i- M! [/ Z7.5 Managing Cluster Resources
$ A/ X3 d) @& B2 p2 N: E5 ~ ~$ S% L
# o1 G0 [, U: K% Z6 iApart 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.
`4 ]' `7 @5 @* w+ K$ m' Z* b. ^' c) F4 u8 X2 E3 y* S' C% b/ |( {
7.5.1 Showing Cluster Resources
. \# |- u! {3 ?: u7 ~# P1 s {9 R' z M+ d
When administering a cluster the command crm configure show lists the current CIB objects like cluster configuration, global options, primitives, and others:
* \1 a" [# r* O, Z+ Q3 I6 G e1 I# d
crm configure show
! u, o! H3 S( z6 `2 a+ S& U0 Nnode 178326192: alice
6 @, P$ ^! U9 q( ~node 178326448: bob) v% Y: @- u0 o
primitive admin_addr IPaddr2 \
* g2 ?) B/ Z3 _) y$ s: p$ S8 ~ params ip=192.168.2.1 \, X9 H- }* _3 p% W
op monitor interval=10 timeout=20
! t5 ~+ @; F# I t; Kprimitive stonith-sbd stonith:external/sbd \
z2 H: {, E k params pcmk_delay_max=30
( c6 e! C; J" Eproperty cib-bootstrap-options: \9 G8 `4 A- S( c9 i1 |) P4 f
have-watchdog=true \
$ F* Z! z p1 N2 I$ X% b dc-version=1.1.15-17.1-e174ec8 \3 ?+ n9 r0 M( b7 G& h
cluster-infrastructure=corosync \0 l+ x0 C1 i! \9 x# s! D' {2 r& E# g
cluster-name=hacluster \
7 h3 B. a* e* v( s+ H stonith-enabled=true \2 E# q$ ^2 T9 M: j; X! l
placement-strategy=balanced \
: k2 R3 w' J6 P standby-mode=true
+ f0 E! a) t* H5 T: Crsc_defaults rsc-options: \
) O ~$ o$ t/ U resource-stickiness=1 \' y7 t2 p- o5 z" A8 u
migration-threshold=3( c: s, `& P) h) u
op_defaults op-options: \
7 ^" ^: W( N& D8 u( J timeout=600 \1 y1 j# }3 s, W* F& R4 J
record-pending=true
) y; k! W9 @# i- L3 A- }COPY+ [* v4 ^$ v: b
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:+ Z# m& P3 V7 z3 G0 r& a
# Q; N/ {) R ^# t& B" \" `" [; D$ p
crm configure show admin_addr& s4 W2 f/ f+ \# c
primitive admin_addr IPaddr2 \1 e- H5 s: L1 d" w
params ip=192.168.2.1 \
$ E4 @; }# P$ q. T op monitor interval=10 timeout=20- a2 @3 v4 Z9 K
COPY' p* @! G7 h. Z$ ^7 T" m
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:
3 _ R/ O' I. `& }, L- A$ M9 \5 o% L" o( x: w
crm configure show type:node
( _/ N. U' l: {& `6 O3 ^5 z5 znode 178326192: alice; l' A: ~- C+ ^8 U& s3 x6 I
node 178326448: bob
. H4 B; y4 X& ~4 }3 h- ?2 G7 W; |COPY
5 G6 ?: ^3 u( [: k5 TIn case you are also interested in primitives, use the or operator:" A o; ~0 [3 A" H, V9 F3 z- q
+ ~! W3 \+ L- L9 Y! E
crm configure show type:node or type:primitive" q* _+ ?# \1 U. a# [* X
node 178326192: alice: {' S9 g0 m/ }) ?; t
node 178326448: bob- W- z6 _8 G" E" t2 B
primitive admin_addr IPaddr2 \& ^# U1 X* E8 w: d) \- u9 H+ V
params ip=192.168.2.1 \
. e, Z8 T' h1 c" O ^, U: V; s op monitor interval=10 timeout=20' {* ^0 Z0 e' @8 V: |
primitive stonith-sbd stonith:external/sbd \
( n# _; v) s4 Z4 Q; _5 M. y params pcmk_delay_max=30
: `- _9 m- Z, z3 N0 n5 ~+ [" MCOPY) ~6 `: O% R9 @! d% k/ |" o% E
Furthermore, to search for an object that starts with a certain string, use this notation:1 J, n$ Z7 j( I5 A& [1 V
6 I4 b) L! w" h# I8 G- F# X0 m5 gcrm configure show type:primitive and and 'admin*'& q# Y6 q2 ~# o" s U
primitive admin_addr IPaddr2 \
# e2 G; j, d/ K+ U v5 P params ip=192.168.2.1 \# j- ~- V2 ?5 l. o1 A, v7 W
op monitor interval=10 timeout=20
3 K! |- U, g3 F) _% R0 _9 ^# qCOPY2 D0 B4 l- J5 e. \" \5 F
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.
" W' M" c% j0 e8 X& H! j* M; ^
: E* |! n9 b$ t: V7.5.2 Starting a New Cluster Resource
# y9 k2 o6 ^; L( K4 |
$ a3 [; s" g4 E ^To start a new cluster resource you need the respective identifier. Proceed as follows:
" i5 ~# S+ Q! W$ [3 Z k/ L2 R+ f- ^/ k# H" r, g0 R: m
Log in as root and start the crm interactive shell:
9 r# O7 z" @0 I1 z5 T; e2 J& B: _$ ~8 K1 D9 O! L2 Q# _
crm6 s2 C6 W9 e; [! ?. n
COPY p& f( I: L1 o3 @4 }; s/ O
Switch to the resource level:* T1 o+ @' F6 S% m
/ o6 H5 S7 y* p! l7 V% X6 D: J
resource7 E F( {* x3 o, J; g% J) @) I) @
COPY$ u6 K" k2 _9 u: M, M; h: y; j7 v2 {
Start the resource with start and press the →| key to show all known resources:
. ]( V7 l( f' e. F. m! @. b1 z% H3 M3 V; b
start ID7 d5 ^. R6 B2 v4 K( i# f
COPY6 t/ [$ E- j/ X3 ^
7.5.3 Stopping a Cluster Resource' r& f3 J& O; q3 C" g
! ~7 |& J6 T. x" r& x& m6 Y
To stop one or more existing cluster resources you need the respective identifier(s). Proceed as follows:7 U! i" n5 ^" n; V
! C9 ~% n. |1 U$ _* a) e3 G
Log in as root and start the crm interactive shell:5 B3 }+ l" i# H7 x s
j. u; K$ s* k0 m5 E4 l9 X2 y
crm& t% h( j2 e* a- Q- D
COPY
5 L" S. }& R! J: |% Y4 U: ZSwitch to the resource level:
. s# x2 U) s, Y5 B9 p8 P( ?+ L x% Q- V6 c# _
resource' u+ P- {8 _7 B }
COPY
: O! i! A! g6 O. qStop the resource with stop and press the →| key to show all known resources:! B4 q" `$ u: \& V0 j, B
3 T. I3 R: C! \* G: q! |5 W5 K
stop ID
* b" G$ W2 I* [6 D! VCOPY
1 b. e+ a; M) u0 bIt's possible to stop multiple resources at once:& h6 o( z- X5 C' i
& H* Y4 e9 r* v5 A, A/ _stop ID1 ID2 .... l# U& C2 H1 b6 S. }; `
COPY8 J$ u9 _: {, v l) R- t5 A4 ^
7.5.4 Cleaning Up Resources
5 f u v8 B7 G1 z1 n# e0 L
( O" ~! I0 [( O+ f3 ]7 xA 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.
' Q2 ]3 O! f3 s9 ^$ w R8 R& J; N0 |- K! U8 k# D2 S, c" t
Open a shell and log in as user root.1 n- q$ v* F) h A+ I7 b: b
$ O3 u7 ?( L* N* ^! o# U
Get a list of all your resources:
5 _% i3 T+ @" ?+ E6 Q. H3 i; h/ `
6 C6 Y3 K: A$ {( O1 g" Lcrm resource list k2 v5 a6 e! C' v
...
% y8 {( N' W7 J6 o2 sResource Group: dlm-clvm:1
' v ^% K; P2 j4 M$ t) O- e: K dlm:1 (ocf:pacemaker:controld) Started# j" m" ]( @- s9 v( W" u/ {
clvm:1 (ocf:heartbeat:clvm) Started" u- a K: x! ?
COPY
' j( I/ D1 I1 G- F( }3 O( xTo clean up the resource dlm, for example:
3 l- b" _$ h! U/ F0 k" R: Z, o7 q3 A8 S* N6 x
crm resource cleanup dlm
9 \ W, y5 ]6 O' T- d6 FCOPY* G$ h& b5 Y- C) @
7.5.5 Removing a Cluster Resource* B) }7 p2 O+ F: f* g9 s2 j. u
; _. l) X) ]6 a) @1 U" s3 ]$ I3 \
Proceed as follows to remove a cluster resource:
( m! t& l Q4 L% R O; z% D( v# @+ b
Log in as root and start the crm interactive shell:5 T+ ]1 @; `. B) p0 f+ ]
$ d, A" O; y" ~: C) K7 Jcrm configure% g7 e2 t& ~6 {7 ^1 \
COPY7 c( B7 |/ U: e) t g0 c
Run the following command to get a list of your resources:1 S! ]" h$ p5 m5 [6 Y+ [
& ]' \$ w( q# T8 J/ fresource status
6 I! P; ~: G) R* J- w. S6 BCOPY
* {- Z' c1 ?, ~9 R6 }' y. XFor example, the output can look like this (whereas myIP is the relevant identifier of your resource):
) P2 a2 {1 j; l& N& Z- w9 q5 N7 y# u# c5 P4 `
myIP (ocf:IPaddr:heartbeat) ...- r6 @/ K: C! Y: J$ ^& o
COPY
% x" M4 |' n/ y' h9 @( D: B8 L" f' Y' MDelete the resource with the relevant identifier (which implies a commit too):, o8 z# J8 W; z
+ M$ R6 [# g' |" b/ Aconfigure delete YOUR_ID
) Y; F' b. H$ ]' v$ P) TCOPY% r9 Z. t* Q0 g( t" D3 Z* F
Commit the changes:
7 g+ o" h# l8 g. @4 x1 K
5 S( o6 S/ o7 Nconfigure commit6 v- c: k' v) _/ C! \
COPY
& R( ~5 B3 @/ I* s @7.5.6 Migrating a Cluster Resource, L5 o% `9 B* x
, P, J# W( T1 I& D9 h( ~% eAlthough 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.
" q. P! L" g* e7 h& P) l- ~' l- l- A
Use the migrate command for this task. For example, to migrate the resource ipaddress1 to a cluster node named bob, use these commands:
3 ^( z+ E _3 X/ u/ ^$ W4 ?+ K) Y) h9 M9 u$ k0 g: P' T/ |
crm resource
* ]" l5 `$ l7 y8 [9 G! Q4 xmigrate ipaddress1 bob$ K4 }& b) F8 F1 `% w' F. u
COPY
, I+ I& t. ?; t4 c$ S4 B7.5.7 Grouping/Tagging Resources
& w" A1 Q; {6 a" n8 g _) y$ V( d! V8 |9 {1 _
Tags 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:
5 F h+ f! X6 b# t
5 Q- a6 j0 C1 n1 E0 g$ ]8 `5 H% Vcrm configure tag databases: db1 db2 db3
7 \6 k# n9 D2 D0 }5 `COPY
% P. R& h/ h; x4 wThis allows you to start them all with a single command: C" L1 I, Y' A8 ~
5 n/ s4 N y1 W- \! k* d9 b
crm resource start databases$ U6 c( Q' l+ g! Y& s, {5 `: [' r
COPY
, i5 X: v0 S, J% G7 B& F' q. sSimilarly, you can stop them all too:* u T: F* i# V( ~8 f' b
% B7 I% |. H$ z- W/ t. B
crm resource stop databases" V/ T( ~% f9 s+ E% O) L( I a
COPY" n0 x, F0 I: a" \( @) E9 D. \. j" M
7.5.8 Getting Health Status$ D8 E5 R1 L3 \" `( r
- }2 G0 E) w0 W) k2 zThe “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.
' b. k+ Z R/ l2 @. u+ {+ U, F2 F4 a4 x) ~# |1 j1 R
To get all the details about the health command, use describe:8 H7 ?7 j; M" f
5 ?+ p- ^1 A. }: f6 m5 F" {
crm script describe health9 D" b7 b5 p& W" F6 E6 \
COPY
- |7 `( n% h4 S: Y5 _It shows a description and a list of all parameters and their default values. To execute a script, use run:
/ o% P0 \) z8 o, ~6 o+ D" I$ _
0 m1 Y# N+ t2 Y5 o1 G; I- v& Fcrm script run health, p3 d9 C& k5 ?
COPY. ^+ y+ q1 I, H- \9 f. f
If you prefer to run only one step from the suite, the describe command lists all available steps in the Steps category.$ T& F9 X% m) j0 h+ M$ [0 g$ o& u# S
! }1 L4 n9 H* W- r8 s
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:
Z1 @8 d8 a) y- _/ z9 d
8 M8 G- @- F2 O5 M- A& e% T1 Lcrm script run health
O+ S+ E- R5 H statefile='health.json'+ T! D( _0 u8 t( {) A$ I5 r
COPY
; i0 u8 _3 m/ ^) ?It is also possible to run the above commands with crm cluster health.$ \/ j9 t( d1 l2 z& R
6 f- X9 C* G* L0 h5 m
For additional information regarding scripts, see http://crmsh.github.io/scripts/.
3 m3 b! ]0 ^5 l/ R- |; {5 G9 T; t# q9 V- o/ [8 I" K2 Y
7.6 Setting Passwords Independent of cib.xml1 G. D- f7 E7 B8 ^. C
6 l9 i) q$ A* w sIn 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.( l3 I/ @4 J1 i$ o* U7 J7 ~
1 u; I* z) }9 B A$ g e* n1 oBefore using secret, better run the show command first to get an overview of all your resources:
9 Q* ^9 U/ q4 E; \
+ `' h9 ?0 f7 z! @6 t) K( X' ecrm configure show
7 z% `* k- q; R" C P4 W4 l7 qprimitive mydb mysql \
! m3 |* `+ b/ V/ ? g) b params replication_user=admin ...( i* b, v) r5 @% ~
COPY
' a2 D0 j* t' O$ N/ K* @, zIf you want to set a password for the above mydb resource, use the following commands:" U6 Y* a: X/ n3 m% G2 h3 e+ _5 ?
: Y' z" X+ y) R H& lcrm resource secret mydb set passwd linux! B( x, G" V* ?
INFO: syncing /var/lib/heartbeat/lrm/secrets/mydb/passwd to [your node list]- z& u- A V3 f5 n2 H' x
COPY6 I, ?' N8 V- Z1 k& c9 p9 r
You can get the saved password back with:# G$ }9 ~$ k0 J5 n4 C- f
! z- ?* ^% p+ a. x. {crm resource secret mydb show passwd
/ ~" d. d s8 O( wlinux. p8 H _1 X) G& E- O
COPY
0 n% i5 ? A) oNote 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.* c% B% k- w7 K6 Z" I. U! t
6 i' w' b6 |0 I0 t: G2 H7.7 Retrieving History Information
+ k% I. t% H* h2 f" K
9 _; w6 |0 m" n+ ^# DInvestigating 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.
: H" T2 e4 P3 V; C6 Z1 y* n% Z, @4 z* X( c! l/ w7 d
Each cluster moves states, migrates resources, or starts important processes. All these actions can be retrieved by subcommands of history.1 w% o, s- r5 R& W8 A) V2 n0 H P
" k% J% L: \ c/ Y6 k4 V: HBy default, all history commands look at the events of the last hour. To change this time frame, use the limit subcommand. The syntax is:1 R5 p3 ~+ i+ I' w& K% l
) L; L6 b! c6 ~& q, {! w! [crm history! \/ x% Y# y. Y: a: N: b5 d
limit FROM_TIME [TO_TIME]( N3 D, @' \- L/ g( L) c
COPY, h9 N s$ H% H4 w% }0 x" `
Some valid examples include:
8 t( q5 r# x: f% Z5 u2 d
% b( y/ }" T+ G8 I/ m! Wlimit4:00pm , limit16:00
' b. {: g+ W5 Y. R) g- K$ s" qBoth commands mean the same, today at 4pm.
3 N* T l& g f5 d$ ]8 D. [+ r$ Z% C0 H# b( n' t# ~* m1 `
limit2012/01/12 6pm
6 t! \/ ~* K5 V7 L) PJanuary 12th 2012 at 6pm: W! w0 ^6 U, V3 ^7 [% r8 f0 G8 u
7 E" ]2 w$ a9 O( }& Nlimit"Sun 5 20:46"
4 |0 M2 ^2 w: v) l. S4 {In the current year of the current month at Sunday the 5th at 8:46pm
6 m6 T' r. p& d, E0 Z- R! g d
K T9 z+ s& TFind more examples and how to create time frames at http://labix.org/python-dateutil.2 O; F8 Q' U) e1 D( [
8 \" r6 H: x0 Q$ y7 W" mThe info subcommand shows all the parameters which are covered by the crm report:
: P8 e5 @# r$ ^2 N4 `, i( J
% i0 e) B, `6 h5 @: R0 Pinfo! S! l3 q3 F: T6 ^
Source: live, K* C/ K6 I+ |. o7 h- [, Y* c Q
Period: 2012-01-12 14:10:56 - end
/ D2 h2 Q" H) n6 O( u" ]Nodes: alice1 b' l5 L, d% l4 |0 s
Groups:
) ]2 V! B5 A' t% u6 NResources:
9 n- Q4 }5 g5 d1 _# ` l8 j6 RCOPY
% y2 ]' F7 a4 X- wTo limit crm report to certain parameters view the available options with the subcommand help.
8 n D% U: s- @" W8 D. |$ n( v1 q6 c' t$ \" a- Z6 E1 R
To narrow down the level of detail, use the subcommand detail with a level:
8 _2 ]) ~" A4 N" U2 Q
9 J3 r$ j i; a+ Wdetail 15 {9 X5 K E' S; @0 ]$ K. c
COPY9 g3 k$ c1 T8 R9 j: ^2 K* z. R
The higher the number, the more detailed your report will be. Default is 0 (zero).
! |0 ~- M) r2 |) ^) @
6 o# c4 v; @7 J- F1 f# ^0 VAfter you have set above parameters, use log to show the log messages.
4 b, E4 T8 k3 |7 I+ \' f( N1 K) ~$ I% C- _- z
To display the last transition, use the following command:
% i6 L; k0 w3 @9 A6 ~4 C4 ]9 H5 A
. s$ A; w; s& ]0 k' }- ^transition -11 N9 k. v4 Y" t8 l! }
INFO: fetching new logs, please wait ...
0 I* ?1 Y2 p+ A$ E" _. v, sCOPY
) z; x5 }6 W0 y7 L5 K/ ?# \2 TThis 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.7 u: Z$ z3 |6 i3 r2 G+ { P
! z' ]; ?- p# A
If you do not want to open the transition graph, use the nograph option:' K) q+ B. w4 S4 r9 r, R
b l* s* [6 Xtransition -1 nograph5 [" }+ j& a2 X, d* \$ h
|
|