- 积分
- 16843
在线时间 小时
最后登录1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?开始注册
x
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.
, ^) l0 S+ }4 ^! U$ z! R+ b% QAnyone 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.4 B, Q; h0 u3 X& ]. w R+ @
In 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.
8 x3 o* g# n2 [# u7 kWe make the following assumptions here:& a% _3 q! C, ^% B* X8 @* z
The solution is a quick setup example that may not be suited for all production environments.; @4 c( ]! i5 x: X
Pacemaker/Corosync and crmsh command line tools usage is known at a basic level
9 L0 _8 j/ ]0 n1 E. L" Y1 U% f. l" EA Virtual IP is set providing the access to the MaxScale process8 y, @3 X: ]" @" f7 M. b B8 N1 I
MaxScale is already configured and working with a MariaDB/MySQL replication setup or MariaDB Galera Cluster
/ t" ~+ l6 p% ~MaxScale 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.
) S7 ^* _" t# Y6 aStep 1 - Clustering Software installation1 c& `6 f. u- d8 w* C3 y) l
On each cluster node do the following operations:
7 Z- N9 [& u% l" o4 b fLet’s start enabling a new repo
5 @9 R V# N) {" j7 ?# vi /etc/yum.repos.d/ha-clustering.repo
! a( Q# I% t9 ?7 kand add the following lines to the file6 {( K! c8 x g3 Y9 s1 Q! M0 v& h6 y
[haclustering]9 l' d, g4 ?% Z1 f( U B
name=HA Clustering
* `: @0 y0 Q/ Y5 k" ~. D8 M, Q- v* `8 A: A
baseurl=http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/
, g' D2 p; D- V0 C# e, r) R6 h% g# x" z
enabled=1% ~% M% x' k& f
5 z7 h0 K7 d5 k4 r4 a2 B) sgpgcheck=0
+ C2 s) U: P$ {0 H. {# K$ LNow install the software.
# j1 d, U: g1 r! P+ c# yum install pacemaker corosync crmsh
. t) @. ?. g" }& L. k z) b# g/ _Please note the packages versions used in this setup are:% O0 t) Z5 w( q# h
pacemaker-1.1.10-14.el6_5.3.x86_64
8 {4 e4 E$ g1 q7 Ucorosync-1.4.5-2.4.x86_64: F, z3 B. i7 _/ n `! G
crmsh-2.0+git46-1.1.x86_64% }6 m0 o6 p; `% i' G8 N0 W
Step 2 - Configuring the system
1 m" k7 F( [$ B! F2 yLet’s begin assigning the hostname to each node:
2 W* z) U* K1 e2 Y0 I% }The node names are: node1,node,node32 r+ i+ K4 k# p/ } ]9 X$ H( ?
# hostname node1
& w2 B# {( {$ v7 ^: p...4 G+ E: \: N8 g! l
# hostname nodeN- c' a7 D- v3 T2 |" @1 j
and write entries in /etc/hosts:
" `5 w( w# q }4 }For each node add the server names and current-node, that is as an alias for the current server." `8 W$ ~8 A$ s3 d9 h6 p" m" p7 f" j
# vi /etc/hosts
4 U; J% o. ~0 |6 S10.74.14.39 node1
+ q/ F& ^. {5 o+ Y4 l) ?, c10.228.103.72 node2
0 c4 x t! f" B10.35.15.26 node3 current-node ...6 j( {# o. M: W: i3 j9 j c
# vi /etc/hosts8 b1 J7 B+ Q3 o
10.74.14.39 node1 current-node2 _) X/ p7 d9 D' Q' ^
10.228.103.72 node2
% P/ P( x3 h4 z: z& b/ W10.35.15.26 node3
! ^: w& j. K7 w9 ]Prepare authkey for optional cryptographic use:: h( W D3 g( g e% K& Q
On one of the nodes, say node2 run the corosync-keygen utility and follow the instructions.
6 ~7 j% p! @' ]; X[root@node2 ~]# corosync-keygen
2 f1 z) ~, ~) X$ z5 v2 j; d
+ Q* n6 ^) _* O% M( |Corosync Cluster Engine Authentication key generator.
. ^0 B/ ^; q/ ?8 C6 \. b( ] Gathering 1024 bits for key from /dev/random.' _2 L3 F. _/ k& R% {0 ~6 P
Press keys on your keyboard to generate entropy.4 f, E* Y/ `# ~& s( [; c7 |- ~
After completion the key will be found in /etc/corosync/authkey.
( b2 ?1 I+ l3 D( }Now let’s create the corosync configuration file:
4 ?1 D/ d$ u5 W# V0 Y[root@node2 ~]# vi /etc/corosync/corosync.conf1 ?3 k; A2 V5 Y. l9 T5 N
Add the following content to the file:
& A, Y/ Q! p$ T2 y8 i- v, M" X; m# Please read the corosync.conf.5 manual page
! a3 y! W/ T& Xcompatibility: whitetank
2 p6 u8 [' c# R& ^6 g7 f% X, U9 z
, q0 V. u/ O5 m. N# Q2 m, Z2 M- v& o& Ttotem {+ @, x4 \0 _4 O1 R% |
version: 28 u7 Y7 j/ @6 W: `+ I1 M
secauth: off+ U7 q* f3 L7 B
interface {
( Q$ M' h% K0 j3 y member {# s" \8 r! T6 g6 Z5 P% H! I- D
memberaddr: node1& S9 m6 P- x3 U/ b* x6 _. q
}
`3 {; H9 x0 U* m! g9 U. d member {
$ J4 D4 h8 z' D! v0 f/ { memberaddr: node2) E; ?; \3 f7 q+ G! }3 g
}4 V6 W8 F6 l9 Q ^. r1 K
member {7 L1 M/ U6 u) Z. U! i; A- a- I
memberaddr: node3 Y2 F1 \- d7 }
}7 ?. g3 e& u8 Z
ringnumber: 0
/ @0 N# u5 h/ }) C0 w' l0 P/ K5 l/ u bindnetaddr: current-node
6 d7 F( Z8 W5 [6 W: V6 }1 u7 k: O* _ mcastport: 5405+ ?/ `; B) L1 Z$ {3 ^* H, D
ttl: 1
1 Z6 o [* G X: U$ M }' r9 }6 p0 H0 m' I3 l
transport: udpu, I5 Z# X+ O# P. G
}
- t* d2 ? M: D: v* B7 g( q! d+ i
# B. a8 T/ m+ S z* s2 i3 Clogging {% c7 y z( A5 t! s$ C3 [
fileline: off: w0 S6 R7 L4 O9 q5 K' H5 S
to_logfile: yes
$ [2 V+ F- Q) \ to_syslog: yes
2 f. O- N `2 m. v- d! _ logfile: /var/log/cluster/corosync.log
8 ^/ B0 `" Y* J, | debug: off
" g$ o7 O9 A: L8 {1 z) t! C+ r3 W timestamp: on
3 Z9 f# w& g" k4 H. o; c logger_subsys {
) K; p* \; O2 b subsys: AMF
9 L& A3 K# v0 N debug: off
6 L$ z# d" a+ F4 h2 A1 X
7 x! p5 H! E& ~+ a' ^+ [ }
& k4 p$ w' I/ h. E}
- w [9 {) N" {% }% f5 K3 w4 S! {, v8 S( d; G. w
# this will start Pacemaker processes
, J$ v7 B+ Q+ g1 Uservice {
; Z6 X& t! h& s& }! Q- Wver: 0
& }( ? M; V% u4 {" a9 h3 J( Ename: pacemaker: D8 h. S, O" {; C
}6 `3 ^ b- }7 {1 k0 f [* X
A few notes here:& R/ `9 g3 ~( f' z' Q+ h( w
Unicast UDP is used
+ Y) ~! R( p) a+ X) \bindnetaddr for Corosync process is “current-node”, that has the right value on each node due to the alias added in /etc/hosts above( k/ T& L/ S. ~- w
Pacemaker processes are started by the Sorosync daemon, so there is no need to launch it via /etc/init.d/pacemaker start m$ {! s& V, _" \7 ^' K, \
We can now copy configuration files and auth key on each of the other nodes:
8 l: w9 j$ D) ?- p, d9 S[root@node2 ~]# scp /etc/corosync/* root@node1:/etc/corosync/
3 n. _3 D$ `5 \4 g...+ Z& p" Z& C& c- l3 c: T
[root@node2 ~]# scp /etc/corosync/* root@nodeN:/etc/corosync/3 S) j( p, N8 Z' f( j- M7 {
Step 3 - Start the Cluster
9 v: j7 q8 I6 p+ s, ^, |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.
0 e5 [! v* |1 ?7 U9 Y2 q+ |For a quick start just disable iptables on each nodes: K; e6 h# F" t' W
[root@node2 ~]# service iptables stop: M- U8 W; z4 V$ `# ?
…
3 ~+ ?* b" P: U$ I[root@nodeN ~]# service iptables stop
( R# ?7 R& F5 [Let’s start Corosync on each node:
1 K0 ~+ Z _9 k[root@node2 ~] #/etc/init.d/corosync start2 M/ i: a! N$ g7 u4 g
…( j# a$ u o3 s/ m8 }3 V$ o2 T
[root@nodeN ~] #/etc/init.d/corosync start
1 B4 P( j6 a1 z4 v: s" |and check if the corosync daemon is successfully bound to port 5405:% q1 V: {$ Z9 |. h
[root@node2 ~] #netstat -na | grep 5405
& e# ]$ [1 p; I! p. Y5 B# J+ _8 g0 U+ q' P
udp 0 0 10.228.103.72:5405 0.0.0.0:*, F% `- U* a0 B& v
Check also if other nodes are reachable with nc utility and option UDP (-u):
3 m# h$ n' g d/ U* m" r" e: n[root@node2 ~] #echo "check ..." | nc -u node1 5405
* J' M+ A3 Z7 F, p0 @6 D[root@node2 ~] #echo "check ..." | nc -u node3 5405
4 Y- m: L g; ]* f' K% C# \…( p* W" T; q5 | X# m! V& O) V
[root@node1 ~] #echo "check ..." | nc -u node2 5405
2 R v( Z3 F9 n; U[root@node1 ~] #echo "check ..." | nc -u node3 5405
" T( j6 R7 O0 G- K4 uIf the following message is displayed:
9 {9 D* b5 C0 e& p9 d" D# [nc: Write error: Connection refused
2 Y( C* Q, q) F9 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.6 i8 {! E7 H' l: z$ q6 a
Please check and resolve issues with your firewall configuration.+ @* l& [& {; c
We can check the cluster status, from any node, with this command:+ m4 h/ o: Q! N
[root@node3 ~]# crm status
+ z, e9 W/ f6 _: VAfter a while the output will look like:
; [$ f( _+ m, z9 e/ {[root@node3 ~]# crm status, @. \9 Y4 b6 Y
Last updated: Mon Jun 30 12:47:53 2014
0 S0 l: L( o) s+ E7 ULast change: Mon Jun 30 12:47:39 2014 via crmd on node2
3 d. Z y5 f; \5 AStack: classic openais (with plugin)) J( g3 ~8 \7 t) v1 [; p! |5 |
Current DC: node2 - partition with quorum4 X2 W' o5 U: e
Version: 1.1.10-14.el6_5.3-368c726' s; L4 P, a0 H4 A
3 Nodes configured, 3 expected votes" `" q: X) U0 i c% F
0 Resources configured$ l: u/ L2 T- H8 X- b$ [" g" ?
/ O5 f0 Y2 S! `7 I( Z7 L
# p; b: f6 z; w7 E
Online: [ node1 node2 node3 ]8 q$ ?- V! X) ?( C
The Cluster has been started successfully, that’s the first achievement so far!
0 H k0 r3 H9 v; n, L# n& APlease note, in the basic setup we will disable the following properties:6 e T, R, f6 u7 Y4 k- [, `
stonith& k1 o7 O7 ~' P q
quorum policy
' I7 f+ y( v6 x$ _3 g[root@node3 ~]# crm configure property 'stonith-enabled'='false'
0 q0 z; m1 c8 D& O" q[root@node3 ~]# crm configure property 'no-quorum-policy'='ignore'
7 [$ ^9 z6 h, J- b* C, kAfter these commands the configuration is automatically updated on every node and we want to check it from another node, say node1
. U x7 i9 A9 X( E- E[root@node1 ~]# crm configure show
& R2 j+ w. N' h7 G0 C5 |" C* c
1 f- ?4 a8 y0 _) l+ [6 U8 _node node1
# s J% O$ o/ w1 ]7 Anode node28 s' t* Y8 Q* @4 R/ w
node node3. T: l" ~# K& k9 W( y
property cib-bootstrap-options: \) W- B$ a% {! |2 X+ K0 r% ^0 I
dc-version=1.1.10-14.el6_5.3-368c726 \/ q& G2 u& x# g# p8 j; u' Y; o
cluster-infrastructure="classic openais (with plugin)" \7 ]. c `( O9 n2 i$ {! R
expected-quorum-votes=3 \
' Z* [3 K5 I! p: g& k0 ^ stonith-enabled=false \1 R% u: [3 {- b1 _" J- J
no-quorum-policy=ignore \
- O6 q, y" m7 K# b& @- S1 v& e( f$ U placement-strategy=balanced \
8 L/ E K$ ?4 O' R default-resource-stickiness=infinity
4 q: g: r5 v$ d" R# `6 W oWell done, the Corosync / Pacemaker cluster is now ready to manage resources, in the next steps we’ll add MaxScale.# c# T+ V" F. [5 W, `% D
Step 4 - Check MaxScale init script
: a$ A8 o- T) s. B% D5 x5 u% }The new MaxScale /etc/init.d./maxscale script allows to start/stop/restart and monitor MaxScale process running in the system.
s" V) l4 j- r" oThe script found in the RPM package is already working with the following path: /usr/local/skysql/maxscale( o; C1 q( F7 ^+ e2 _
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_PATH9 b6 M% l7 D! A9 b8 l! X* j- u
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./ M4 y" _5 d* ~9 [! o' `" \
Following commands should be issued on each node, assuring the application could run and managed:+ O* n3 Q8 j' N' O
[root@node1 ~]# /etc/init.d/maxscale
; T8 m2 }7 d. k6 hUsage: /etc/init.d/maxscale {start|stop|status|restart|condrestart|reload}
5 ]+ m4 d# q' h' c" U& jStart% y- O1 j+ X1 A
[root@node1 ~]# /etc/init.d/maxscale start/ H4 _2 X3 V+ p& Q* N. S! c1 i0 b
Starting MaxScale: maxscale (pid 25892) is running... [ OK ]' n6 G1 {& r4 h1 y) r+ U. w
Start again. g- K- M" f! s4 C; y$ n* U
[root@node1 ~]# /etc/init.d/maxscale start1 |" E" d. B+ f O
Starting MaxScale: found maxscale (pid 25892) is running.[ OK ]
9 B4 L$ Y" @, ?' `/ Q1 z) ^Stop6 t% t# W0 E0 N% {
[root@node1 ~]# /etc/init.d/maxscale stop: |- t7 P' c- X; K: x
Stopping MaxScale: [ OK ]- R9 }, T" J5 _9 X- L( l/ n
Stop again
/ F8 D) H5 A9 w5 k) G! ~$ t[root@node1 ~]# /etc/init.d/maxscale stop( T: w8 e( t0 X4 o b' @1 ^& D# E
Stopping MaxScale: [FAILED]% a0 z; u6 }' Z: I8 t6 `
Status (MaxScale not running); N; A, c$ n0 b% `3 `
[root@node1 ~]# /etc/init.d/maxscale status
) M- m& f) Y% XMaxScale is stopped [FAILED]
$ ]6 w# |0 j8 G# O. w" k2 g; r# PStatus (MaxScale is running)
$ T4 k3 [+ A b[root@node1 ~]# /etc/init.d/maxscale status- o/ \0 \: x" Z! i. [- i6 ?! _
Checking MaxScale status: MaxScale (pid 25953) is running.[ OK ]4 _: N1 q! n, G6 R, X7 m$ U
As 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.
/ ^# u v9 ^) [* S1 g6 [) Z, \Step 5 - Configure MaxScale as a cluster resource
% P- q2 W* B. h* E# ] j& zWe are assuming here MaxScale could run on each node with the same configuration file.
. _4 F, o) ?0 p8 P6 J* s" u[root@node2 ~]# crm configure primitive MaxScale lsb:maxscale \1 h2 b/ p, y7 |7 Y6 v
op monitor interval=”10s” timeout=”15s” \' q6 ^8 P. m+ [! ~* y) j; M& Y
op start interval=”0” timeout=”15s” \
& E8 I: V1 w9 S q7 jop stop interval=”0” timeout=”30s”
. A6 `3 g) m- t! k1 TThe command above has configured MaxScale as a LSB resource, note “lsb:maxscale”
- K8 j3 W3 f5 O& a( P# dIn Pacemaker there are two different ways for managing applications:! g3 H, u7 l& s; n% l- R( @0 o
Resource Agents (VIP, MySQL, Filesystem etc)
6 L' R" @, D) m4 J6 p# qLSB scripts for applications that don’t require the complexity of a resource agent and custom applications, in general.' R% s4 T+ R' C7 P8 `$ H
MaxScale itself manages the backend servers we had configured in etc/MaxScale.cnf service sections such as:
) L9 ^' a1 B F4 k[RW Split Router]6 V! Z& W+ |6 ~; ]3 m6 r
type=service2 X* ?# S( q2 O4 e/ ~
router=readwritesplit
* x# j" [+ F3 K; k2 hservers=server1,server2,server3,server4,server5,server6,server7
% W; a _) r3 _3 u( e1 K! i# }0 T6 puser=maxuser/ V- q8 X; q w- w6 L: P
passwd=maxpwd) J b+ a5 d3 j0 s" q, e
So we only want Pacemaker to manage the MaxScale process and the LSB approach is well suitable here.
, E9 U$ Q; U ?If everything is fine we should see the resource running:
) \6 z7 n' x& Q1 m0 T2 e( W[root@node2 ~]# crm status1 M4 ~, J. d- I. p' x1 W3 m
Last updated: Mon Jun 30 13:15:34 2014" }0 c. \$ l) B
Last change: Mon Jun 30 13:15:28 2014 via cibadmin on node2
8 e+ X! }0 e" S. F1 `' TStack: classic openais (with plugin)
( {- Z# k! t `+ _" c, N! B% `Current DC: node2 - partition with quorum
+ A. w' |5 C8 q- |6 _Version: 1.1.10-14.el6_5.3-368c726
?7 f7 _7 t" ]; x3 Nodes configured, 3 expected votes
* {7 d% Y% B" r4 x6 Y$ g& g0 |6 b/ e1 Resources configured
6 t" U* y2 n& D) r K. D% q8 e4 `( {5 [$ l: D$ ^
Online: [ node1 node2 node3 ]
, B1 h( d _* g5 K+ r( E
/ v& ]$ a% ^6 T3 H; u4 fMaxScale (lsb:maxscale): Started node1$ g; w& X5 f) A9 M" J/ d
Well done, another achievement here!
, a8 _% K) |+ Z% E+ P1 xWe 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:0 {, ?1 c1 L7 u* _ t4 i) C
# chkconfig maxscale off$ l& f2 z- u2 B/ a4 O
# chkconfig corosync on
) y1 [7 {7 c \! Y4 ~! u gStep 6 - Does the HA software work? Let’s see a resource restarted after a failure:
, L+ Z! w$ t/ D- a+ |MaxScale application is now managed by the HA clustering software but what does it mean?( ]0 E5 g7 I, [7 R
Will the application be restarted in case of any failure? It should be!
/ @2 S0 L4 A' k3 O2 iWe try now to kill the MaxScale process and see what will happen ...: D ~7 y; [, m" `. A- Q/ z/ K
As we now MaxScale PID could be easily found in $MAXSCALE_HOME/log/maxscale.pid
& {, D& l' x- L" h1 X( V: BIn this example the PID is 26114, and we kill the process with brute force:
- @2 ~, C' w; z% | C# `: N5 |[root@node2 ~]# kill -9 26114
% ^% t9 j! n6 u) ^ v2 ^
# B' |8 M4 ^$ J* F; z# }; r; h[root@node2 ~]# crm status) \# _. P# r3 U6 W: f
Last updated: Mon Jun 30 13:16:11 2014
. G/ a: z- a% X9 \7 WLast change: Mon Jun 30 13:15:28 2014 via cibadmin on node2
' T, A5 g$ F/ F& n4 \7 y3 qStack: classic openais (with plugin)
5 W! F/ h4 S' t% r) LCurrent DC: node2 - partition with quorum' B, @$ _' r5 ~) V/ m+ I* L$ u
Version: 1.1.10-14.el6_5.3-368c726
4 [' F/ Q' D1 l! z, n3 Nodes configured, 3 expected votes1 e" W. B; C: I1 T& n, H
1 Resources configured
" Z( i1 C! T& Z* S% N t
* `4 R0 M+ K7 G+ ?/ b9 b. H9 qOnline: [ node1 node2 node3 ]
3 |6 s9 D( ~# H0 a9 Y. I1 Y; F: h3 n; J* {& o1 d
Failed actions:8 G7 [9 p2 c* u9 ^: s" r! ?0 }* ]: r
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
% ~8 F0 a4 c9 |/ I4 |* HNote the MaxScale_monitor failed action above and ... after a few seconds it will be started again:; _- i) x# @% ?3 E6 z1 m
[root@node2 ~]# crm status! l; B- ~' Z1 u, n: J5 r" [
Last updated: Mon Jun 30 13:16:22 20146 P' O: z7 u- p) B' W$ F& Q
Last change: Mon Jun 30 13:15:28 2014 via cibadmin on node1
/ u8 n+ f7 Z' k1 W$ l! VStack: classic openais (with plugin)
: B& D5 X" [( L4 d/ w/ MCurrent DC: node2 - partition with quorum% ^2 N A2 K5 a( m% [4 m
Version: 1.1.10-14.el6_5.3-368c726+ Y# D9 _. g( ~3 d6 o! }4 D
3 Nodes configured, 3 expected votes5 M& {0 S5 k l ?
1 Resources configured
7 o. L8 W+ z* }5 v; t1 S! t3 N/ D" F8 E. h4 ?
9 x: f. |# \; O8 R- i
Online: [ node1 node2 node3 ]
- X0 n# I: p. u
1 ~+ p: s, v9 L) E- f4 \' _ MaxScale (lsb:maxscale): Started node1
5 a' i2 W( ^, h- L3 T8 l8 Y! jThe 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?. K+ |/ z- {; l
# mysql -h $MAXSCALE_IP -P 4006 -utest -p test
" b9 Q. A0 c+ p+ j0 Y% ^3 w9 pWhat is the $MAXSCALE_IP then? Let’s Follow the last step ...) V& N8 r) R4 ]$ L) W5 ^
Step 7 - Add a Virtual IP (VIP) to the cluster& d, f+ {( y7 ]% Q
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.
7 f# |% q( ^2 h' EThe 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:
' u3 L0 q$ O1 S9 V) N[root@node2 ~]# crm configure primitive maxscale_vip ocf:heartbeat:IPaddr2 params ip=192.168.122.125 op monitor interval=10s( l) L7 [- y# l6 `5 W- V
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’.$ ?0 x! V7 {4 ?5 n6 M+ r" Q! v4 J
[root@node2 ~]# crm configure group maxscale_service maxscale_vip MaxScale$ E4 T% g3 G5 s8 @4 Y# S3 W. a% _
Here is the final configuration:$ ^' s+ x& S! F! \' w
[root@node3 ~]# crm configure show$ j6 T( p6 R2 y8 x j2 V/ L9 D
node node1- x7 _+ Y9 h# b9 t$ I$ f
node node23 m; B* k1 H) g1 j3 B7 F% F# U
node node3
: e. j- T" D& U" x* Tprimitive MaxScale lsb:maxscale \8 d/ f: o2 f- J- ~! e7 ]
op monitor interval=15s timeout=10s \0 _# H1 O0 J" M+ m7 q9 R( ~; }
op start interval=0 timeout=15s \
. T4 h @8 f& Z3 V( K0 l op stop interval=0 timeout=30s* k. ?, i# b8 X T, s' \2 l+ x
primitive maxscale_vip IPaddr2 \9 J& Q( s& `7 z4 ?3 {* |# T
params ip=192.168.122.125 \- V0 o+ g' u6 y! p' a" Z
op monitor interval=10s# _8 Z& N ^5 w
group maxscale_service maxscale_vip MaxScale \* a. ~4 V% v! K) z, V1 {+ r
meta target-role=Started) r& Y& B; k7 L# a% P
property cib-bootstrap-options: \
* I+ p8 M& t5 p0 w; X x dc-version=1.1.10-14.el6_5.3-368c726 \
/ N, k( u- A, V% Y/ m$ v8 [ cluster-infrastructure="classic openais (with plugin)" \. c7 @ l4 ], P$ S
expected-quorum-votes=3 \2 w9 }9 g& c2 T
stonith-enabled=false \
8 m: A- @! k. B' q3 E! d/ m no-quorum-policy=ignore \: K( g7 D e7 @. {( ?
placement-strategy=balanced \* B/ u2 W3 l2 J0 Z: x
last-lrm-refresh=1404125486
% c5 d# v d/ c2 l1 F7 @2 MCheck the resource status:
. b2 K7 n+ z7 Y5 y) y8 I[root@node1 ~]# crm status Y& s7 R1 J. l. t- p3 f$ S
Last updated: Mon Jun 30 13:51:29 2014
. L* b( j. m3 O# W$ xLast change: Mon Jun 30 13:51:27 2014 via crmd on node1* d+ F$ }+ b7 }) N' u
Stack: classic openais (with plugin)
( Y4 b N' W3 E: T/ j/ N3 LCurrent DC: node2 - partition with quorum9 l: P2 j2 T% C' A8 m0 ]' w' `% s" ]
Version: 1.1.10-14.el6_5.3-368c726
8 e( Q3 h% Y$ v7 A% B. z! z6 l3 Nodes configured, 3 expected votes) a$ T! u% m9 P: r# v/ I
2 Resources configured
; x/ C/ a+ }# V- r: k1 y9 [6 E. T- w8 t( Z0 w8 @9 ]
Online: [ node1 node2 node3 ]
1 J( k% r7 i' M6 }8 F: m; R
* c7 { A( h. X6 o, \" S0 H Resource Group: maxscale_service
3 o5 G0 ~. y0 R, s maxscale_vip (ocf::heartbeat:IPaddr2): Started node2 9 o$ b: I, t" p- z
MaxScale (lsb:maxscale): Started node2
) g" S6 F2 e5 p; H7 L8 s/ }With both resources on node2, now MaxScale service will be reachable via the configured VIP address 192.168.122.125:
) S& b8 C+ ?5 Y1 Q+ y1 W/ Y# mysql -h 192.168.122.125 -P 4006 -utest -p test# o; U4 k: Y" P& \+ ~& }4 c8 ]" @
Please note our three Linux boxes setup require now four IP addresses: one for each node plus the moving IP address assigned to MaxScale& D) c2 C: [3 l) G, F" d* k
Summary
5 N8 b; g# P& H+ z( dThe goal of this post was to present a quick HA solution for a running MaxScale setup, using a widely adopted open-source clustering solution.% o) [- q. T3 W$ ?- Z5 w* `
Even 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.. E% X9 V! Q4 H: @- h9 F
The reader might fin the LSB script tutorials interesting too, just enabling another application to the HA side, |
|