|
|
MaxScale, an open-source database-centric router for MySQL and MariaDB makes High Availability possible by hiding the complexity of backends and masking failures. MaxScale itself however is a single application running in a Linux box between the client application and the databases - so how do we make MaxScale High Available? This blog post shows how to quickly setup a Pacemaker/Corosync environment and configure MaxScale as a managed cluster resource.8 }2 T6 e" w7 o) z6 B/ q% u
Anyone following the instructions detailed here, modifying configuration files and issuing system and software checks could create a complete setup with three Linux Centos 6.5 servers and unicast heartbeat mode.
! i& O% g2 }: p: O+ C3 zIn a few steps MaxScale will be ready for basic HA operations and one simple failure test, the running process manually killed, is showed as an example.
2 i' d' p* d, m" W' lWe make the following assumptions here:4 Y* @# f! t9 ]$ D- d& B4 Q
The solution is a quick setup example that may not be suited for all production environments.
8 ?8 H/ `+ `! U7 y$ s" i! X! HPacemaker/Corosync and crmsh command line tools usage is known at a basic level& \3 x# x1 w4 E8 }
A Virtual IP is set providing the access to the MaxScale process" Y- c1 s* r% G) l
MaxScale is already configured and working with a MariaDB/MySQL replication setup or MariaDB Galera Cluster
T' g' x9 B1 d) n" {/ R% YMaxScale process is started/stopped and monitored via /etc/init.d/maxscale LSB compatible script that is available in RPM package from version 1.0. The script might be found in the GitHub repository, for Ubuntu as well.
2 L" m; B3 S/ g0 d, r9 U+ X- l, BStep 1 - Clustering Software installation/ m8 B8 w* b/ H1 U7 @5 A
On each cluster node do the following operations: \' D* T& b% ]7 W! j1 Z
Let’s start enabling a new repo
c5 n- E1 V8 k$ f6 @6 u+ _# vi /etc/yum.repos.d/ha-clustering.repo3 ^6 {" M, B8 j7 m8 j* H
and add the following lines to the file
% {6 ^/ h& E p) K$ N2 l[haclustering], v0 t, O1 X( p) c. @4 v( n
name=HA Clustering; |# b5 v7 v/ y: k, C7 ]
8 d2 e& w! b% p9 z" j
baseurl=http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/
+ | w9 Q" ^; W% N" Q1 {
' e( M7 W( g( D0 Penabled=1) g. ? B) y' j! Q& N
0 B/ I$ v. {4 u1 K# X. D) l
gpgcheck=0% y7 m/ `& i: W3 N" d g
Now install the software.
' `! M5 ?; v% s1 I2 C# yum install pacemaker corosync crmsh5 a: K5 T3 J& w/ K3 v
Please note the packages versions used in this setup are:
9 z8 v' ^' \1 Q0 p5 t+ g7 B" ipacemaker-1.1.10-14.el6_5.3.x86_64
. F. _/ G+ S1 Bcorosync-1.4.5-2.4.x86_64
" b- `- b* f; {/ @, l8 Scrmsh-2.0+git46-1.1.x86_64
8 v) ]& A$ y2 U- N( Q( Q3 EStep 2 - Configuring the system2 H3 Y" @# m6 f c
Let’s begin assigning the hostname to each node:3 d" j& [ D2 R$ ?" {
The node names are: node1,node,node3
" B! ]; \" }: p3 G y. x# hostname node1
|# e1 ^: q: T @% G8 u' T...2 C8 b6 }$ l+ b- j c, I
# hostname nodeN
! C5 F: v, E7 l% R9 ?and write entries in /etc/hosts:3 t$ z+ t& Y) z. w
For each node add the server names and current-node, that is as an alias for the current server.
% \# a1 j' s5 _$ l1 e+ v# vi /etc/hosts
1 J6 t7 u; r1 y( ^( z10.74.14.39 node1
+ N( ^ {) B2 z- f- E4 D0 y10.228.103.72 node2- l/ S( g" N6 O, ~ F7 G0 Y! u
10.35.15.26 node3 current-node ..., ]) m9 v' Q7 z. k F+ w
# vi /etc/hosts
" O% K4 V3 Y F4 R10.74.14.39 node1 current-node: X/ g4 i$ g+ ?: J+ m9 ~ d
10.228.103.72 node2
7 U, ~& L1 l; n4 c0 j( g10.35.15.26 node3* L$ ]+ t$ Z+ r F8 V" R
Prepare authkey for optional cryptographic use:, }6 l" Y7 w" b+ F$ Q+ @
On one of the nodes, say node2 run the corosync-keygen utility and follow the instructions.
1 t! O( O Y1 ^* K[root@node2 ~]# corosync-keygen! ~6 n' P9 J: E; a1 e7 O7 G/ _
( Q% U5 |( O: J0 e3 n+ E$ Z% ^
Corosync Cluster Engine Authentication key generator.
+ h! r- h0 z& a& `; G0 p Gathering 1024 bits for key from /dev/random.3 ~% T+ Y' e( H1 D6 s) D4 k9 D7 P
Press keys on your keyboard to generate entropy.
) [& N, ^$ w+ lAfter completion the key will be found in /etc/corosync/authkey.
3 |' R# I& O. |" |& F! WNow let’s create the corosync configuration file:' N3 Y6 a5 v$ B, C$ R3 N4 ~, n
[root@node2 ~]# vi /etc/corosync/corosync.conf7 z. `" O- {0 z1 z T% L* A
Add the following content to the file:
% `9 T. g) m* y3 \) N( r0 w# Please read the corosync.conf.5 manual page2 k5 P' L: b# p0 Y- [7 _
compatibility: whitetank% J8 Z9 a) D8 m# A: Y7 y, X
" H" h* w: f) F1 `3 Q
totem {3 A9 x$ I! T1 V) f G
version: 2" r; r) y) J( v* a0 G
secauth: off
% @/ c# b4 v+ K: f8 T* y, T* } interface {4 _ n1 I2 R5 W+ J4 V, a* _5 e
member {* \; r/ H+ n( `: Y( m% f% d$ A% @
memberaddr: node1
+ ^0 S) z- H2 v) ^ }/ J" Y2 U$ b0 s
member {
: V. @8 `3 u1 p% r memberaddr: node20 |( \8 C9 G6 i) K6 n6 `
}
; Q4 P, g6 z, D member {# ^- e+ c u2 E
memberaddr: node3$ `" l, |0 B: E4 c- Y" h* X
}
, k" P; C: v& ]* z7 F ringnumber: 0
6 z- W4 b4 _! f% Q' n bindnetaddr: current-node
6 Q1 C' s$ G2 |( Y8 Z$ v" V+ O mcastport: 5405: @4 d# j5 B0 {) J! [3 a- Y* z
ttl: 1
|9 w. h; U( `8 H0 N* T$ P# i } V( P% T$ k* ~- ? ^8 a0 p/ P7 f Y
transport: udpu- B3 Z8 T3 X2 ^
}+ u3 i# W: Y+ v8 Q5 s9 ^
& Y: x% e$ i" w& ?logging {
, w1 j# [' j, A* @0 \1 T fileline: off2 F& f; n- C, @7 d/ R
to_logfile: yes
9 c6 z* w7 ?+ ~- o7 G5 p) o5 Z to_syslog: yes
7 W& q9 V M& d logfile: /var/log/cluster/corosync.log8 W p2 y' o% V+ k, O
debug: off
7 t' w! V2 [( s" T timestamp: on
- B$ N- [' m0 f0 w" j logger_subsys {/ _% P" v* g; y4 c; L
subsys: AMF
' E4 v$ D! H! T1 B: B0 G debug: off! b) I/ o; V' L
; |, ? T, Q6 u8 ?) k9 r- u ?" L
}
: g7 n8 z) \$ \9 P7 z5 M, s# V% \}
* _6 n: z8 x* o! }+ W }; I) a& ?/ d
# this will start Pacemaker processes0 J7 |! X! W5 \% F, s
service {
, d: k/ N6 M* l2 ~ver: 0
5 e% S6 U" _2 ^3 x. Kname: pacemaker
6 e* Y# Q5 }5 Y( H}: M2 @, m9 X0 d
A few notes here:
, [- Y* X# e& E- bUnicast UDP is used! \9 T" s" U5 p9 u' L
bindnetaddr for Corosync process is “current-node”, that has the right value on each node due to the alias added in /etc/hosts above) c8 b8 \# Y, v8 ~7 [0 B
Pacemaker processes are started by the Sorosync daemon, so there is no need to launch it via /etc/init.d/pacemaker start) t) F! W, G8 x' }+ ~
We can now copy configuration files and auth key on each of the other nodes:
6 E% k; H. N5 A[root@node2 ~]# scp /etc/corosync/* root@node1:/etc/corosync/* m6 S' A6 z. {+ w( P
...
5 {2 j$ r* ^# l W# K& b# B[root@node2 ~]# scp /etc/corosync/* root@nodeN:/etc/corosync/
' G/ v$ D% ?/ v5 L/ F# t5 aStep 3 - Start the Cluster( }- S' d2 z* X. J2 s- a
The Cluster can be started now but let’s do additional checks before proceeding. Corosync needs UDP port 5405 to be opened so we need to configure any firewall or iptables accordingly.$ v, {' y# K1 U3 _' `0 M
For a quick start just disable iptables on each nodes:0 E& j. U6 u* ?5 {6 E- D% f, D$ I
[root@node2 ~]# service iptables stop V0 o( e4 w3 L$ e7 q
…
. R" A) y/ L u( ]& X[root@nodeN ~]# service iptables stop
0 W* T+ Y! g( D) a: r+ j S) P: @Let’s start Corosync on each node:
1 q. a6 h: T2 |4 l$ @; J0 v6 R[root@node2 ~] #/etc/init.d/corosync start
: c/ I8 ]1 [! J' I' |8 y…
; L7 p& t; K, c[root@nodeN ~] #/etc/init.d/corosync start% _- U v1 q9 f; M% r
and check if the corosync daemon is successfully bound to port 5405:* ]( o" u! L6 I) w2 n6 l
[root@node2 ~] #netstat -na | grep 5405
+ }6 ^4 T6 l/ }1 j0 V5 v7 \
! ^. v' X9 d" P8 Hudp 0 0 10.228.103.72:5405 0.0.0.0:*5 i+ ^* f. K0 B
Check also if other nodes are reachable with nc utility and option UDP (-u):
}/ n! c q& K7 V[root@node2 ~] #echo "check ..." | nc -u node1 5405
. L6 E0 P2 ?$ L/ x[root@node2 ~] #echo "check ..." | nc -u node3 54051 r% F: [0 g$ }
…( l9 Y$ S! G, t& a; T
[root@node1 ~] #echo "check ..." | nc -u node2 5405
, m- f* W! y9 a% P7 v5 |; a[root@node1 ~] #echo "check ..." | nc -u node3 5405
; c4 x' V+ O5 dIf the following message is displayed:9 O: S) c ~: }% P: x1 M
nc: Write error: Connection refused2 h" W$ C' M, N9 F
there is an issue with communication between the nodes, this is most likely to be an issue with the firewall configuration on your nodes.3 l$ c! ?% [3 l8 f2 V! a
Please check and resolve issues with your firewall configuration.
( p" |* o( m( A) h) ?2 u% c( OWe can check the cluster status, from any node, with this command:
6 F. W; i- |7 Q2 R+ [; {1 ~" r[root@node3 ~]# crm status1 j* N) D& g3 u7 Y; F) z
After a while the output will look like:* }: \. V) ]3 T
[root@node3 ~]# crm status9 V5 b" ~* n. X1 r8 [
Last updated: Mon Jun 30 12:47:53 2014' S$ Y- m' V8 m3 y. B0 G" x
Last change: Mon Jun 30 12:47:39 2014 via crmd on node2+ G3 e+ P% F' k7 n E$ w7 |( A2 W
Stack: classic openais (with plugin)3 [# G& R' J( e
Current DC: node2 - partition with quorum
$ g; U0 |) ~3 o2 {9 R/ NVersion: 1.1.10-14.el6_5.3-368c726
+ K% L# K4 I3 B1 y/ X% _5 X: C3 Nodes configured, 3 expected votes! _" {% k& e R( w+ T0 E8 U. M1 n
0 Resources configured
/ ?- K9 X% G, B7 A! e" x' X7 ], [# _2 A9 x4 v) y
) ~/ T% A, U' EOnline: [ node1 node2 node3 ]
7 N$ x$ p) V; p6 M# G$ D( Z# EThe Cluster has been started successfully, that’s the first achievement so far!
( F) c2 o" n7 P' P4 I' M" gPlease note, in the basic setup we will disable the following properties:* {) I, ?0 r4 f/ q6 M& n' Z1 T
stonith
( \) ?& I p: K3 c. }quorum policy
3 Q }1 R7 m1 C) b& |3 n3 k; e[root@node3 ~]# crm configure property 'stonith-enabled'='false'
4 r. @) A/ G# e' F' s0 v& R: b[root@node3 ~]# crm configure property 'no-quorum-policy'='ignore'
$ a) j! E# @; B8 R+ JAfter these commands the configuration is automatically updated on every node and we want to check it from another node, say node1( O. ? Y9 }6 d: K% ~
[root@node1 ~]# crm configure show( k6 ~' P) Q1 B! o: F1 F
+ ?9 O! b4 r/ I# X( v* Fnode node1* M# H ?6 _ X8 G: R' E" h
node node2
( o$ ?% |0 n! y0 `& d! C# Lnode node3
6 N7 M# f( ] G, w. f) l5 @property cib-bootstrap-options: \
4 Q+ b8 J; J' f8 z" _3 W$ L dc-version=1.1.10-14.el6_5.3-368c726 \ s( T5 \( r8 t/ m6 a
cluster-infrastructure="classic openais (with plugin)" \6 ~# V) M4 ^3 d: D2 `
expected-quorum-votes=3 \' r* y8 d5 Y$ I1 g- @% ?/ J
stonith-enabled=false \1 t' o/ m/ U' c2 l7 Y" m
no-quorum-policy=ignore \( h# h8 o& {5 [4 c
placement-strategy=balanced \& |; }0 X7 K+ S6 w: P
default-resource-stickiness=infinity
5 w4 J' Q) O q: L( Q! ^$ FWell done, the Corosync / Pacemaker cluster is now ready to manage resources, in the next steps we’ll add MaxScale.6 r1 Z9 R: {5 V, e: F0 l* k
Step 4 - Check MaxScale init script# [9 G* @1 U- U+ @
The new MaxScale /etc/init.d./maxscale script allows to start/stop/restart and monitor MaxScale process running in the system.! P: V# J7 \: H; j2 D
The script found in the RPM package is already working with the following path: /usr/local/skysql/maxscale1 \$ s% @" f( N. P5 ~ z$ D1 g6 E, A
It might be necessary to modify some variables such as MAXSCALE_HOME to match the installation directory you choose when you installed MaxScale or MAXSCALE_PIDFILE or LD_LIBRARY_PATH4 _, S- l! F: X: S7 V7 Q+ o
We assume here MaxScale is configured with a MariaDB/MySQL replication setup or MariaDB Galera Cluster and those servers might be located in the three Linux boxes we are using or anywhere else.
* `5 N3 L, F+ V$ ?! o" Z; qFollowing commands should be issued on each node, assuring the application could run and managed:
$ h2 L( C" p! q[root@node1 ~]# /etc/init.d/maxscale
; V6 u# l( y" ^% k4 CUsage: /etc/init.d/maxscale {start|stop|status|restart|condrestart|reload}$ }$ S! }- H1 J% k6 \1 N; b
Start1 y8 d% d9 @, I
[root@node1 ~]# /etc/init.d/maxscale start E1 D) s) Y! [. S0 I, B: S; q
Starting MaxScale: maxscale (pid 25892) is running... [ OK ]
4 F1 n8 L! Z: MStart again
# }& e7 I" D4 o, J[root@node1 ~]# /etc/init.d/maxscale start
, w: l) ]5 N: I1 jStarting MaxScale: found maxscale (pid 25892) is running.[ OK ]
9 W7 s8 V, f, G; N1 M# S% w" sStop
0 q0 v$ D% z$ Y& K* e# K[root@node1 ~]# /etc/init.d/maxscale stop: N# I" b6 t/ g
Stopping MaxScale: [ OK ]
0 w4 O. S/ m' }* c7 r jStop again5 l; B# e; b5 |% |
[root@node1 ~]# /etc/init.d/maxscale stop& q+ ?$ F) O# |" n
Stopping MaxScale: [FAILED]/ U t k) d2 e5 [/ s% k5 }
Status (MaxScale not running)4 k$ D8 w5 `, H4 {
[root@node1 ~]# /etc/init.d/maxscale status( b& [- G0 q( n/ Q2 D: K
MaxScale is stopped [FAILED]+ I G0 {+ W+ T5 Z8 [4 v8 J1 n
Status (MaxScale is running)
+ k: ` _& ~# j8 Y3 c[root@node1 ~]# /etc/init.d/maxscale status/ m" \8 I) }2 v4 t/ d
Checking MaxScale status: MaxScale (pid 25953) is running.[ OK ]
6 ~% J( E' W( a6 |5 ]" ZAs MaxScale script is LSB compatible, returns the proper exit code for each action, it’s now possible to configure the application as a resource in Pacemaker, next step will show how to do it.
9 M c+ D5 i( J( OStep 5 - Configure MaxScale as a cluster resource/ D9 j8 {: X- _6 I6 R
We are assuming here MaxScale could run on each node with the same configuration file.
( Q, V3 N/ O" u8 B9 `/ X( m: Y[root@node2 ~]# crm configure primitive MaxScale lsb:maxscale \
T$ y" k: `9 t" sop monitor interval=”10s” timeout=”15s” \
+ w+ o7 r3 f0 v6 h5 iop start interval=”0” timeout=”15s” \, b, o: l6 U$ N$ Y
op stop interval=”0” timeout=”30s”
9 V) h4 N! u9 D5 p) F9 U' }% IThe command above has configured MaxScale as a LSB resource, note “lsb:maxscale”
1 S' n3 e( s) G, h" [In Pacemaker there are two different ways for managing applications:
9 k- w. x5 j. a4 VResource Agents (VIP, MySQL, Filesystem etc)2 D5 ]2 q- X9 }/ u9 w. p, r# s
LSB scripts for applications that don’t require the complexity of a resource agent and custom applications, in general.
1 P; t; N$ P$ e9 Q- P$ QMaxScale itself manages the backend servers we had configured in etc/MaxScale.cnf service sections such as:6 z. G7 K. [# v) N# u
[RW Split Router]
# V, a6 v- O1 z7 {type=service
" w' v& _( c) ?0 d6 }router=readwritesplit1 ]9 Z/ K5 l: A9 Y
servers=server1,server2,server3,server4,server5,server6,server7$ e8 o, H; @* }1 M3 Q9 Q
user=maxuser
1 L; B& Q0 c: }passwd=maxpwd
/ J) n3 b6 ]" \: U8 ^9 ^7 CSo we only want Pacemaker to manage the MaxScale process and the LSB approach is well suitable here.# W: n# r/ r) I6 M3 o: @
If everything is fine we should see the resource running:
3 } \8 V" \) C" q4 K* a3 W" d[root@node2 ~]# crm status
5 [4 o$ y# q5 X3 j6 @4 ~, TLast updated: Mon Jun 30 13:15:34 2014
5 {7 v( B* u ~5 z7 A4 eLast change: Mon Jun 30 13:15:28 2014 via cibadmin on node29 Q0 ~ b; X" X8 U+ t) v c
Stack: classic openais (with plugin)
# s% Q9 ?' Q7 c/ \. t M% L% b3 DCurrent DC: node2 - partition with quorum# R( D% i* _, d# ^, }( z& |2 y
Version: 1.1.10-14.el6_5.3-368c726! v( X* H2 e7 I/ c9 l% Q3 C
3 Nodes configured, 3 expected votes
" }+ }. e! L' c, \4 y; J1 Resources configured
( V j- \- H( s& L- x9 F5 U- K( E$ M$ C# n8 E
Online: [ node1 node2 node3 ]
; L! A: C z2 g% }
3 v6 ~5 H: q3 p: zMaxScale (lsb:maxscale): Started node11 n0 U/ ]# Q) @8 Z, W' ~
Well done, another achievement here!% Q4 u4 ]2 O0 W
We now have MaxScale running via Pacemaker and we don’t need anymore to have it started via /etc/init.d at boot time! Pacemaker will do all the job but it needs to be started at boot: with CentOS 6.5 setup we need at least:
$ ^3 j; Q" P5 |# chkconfig maxscale off
; j- Y( O% e7 u; c8 H- j# chkconfig corosync on4 w$ P/ \7 g3 ?% T& ^/ J
Step 6 - Does the HA software work? Let’s see a resource restarted after a failure:6 u! G: N( }% K* i1 l% j. q
MaxScale application is now managed by the HA clustering software but what does it mean?; N1 I% O6 \3 }' A
Will the application be restarted in case of any failure? It should be!
d& g5 t' }3 S( H5 eWe try now to kill the MaxScale process and see what will happen ...1 y7 U1 L) c4 D& G0 I4 i { y/ |
As we now MaxScale PID could be easily found in $MAXSCALE_HOME/log/maxscale.pid
" N7 |6 m$ @2 x# dIn this example the PID is 26114, and we kill the process with brute force:& D \$ `- v) t* Z; x L
[root@node2 ~]# kill -9 26114$ y" [; Z4 D9 M9 n2 Y
+ Q6 N6 }6 h8 d! H* Q" m2 h% v f/ b
[root@node2 ~]# crm status
/ s( G+ p9 X9 xLast updated: Mon Jun 30 13:16:11 2014
) r8 h6 k. L) SLast change: Mon Jun 30 13:15:28 2014 via cibadmin on node2
; @( A% r# n8 e. UStack: classic openais (with plugin)
: @$ h+ K* U7 p5 ^3 M' KCurrent DC: node2 - partition with quorum
) G/ b0 j K/ _% jVersion: 1.1.10-14.el6_5.3-368c726& Q2 E0 [3 s6 b
3 Nodes configured, 3 expected votes
h, `3 U( n* [) @" n, _) l, T! j1 Resources configured1 ?: N0 h- m& B5 w/ t+ g
1 b" R; E2 K( ~) Z
Online: [ node1 node2 node3 ]
3 ~- [. y+ Z+ c: k! `6 l
' y3 C! ]. |" ?1 B8 J+ C# `Failed actions:! Y& r8 _. N$ G% c
MaxScale_monitor_15000 on node1 'not running' (7): call=19, status=complete, last-rc-change='Mon Jun 30 13:16:14 2014', queued=0ms, exec=0ms
/ r7 |% X3 S3 M6 yNote the MaxScale_monitor failed action above and ... after a few seconds it will be started again:8 r7 `: I$ L- K: o9 Q N0 \8 m! O# r
[root@node2 ~]# crm status
( w* D+ h' e" d: b6 o9 i8 bLast updated: Mon Jun 30 13:16:22 2014
: {% @: S8 m3 Z$ c( Z) D4 [Last change: Mon Jun 30 13:15:28 2014 via cibadmin on node17 E8 R+ ]( K5 L% k H6 {! x2 \& _
Stack: classic openais (with plugin)
. o9 v+ R; S; U& e4 v' J6 r6 j( JCurrent DC: node2 - partition with quorum
; w3 [8 D, h6 EVersion: 1.1.10-14.el6_5.3-368c7262 W+ u0 Y1 w7 x! t" B* l
3 Nodes configured, 3 expected votes8 @2 n. }, K8 R4 D' a3 n A
1 Resources configured
. m1 p3 j& U: m' e, A. D2 p' q% C1 |8 P3 N1 w( E( `
$ F% @5 O+ |. ~
Online: [ node1 node2 node3 ]" |5 L5 x. h7 G
% \( A: D7 A! H+ } MaxScale (lsb:maxscale): Started node1 7 l: J) ~/ q3 q$ `7 Q2 g. K7 N
The Clustering HA software will keep MaxScale running in one of the three Linux boxes we have but … which node? and how could we connect to MaxScale from our client application if we don’t know where it runs?5 q( C) n. k( J% F; m$ k
# mysql -h $MAXSCALE_IP -P 4006 -utest -p test0 `) E# ]! m9 D# p: p/ x; i4 h7 j
What is the $MAXSCALE_IP then? Let’s Follow the last step ...2 W) J+ }% U5 e1 ~
Step 7 - Add a Virtual IP (VIP) to the cluster9 i5 j! ~4 U' H8 W0 R0 P
The solution for $MAXSCALE_IP is that MaxScale process should be contacted using one known IP, that may move across nodes with MaxScale as well.
/ C. @" k1 T( O3 ]The setup is very easy: assuming an addition IP address is available and that it can be added to one of the nodes, this i the new configuration to add:
& |4 r9 @ A7 P; M' c- u! }7 m[root@node2 ~]# crm configure primitive maxscale_vip ocf:heartbeat:IPaddr2 params ip=192.168.122.125 op monitor interval=10s" Z O, _" q9 \5 W- s7 b
There is of course another action to do: MaxScale process and the VIP must be run in the same node, so it’s mandatory to add to the configuration the group ‘maxscale_service’.
; e( Q6 _, u1 X* d[root@node2 ~]# crm configure group maxscale_service maxscale_vip MaxScale
! h; ~8 X8 e4 T) X5 gHere is the final configuration:
" `9 K3 N( @ r9 A$ y3 O[root@node3 ~]# crm configure show) w n$ M( q1 n! ]4 X
node node17 k1 M# b. W9 v2 i( k
node node2# K% ~# }0 l3 T( T; d P
node node3
0 u0 S+ B, D& rprimitive MaxScale lsb:maxscale \, o$ A& l* Y) ~! f) c1 [- d
op monitor interval=15s timeout=10s \0 F. L# y) V( T+ ~8 i* G; P: o
op start interval=0 timeout=15s \. V+ ^4 V2 {. w4 Y6 U1 w8 F
op stop interval=0 timeout=30s7 K. B, d( I9 r
primitive maxscale_vip IPaddr2 \
% O7 r; v# K" u2 G7 M params ip=192.168.122.125 \
) z7 `# u# Z0 U4 d# z" X- a op monitor interval=10s% t- A. P( s0 I4 @# o
group maxscale_service maxscale_vip MaxScale \1 W' D; @5 i( p: K+ D/ \
meta target-role=Started
6 J; n( z: f4 Z/ u% T( ?- j: F2 qproperty cib-bootstrap-options: \
) g" D+ S$ P, [0 m0 p dc-version=1.1.10-14.el6_5.3-368c726 \; C" e* M( |1 T8 U
cluster-infrastructure="classic openais (with plugin)" \
H$ _. [; K5 o. n# r expected-quorum-votes=3 \3 Z: F7 s: y4 p3 F1 S1 |' g
stonith-enabled=false \; U4 e2 S8 D( u7 Z
no-quorum-policy=ignore \
& l: v" c# K' N8 I placement-strategy=balanced \
) T# G/ b+ V/ h) u* B- b' Z, c$ N last-lrm-refresh=14041254861 f1 j. n* B o7 h u& Z( ]9 S
Check the resource status:
. D) Q, X: v! I4 A[root@node1 ~]# crm status* B) `: P( n5 F+ Z( x2 \
Last updated: Mon Jun 30 13:51:29 2014
! E" {) A6 O1 O& i/ V+ h5 HLast change: Mon Jun 30 13:51:27 2014 via crmd on node1" n# ]# {, w; }0 K1 o
Stack: classic openais (with plugin)
( k1 E8 u/ f7 V7 _9 o8 yCurrent DC: node2 - partition with quorum% Z: y' e: ^* z: P. M
Version: 1.1.10-14.el6_5.3-368c726
0 o3 D* P, L5 A* @% ^5 m3 Nodes configured, 3 expected votes
! @5 F- X% q& F4 v# M2 Resources configured
% ~/ }" Z0 N. B& \! `# }0 j
& ]4 t: Z3 [1 K ?4 r7 ZOnline: [ node1 node2 node3 ]0 X2 [. b0 c5 {2 W
* o6 B: `. P2 V* L" i, e f2 m [ y) t Resource Group: maxscale_service
2 u0 F# j: [% m! \. o6 b maxscale_vip (ocf::heartbeat:IPaddr2): Started node2 # E& I- @8 @: z& ?4 I
MaxScale (lsb:maxscale): Started node2 8 n/ z; Z0 S6 k$ r: W, p
With both resources on node2, now MaxScale service will be reachable via the configured VIP address 192.168.122.125:
; a) f& q1 M- L# I4 {6 r* u8 D+ E- E" v# mysql -h 192.168.122.125 -P 4006 -utest -p test
( n: Q9 o% e" N5 G1 dPlease note our three Linux boxes setup require now four IP addresses: one for each node plus the moving IP address assigned to MaxScale, Q+ I3 ^6 q7 G/ a5 m6 m
Summary+ @1 X4 W% p. c
The goal of this post was to present a quick HA solution for a running MaxScale setup, using a widely adopted open-source clustering solution.
) |: R0 K% S" U _1 j" l( M. bEven though the main content could be seen as a basic Corosync/Pacemaker setup guide, I encourage you to look for other failure scenarios and all the cluster administrative commands such as moving resources, adding constraints that could be found through the links below." m) N; Q- E T
The reader might fin the LSB script tutorials interesting too, just enabling another application to the HA side, |
|