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

How to make MaxScale High Available with Corosync/Pacemaker

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2017-12-29 13:04:38 | 显示全部楼层 |阅读模式
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.+ {$ @! v. U$ u2 F' a3 N8 M& N
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.
; V; A1 R% C) w# x; b! kIn 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.( Q+ e2 m; W4 O. f* |
We make the following assumptions here:* k2 {) U- e7 Q' J$ Q( K
The solution is a quick setup example that may not be suited for all production environments.! Z- c$ \3 x/ U  l/ Q# S' o0 g/ H
Pacemaker/Corosync and crmsh command line tools usage is known at a basic level
% {/ F$ i6 e* @' b0 {A Virtual IP is set providing the access to the MaxScale process9 `  i% Y  l8 z. _
MaxScale is already configured and working with a MariaDB/MySQL replication setup or MariaDB Galera Cluster( L# J" _- I2 ?/ h; u% \" W
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." z. L, T; ~. a$ v. S
Step 1 - Clustering Software installation
; b/ p! F' f0 ~8 Q$ `On each cluster node do the following operations:9 \2 O4 h7 B# k# v
Let’s start enabling  a new repo1 `  [" q9 L3 ]% M  `  `
# vi /etc/yum.repos.d/ha-clustering.repo
# C% @# |1 Y# p2 Uand add the following lines to the file* h, p) m8 j. _! E$ e' K: Z
[haclustering]
, y, |: x* C! u( ~0 ^8 }name=HA Clustering3 t4 ~, e" I& r; l3 j9 E2 v" n

; b% H! x6 j+ J9 W5 F( ybaseurl=http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/6 [9 T) e, L9 ?: o6 S$ Z& Y$ c

2 Z9 R3 w3 M: t$ Penabled=1
  I' w! y8 j" W+ \( W* e" w0 p0 d0 d; ?7 @5 v: G* E
gpgcheck=03 D/ x/ x1 T, T  F1 {( u
Now install the software.
/ `' B5 D' |4 z, O( J2 }4 W# yum install pacemaker corosync crmsh5 N+ q8 I5 @$ i
Please note the packages versions used in this setup are:
+ N* R! T  ?% B, J# G. Npacemaker-1.1.10-14.el6_5.3.x86_64; V- J, f0 [2 x4 m/ l  L
corosync-1.4.5-2.4.x86_64& ~4 l1 m& a* ?7 f: U" P2 Z
crmsh-2.0+git46-1.1.x86_64/ i6 a8 g" A' a" j3 H. }3 k
Step 2 - Configuring  the system' g) m6 u2 G$ y% c
Let’s begin assigning the hostname to each node:  e+ Y3 U1 G; D3 [
The node names are: node1,node,node3( n4 W% J5 t/ ^* O+ s2 k( m2 h( D( o
# hostname node14 d. b! K; \+ s# ~4 R/ n( Y0 [; Q
...- d% C8 f/ E' m2 ^. E6 l
# hostname nodeN
' E: g% R; o/ a: n: l4 g# F" M3 z1 fand write entries in /etc/hosts:$ P1 f" n/ n2 K$ @) c7 u
For each node add the server names and current-node, that is as an alias for the current server.
8 p( o( {2 g1 v' {8 ]" p/ Y# vi /etc/hosts
* [( d8 P1 E: y3 }( ]! c' f10.74.14.39     node1( D7 |1 H4 Y9 ]7 @
10.228.103.72   node2
& E2 N% y  p/ b7 D7 Y6 }1 R10.35.15.26     node3 current-node     ...
% g- h$ D! v8 i0 K4 k- ?# vi /etc/hosts$ D( U5 b  X* d+ S
10.74.14.39     node1 current-node
/ Y8 @/ _% ^6 j" B/ {# K# T1 R10.228.103.72   node2
! B4 ]2 Y4 t+ i8 i4 q. m% H10.35.15.26     node3
1 w9 Q' V( X5 s5 ?* L& W; c7 i" nPrepare authkey for optional cryptographic use:
; x* W1 h9 K7 G* sOn one of the nodes, say node2 run the corosync-keygen utility and follow the instructions.: v. m' p  A. l% r. ?3 D7 x0 [& h
[root@node2 ~]# corosync-keygen
  P& c! B+ S# g0 K: \& A" J
) F# K. D( r, r8 G+ c: ^: V* o) yCorosync Cluster Engine Authentication key generator.
' P2 u& ]' k* a6 V) Q4 H1 X( o0 z- n       Gathering 1024 bits for key from /dev/random." I2 ^. o* b* ?" i' `8 F
       Press keys on your keyboard to generate entropy.! L% i$ E, F) m  ^( R' W& V
After completion the key will be found in /etc/corosync/authkey.
3 i7 i4 n4 b9 O& VNow let’s create the corosync configuration file:
6 J# d6 u2 ?9 V- n' z& i; E9 K[root@node2 ~]# vi /etc/corosync/corosync.conf/ ^% d/ Q' H; k/ v
Add the following content to the file:
! `& M& a( T- O5 w) c& z# Please read the corosync.conf.5 manual page$ p: [) c+ e, k( _; \
compatibility: whitetank
; V+ |2 y4 k$ V5 y" H2 W- s) {  @8 M3 [5 l0 J
totem {4 ]. t( @/ N  a
        version: 2' B/ h- I( u8 x: g0 z
        secauth: off9 {7 @; D0 e" I. D" z, m' Z
        interface {1 _% H) v; ]1 @) P: l' E
                member {; e+ a$ L8 Y* N: J
                        memberaddr: node15 F: r# N1 z2 y; F
                }
4 j: {& D/ Q( {( }                member {: U  V, i; N, Y4 ]+ X( `2 x$ m( D/ B
                        memberaddr: node20 v5 c. J0 w  ~
                }8 k$ G5 O" o+ k* L3 [% C* H  c
                member {
) y1 l8 s" e0 }5 J: W                        memberaddr: node3
  I6 {4 b! w1 J+ u                }$ Q  v7 Y8 ^5 ]. L
             ringnumber: 0
( S8 c* x' M  U& b4 a7 x0 q                 bindnetaddr: current-node& l, O! M% j8 D9 }
                 mcastport: 5405" {$ @  G3 G2 ^6 X7 ]8 s+ {0 D" _
                 ttl: 1$ e* ~( o( {$ X$ M3 \6 c
        }
: T5 v4 c! O$ a        transport: udpu
6 O' n; ^1 G9 v  W8 x" ^2 i9 d}2 X) x+ C. v9 {: z5 z* ^* F
. H# L0 P) R  s1 w  F, I$ ]8 b- n
logging {
, V/ g* G" O, F* W        fileline: off
! B/ g. M2 A( Z0 k+ F8 p  L        to_logfile: yes8 P$ z' Z3 V5 z
        to_syslog: yes
* A# O' z0 C( @& Q( E! U3 o3 z+ v        logfile: /var/log/cluster/corosync.log
% U; r/ A4 m4 {8 n6 m& s8 s3 _- u        debug: off# u. U1 h6 @2 Q7 L7 K; a' E* o
        timestamp: on0 f; u$ J3 T0 F
        logger_subsys {
8 G, I) x1 f0 b2 V                subsys: AMF9 v* Q! g! t7 G+ {4 ~9 [
                debug: off' I5 I9 R5 l* p9 P% t! b

" X' S" B1 @/ x2 J; F0 {        }( x. M1 ~: U. W$ `; _
}0 W) A$ b9 F1 J

. h; z/ ^' q; z# this will start Pacemaker processes3 V. ~% B; A/ A5 Z' ?' V
service {
/ C+ q3 ~" C( k7 aver: 02 |* d% l5 z5 k5 ?, l; r( {, i
name: pacemaker
7 g- x% r2 v, C3 ^: P; B}# |. y' u4 }8 B+ d; a- @
A few notes here:2 S& a" r' o( J8 _6 q3 T
Unicast UDP is used  N0 K0 u% X/ s) N# `
bindnetaddr for Corosync process is “current-node”, that has the right value on each node due to the alias added in /etc/hosts above! C  u# |; H6 x
Pacemaker processes are started by the Sorosync daemon, so there is no need to launch it via /etc/init.d/pacemaker start7 O' I' D! d; [' a$ O
We can now copy configuration files and auth key on each of the other nodes:
* P+ B) u1 B: c9 L: C6 ^; n[root@node2 ~]# scp /etc/corosync/*  root@node1:/etc/corosync/
, {: ]9 F5 o: X" t9 h0 c...
# \9 u# Y5 I6 ^[root@node2 ~]# scp /etc/corosync/*  root@nodeN:/etc/corosync/( j4 u7 I( ~& L! M& i
Step 3 - Start the Cluster) @  v" B. a6 f, r, e& `
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.
7 A) ^' U' m& X; t$ KFor a quick start just disable iptables on each nodes:3 E2 O$ L# D, Z. L
[root@node2 ~]# service iptables stop+ ~! V/ W+ x5 I' ^# e8 I% a: ]

' q0 J) W( Y/ z) S[root@nodeN ~]# service iptables stop+ `$ h, z5 L* M) j  k
Let’s start Corosync on each node:
9 k; s& J5 ^6 j4 K. X4 i1 M[root@node2 ~] #/etc/init.d/corosync start
* T; L+ \; \' z3 Q& ^
! D: Q( c$ n1 ][root@nodeN ~] #/etc/init.d/corosync start
0 _, W( ?  H3 @4 r6 g2 n) u  q. Uand check if the corosync daemon is successfully bound to port 5405:& c% c4 H" W) Z/ F) k$ Z
[root@node2 ~] #netstat -na | grep 5405
3 `2 Q) r8 [+ Q" o1 _% L6 r3 P* K* n& Z+ L
udp        0      0 10.228.103.72:5405        0.0.0.0:*: K% n; m3 e/ p" \: Z
Check also if other nodes are reachable with nc utility and option UDP (-u):
7 }6 U: j* x5 |' F- _  N% |[root@node2 ~] #echo "check ..."  | nc -u node1 5405
8 [' U# O5 V& i: Z/ h[root@node2 ~] #echo "check ..."  | nc -u node3 5405
3 d( y, R  L( b! `9 M# _9 s
% n8 [+ x8 C" y' F* r[root@node1 ~] #echo "check ..."  | nc -u node2 5405: z( H, z( N2 P+ b; x/ w6 }
[root@node1 ~] #echo "check ..."  | nc -u node3 54054 ?& ]* l9 B7 @' }; {- \0 y
If the following message is displayed:
; ~2 g! Z2 P. C9 G/ Mnc: Write error: Connection refused
* ^$ m6 d7 v- n8 N+ W9 pthere is an issue with communication between the nodes, this is most likely to be an issue with the firewall configuration on your nodes.+ }1 K" t( N/ L& I8 Q) F
Please check and resolve issues with your firewall configuration.8 V' k( e8 S4 u$ T
We can check the cluster status, from any node, with this command:" P; u, g  I/ D7 c6 x
[root@node3 ~]# crm status9 r0 W; w% ?$ T9 E4 k
After a while the output will look like:' p7 |  |& u' `: h+ S* r1 _. T* r
[root@node3 ~]# crm status9 ~" j- u! F& h" [! u. l. \
Last updated: Mon Jun 30 12:47:53 20148 Q; F6 G' U5 J4 B) {
Last change: Mon Jun 30 12:47:39 2014 via crmd on node2
: a: W  a- l/ _# X: I$ }: }, d. oStack: classic openais (with plugin)8 J) ^, h# V1 C9 \! N
Current DC: node2 - partition with quorum! K3 ^: w* T, z6 B2 u3 `0 A3 K
Version: 1.1.10-14.el6_5.3-368c726
8 t% e+ P' L+ d/ ^$ P3 Nodes configured, 3 expected votes
  t7 Y& ~( G( I# x2 H2 H0 Resources configured
( g8 N$ a. W- g0 m# x* V5 l! M* W( D* V' B: s  P* f4 U

6 D0 @; M: M0 |  ~' xOnline: [ node1 node2 node3 ]  N+ v, s3 @/ ?/ ?5 `' d
The Cluster has been started successfully, that’s the first achievement so far!
' r% m( n3 X/ R& q( y/ x2 ~Please note, in the basic setup we will disable the following properties:' G5 m' ~- T: q
stonith! P2 Z+ s( Q$ Q! h" M7 c, H9 H' q
quorum policy0 K2 [" U; w! Y# _
[root@node3 ~]# crm configure property 'stonith-enabled'='false': U- {; K: k. }" H+ p
[root@node3 ~]# crm configure property 'no-quorum-policy'='ignore'
2 l, Y: {1 Z% U: N8 q" HAfter these commands the configuration is automatically updated on every node and we want to check it from another node, say node1
1 f) O6 u4 ]4 }; E. G$ ^! H1 y' Q[root@node1 ~]# crm configure show
& I% `, o1 a7 j9 C9 @0 Y2 R
/ X6 @2 q$ S; u4 G8 i4 \node node1; L- F- P" [8 _, C
node node2
; z) P# V: k  q; enode node39 v$ R  ^. y' M# k& p& ?, h
property cib-bootstrap-options: \
1 W6 x7 E6 ]. t4 g& ^        dc-version=1.1.10-14.el6_5.3-368c726 \
  `! A  R  e/ O  a- D        cluster-infrastructure="classic openais (with plugin)" \) N+ k8 n' Z  J, F- t9 d. B
        expected-quorum-votes=3 \# x+ J% c  U& Z, X7 c' `0 _
        stonith-enabled=false \
6 n6 y9 I5 r$ J0 N  Q6 n% v5 W/ d        no-quorum-policy=ignore \
2 V' [1 d1 V6 c. D9 s, P' z4 B; h        placement-strategy=balanced \
) g: d2 n( Y0 j        default-resource-stickiness=infinity5 Q1 T9 D' \# `4 O: \
Well done, the Corosync / Pacemaker cluster is now ready to manage resources, in the next steps we’ll add MaxScale.3 X; b8 T- I+ y" Q' y: I
Step 4 - Check MaxScale init script
& p( T- g5 C' `' n" Y# l# `. bThe new MaxScale /etc/init.d./maxscale script allows to start/stop/restart and monitor MaxScale process running in the system.
( c$ X6 g+ I2 p# dThe script found in the RPM package is already working with the following path: /usr/local/skysql/maxscale; d1 y+ b$ B, N6 s1 [5 A' R
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_PATH6 b% j3 h- o) {* r0 |2 J4 y3 \! r; k
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., ~' m/ A; p- f
Following commands should be issued on each node, assuring the application could run and managed:$ q( M# a$ x/ ^- ^) `3 W
[root@node1 ~]# /etc/init.d/maxscale % y( d# Q9 k9 W' W. k
Usage: /etc/init.d/maxscale {start|stop|status|restart|condrestart|reload}
2 T! J( P8 l- W9 y! ~0 r$ V) C# E; pStart
9 S# v9 M1 c0 z# [6 J9 z1 _$ n[root@node1 ~]# /etc/init.d/maxscale start  }0 \; y0 k+ l
Starting MaxScale: maxscale (pid 25892) is running...      [  OK  ]6 h0 w/ t6 W( _: y3 ^6 h3 Q: T5 v
Start again" |1 ^7 V/ w! ^$ s( a& B
[root@node1 ~]# /etc/init.d/maxscale start
' h$ D3 u5 B5 K3 ^Starting MaxScale:  found maxscale (pid  25892) is running.[  OK  ]3 Y! i. L5 p7 |6 t) M! ]; Y
Stop5 p- `+ [7 E% l
[root@node1 ~]# /etc/init.d/maxscale stop
; _( V- f7 ~6 S7 x- q# D6 y  qStopping MaxScale:                                         [  OK  ]6 q0 K. Q9 O; e' r
Stop again6 N9 J- O$ g- }" u$ X# @
[root@node1 ~]# /etc/init.d/maxscale stop! y# P. X/ y; S3 H  @$ }; I
Stopping MaxScale:                                         [FAILED]
. P; `/ W* f7 z5 E  y0 L5 sStatus (MaxScale not running)8 x9 A, N' `) ?0 S7 }; y$ k
[root@node1 ~]# /etc/init.d/maxscale status
$ F- r4 I# I6 r) L; S8 |% r5 MMaxScale is stopped                                        [FAILED]: \0 C. ]3 {$ ~: i- _. s
Status (MaxScale is running)9 d% `6 E( _8 }& E5 y
[root@node1 ~]# /etc/init.d/maxscale status
' q: P, ^: T9 k' _1 W& x& w/ iChecking MaxScale status: MaxScale (pid  25953) is running.[  OK  ]3 G9 V: S1 O& t( w$ x3 A
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.8 \  j. ~5 g" u4 v' B, F
Step 5 - Configure MaxScale as a cluster resource# G; j+ R1 Q  l9 v2 C2 b( N
We are assuming here MaxScale could run on each node with the same configuration file.! |0 q9 L: C3 u" S$ Q/ H5 Z' b
[root@node2 ~]# crm configure primitive MaxScale lsb:maxscale \
: j* L$ v/ @7 K, d$ ]op monitor interval=”10s” timeout=”15s” \% j% z" [  J0 |( P# t  D( _
op start interval=”0” timeout=”15s” \
" J- E$ g* U  w$ o8 D5 A7 oop stop interval=”0” timeout=”30s”+ _; T5 I6 j$ Q+ Z
The command above has configured MaxScale as a LSB resource, note “lsb:maxscale”6 k+ S1 F8 ]$ f3 ?
In Pacemaker there are two different ways for managing applications:# k* |3 s- {% f8 z
Resource Agents (VIP, MySQL, Filesystem etc)
3 x3 Q, J6 T! [: A! [$ vLSB scripts for applications that don’t require the complexity of a resource agent and custom applications, in general.4 u. J4 Z7 {( h2 N6 I& \4 ]
MaxScale itself manages the backend servers we had configured in etc/MaxScale.cnf service sections such as:6 J$ ~1 E) x1 V
[RW Split Router]
( a" N) h5 C2 Etype=service6 z2 J$ D& i: k: X& I' `, L9 }
router=readwritesplit
  O/ }( O6 y5 b4 _5 iservers=server1,server2,server3,server4,server5,server6,server7
; Y% d: y0 \6 zuser=maxuser2 x) n5 I6 X7 B9 B' u: O9 ~* j/ ~
passwd=maxpwd& P2 w) R! g# U* O3 B% y3 B
So we only want Pacemaker to manage the MaxScale process and the LSB approach is well suitable here.
/ E! N# d( \. SIf everything is fine we should see the resource running:
. R$ [% A/ ?: S" ]0 E[root@node2 ~]# crm status
5 L8 c& x2 m$ ?Last updated: Mon Jun 30 13:15:34 2014
& t2 {+ x! I, _4 u$ t' B% PLast change: Mon Jun 30 13:15:28 2014 via cibadmin on node2
9 L; M& J( f+ p0 x# d( Z" L0 G" ^9 ]Stack: classic openais (with plugin)
3 Y; `, H2 u% f, K2 r( RCurrent DC: node2 - partition with quorum
$ G; M7 G+ C. H2 \8 g, A9 ~7 v" DVersion: 1.1.10-14.el6_5.3-368c726+ ?3 G& x% i4 O9 w1 b; |* E1 k
3 Nodes configured, 3 expected votes* ~; V  e7 S. w3 a5 P
1 Resources configured" F; |  U& f' D5 u
) i/ Q8 W% Q# \% ~1 F* L4 G; q- R) N
Online: [ node1 node2 node3 ]
2 @0 d6 Y/ q* X- T/ O8 y/ p
3 b+ }2 z' M, {. sMaxScale        (lsb:maxscale):        Started node1
: e" |- `, U& w3 ?+ ?* pWell done, another achievement here!$ V9 |. ~7 x/ I! C' {$ i
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:
) z. i' \( r# C# O3 b; x7 O: o* B# z# chkconfig maxscale off
* n  U& V1 Y# y# a6 c# chkconfig corosync on
9 s  j& w9 w6 DStep 6 - Does the HA software work? Let’s see a resource restarted after a failure:
8 I/ t6 V! R0 MMaxScale application is now managed by the HA clustering software but what does it mean?
3 Z" E6 \5 o: W5 v+ R% kWill the application be restarted in case of any failure? It should be!
; U- ]; V5 O* s: J) AWe try now to kill the MaxScale process and see what will happen ...
8 C, K3 E0 k' P0 l& G1 W2 H1 BAs we now MaxScale PID could be easily found in $MAXSCALE_HOME/log/maxscale.pid
6 B% |& [& U0 j/ M# d, {In this example the PID is 26114, and we kill the process with brute force:. W! p1 V+ F: `- }1 b+ t
[root@node2 ~]# kill -9 26114
/ {+ Q8 B$ Y$ K2 r
- i' U% Z. _$ }+ q9 b( c7 r[root@node2 ~]# crm status( ?' ^' ^7 ?9 N4 j8 L# W7 t
Last updated: Mon Jun 30 13:16:11 2014$ _& u2 K1 |* f  T
Last change: Mon Jun 30 13:15:28 2014 via cibadmin on node2
1 F1 S  l% j: Y: y# TStack: classic openais (with plugin)8 U6 t/ a* G5 C
Current DC: node2 - partition with quorum0 N( p0 P  w; N) `5 y
Version: 1.1.10-14.el6_5.3-368c726
5 @: D, D% r! |( ~) |0 Q5 Z3 Nodes configured, 3 expected votes
! B1 m" X2 A, X7 f  T1 Resources configured
" F' _0 ^2 Z  T# S! H# e! g8 V" F0 L8 ]6 `% H4 L8 X
Online: [ node1 node2 node3 ]
! P( `8 d3 S* e; D! f" u* T6 J" b1 n: H9 t
Failed actions:
4 Q  D: J- ?$ l7 n6 B2 A3 q; g* N    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
, n! g. c' y8 b' B$ e# DNote the MaxScale_monitor failed action above and ... after a few seconds it will be started again:! m9 Y# I' n0 R( G  d0 O$ u- W
[root@node2 ~]# crm status
: O8 b- W! h6 o" T1 |! U! ILast updated: Mon Jun 30 13:16:22 2014
; W! {4 m+ O% s! d( `  Z! ^- ULast change: Mon Jun 30 13:15:28 2014 via cibadmin on node1( @, q& T6 {# k/ i8 E$ {
Stack: classic openais (with plugin)
- `. V& _+ f( VCurrent DC: node2 - partition with quorum0 b: m' b# X6 a$ r, R1 u
Version: 1.1.10-14.el6_5.3-368c726$ g; W3 z- U" a( W, M
3 Nodes configured, 3 expected votes- Q& Y7 B3 a6 l2 c2 o
1 Resources configured
5 Z7 g! ^# z  v/ }; z% a
) i0 N2 y# F; W# F% a6 p0 l
9 G; U( r: i% }* vOnline: [ node1 node2 node3 ]
& ?7 e% x) R& k2 J/ v. x$ s1 l; R  `/ ~0 r, \1 d3 _4 U7 l
MaxScale        (lsb:maxscale):        Started node1 : I9 }, S, D+ Y$ Z/ \' l" a
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?
  B! i* h* X+ y5 V, w- S5 j# mysql -h $MAXSCALE_IP -P 4006 -utest -p test* M" s; o% N  p! D0 J8 ]% u
What is the $MAXSCALE_IP then? Let’s Follow the last step ...
( C" V: F. L; M8 v# A- ]Step 7 - Add a Virtual IP (VIP) to the cluster" r. F- F7 f2 _7 O( t, n
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.
& E0 t' b; P1 p# G' XThe 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:
0 h/ P0 g3 |+ G* z0 p[root@node2 ~]# crm configure primitive maxscale_vip ocf:heartbeat:IPaddr2 params ip=192.168.122.125 op monitor interval=10s+ i- C2 ^2 R$ C/ }
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’.( d  V0 {+ u& p0 r* B
[root@node2 ~]# crm configure group maxscale_service maxscale_vip MaxScale
* E; W. {8 t& G3 Y  N, y; ]Here is the final configuration:
- w" B# h) x% y[root@node3 ~]# crm configure show
9 s: _6 j/ }2 \* j, y& v' p9 Lnode node1
! }2 j8 v  P2 M+ {: onode node2
- C% t3 T5 h; }9 `. ~0 C0 m+ v; t4 knode node3% z+ G( V) f. \+ i1 m" n
primitive MaxScale lsb:maxscale \, m, p' V! {- l9 \  v
        op monitor interval=15s timeout=10s \( k/ P! v5 \( c  d% Q
        op start interval=0 timeout=15s \
0 Y# Z; ^$ O! E, \* Z, [2 C        op stop interval=0 timeout=30s
/ J; w/ d' `+ x0 B. Wprimitive maxscale_vip IPaddr2 \/ l" s) ~, \0 U
        params ip=192.168.122.125 \! a  B3 W4 y  L' @
        op monitor interval=10s( K; j& ^! J9 p
group maxscale_service maxscale_vip MaxScale \! F+ D+ I) E# a4 E2 U# I
        meta target-role=Started
  u3 Z0 X/ n0 B1 eproperty cib-bootstrap-options: \5 }$ Z: t% A! C( w" F2 F7 o
        dc-version=1.1.10-14.el6_5.3-368c726 \
: ]0 m5 ]: I9 F8 f6 N        cluster-infrastructure="classic openais (with plugin)" \! s$ i  Q8 a+ K) E$ Q! m
        expected-quorum-votes=3 \5 X4 g0 \& w9 e* C
        stonith-enabled=false \
" ~! {$ I! V, X/ Q7 L' Y5 _# `2 R        no-quorum-policy=ignore \
' X/ B' I% a/ T  B) I, k% [        placement-strategy=balanced \
0 I& a" O) ^3 ?        last-lrm-refresh=1404125486
2 J: A3 z2 s3 A6 y( F5 X0 u  |% aCheck the resource status:! ]7 Y1 K7 E3 E6 {7 r! D' T
[root@node1 ~]# crm status, S9 \+ h  y$ Y6 B$ C. [
Last updated: Mon Jun 30 13:51:29 2014* ?. I' ~) ], r# R2 z# l
Last change: Mon Jun 30 13:51:27 2014 via crmd on node1; c2 S3 q. n( I! t2 @% K
Stack: classic openais (with plugin)* K  f; x+ E7 A* G5 ?  R! ~$ p
Current DC: node2 - partition with quorum% S3 @3 m1 Q- J. Y' c% X- r
Version: 1.1.10-14.el6_5.3-368c726- D& g0 q" [. ^5 s2 Q: H) X# u% M( }' Y
3 Nodes configured, 3 expected votes$ o; E* ~% h  O7 P0 f0 B1 y
2 Resources configured
$ V5 M5 C9 B5 Q7 o6 S, ^; B# ~
: N+ b) s+ a3 {: JOnline: [ node1 node2 node3 ]! _0 f- L4 f6 y/ B$ d, _- J; c& P
$ W3 z8 s4 T, I0 \2 E' ]
Resource Group: maxscale_service
$ n/ K* w. F& _* ?1 K  d8 x: y     maxscale_vip        (ocf::heartbeat:IPaddr2):        Started node2 0 v' ]6 s# q% S
     MaxScale        (lsb:maxscale):        Started node2 9 Z- p$ o! [9 K  C' m& S" T
With both resources on node2, now MaxScale service will be reachable via the configured VIP address 192.168.122.125:
1 L5 r9 I! B5 L( w0 v. T# mysql -h 192.168.122.125 -P 4006 -utest -p test+ m) P4 b% D; \  N; D8 V
Please note our three Linux boxes setup require now four IP addresses: one for each node plus the moving IP address assigned to MaxScale
$ p6 x+ U: S0 X& M3 I+ S- kSummary
" n! M. b2 t0 C+ uThe goal of this post was to present a quick HA solution for a running MaxScale setup, using a widely adopted open-source clustering solution.
% J) H  \/ w9 u" k! w! C$ X9 aEven 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.
$ s% K8 {( Y. q" [The reader might fin the LSB script tutorials interesting too, just enabling another application to the HA side,
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 00:59 , Processed in 0.020996 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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