易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 4116|回复: 0
收起左侧

How to make MaxScale High Available with Corosync/Pacemaker

[复制链接]
发表于 2017-12-29 13:04:38 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?开始注册

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.3 V. f" L0 T* b  e# t
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.
# s' }7 v3 e7 S' v( FIn 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.* a/ Y- P8 x# ~7 o  t  M3 J
We make the following assumptions here:7 |% f) G7 |) v- x' |% a
The solution is a quick setup example that may not be suited for all production environments.7 H" o( `9 M" z) G
Pacemaker/Corosync and crmsh command line tools usage is known at a basic level
4 w' x# U; s; Q$ Z' jA Virtual IP is set providing the access to the MaxScale process
' K  x* ~3 E7 D3 hMaxScale is already configured and working with a MariaDB/MySQL replication setup or MariaDB Galera Cluster( W, X0 a- ]( [" z
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.
6 {- G9 p) n- |/ `Step 1 - Clustering Software installation3 O: ?5 u. I  Y  J: v7 Q
On each cluster node do the following operations:
* f/ r5 t5 Q; H: I. L8 `; W% z3 O5 e  }Let’s start enabling  a new repo
& n6 R* J# \$ s  k& W1 `* Q0 l# vi /etc/yum.repos.d/ha-clustering.repo
/ [' D4 ?- Z" [0 M) D2 B! yand add the following lines to the file
( V# q# Z4 |) {9 t% d[haclustering]4 h: H1 v7 X, Z0 J. d) L* c* g  [
name=HA Clustering
8 W* m" \; q1 Y4 t3 @: T% D
& ~! _. z4 b! y, nbaseurl=http://download.opensuse.org/repositories/network:/ha-clustering:/Stable/CentOS_CentOS-6/) c4 ^* ~1 _# _5 Y5 [1 v; m
/ g2 {( C6 u+ ^2 `) u
enabled=1
, W& _1 i; n3 b3 A3 a5 f6 L; X: ]- W& H, Y, K6 ?# h+ j
gpgcheck=0
9 r/ c- p; X+ A: S: d0 o, MNow install the software.# I+ l' I5 Z- E' a
# yum install pacemaker corosync crmsh
1 q1 l) n; E* Z) lPlease note the packages versions used in this setup are:
3 _/ `4 B$ I) _, |( Ppacemaker-1.1.10-14.el6_5.3.x86_64
6 o- ?8 K( K3 O6 @4 ecorosync-1.4.5-2.4.x86_64
5 ^4 Q: k$ A* Dcrmsh-2.0+git46-1.1.x86_64
! U# `( M& ?2 Q$ eStep 2 - Configuring  the system) E  ]1 E/ N  c: L$ S
Let’s begin assigning the hostname to each node:
. _, Y7 Z/ G  i, @! m1 ~The node names are: node1,node,node3$ E3 ~* A3 }  y3 F  t$ s- f6 D
# hostname node12 _! L" E" v* k9 {
...
9 T8 X3 v9 j/ u4 Y# hostname nodeN9 G: i6 C: L$ R/ s
and write entries in /etc/hosts:
( e; ^1 c/ ]( ]2 _+ wFor each node add the server names and current-node, that is as an alias for the current server.
+ b& K; s; I- t! N) \" }# vi /etc/hosts
) K! L+ S% q: L( `10.74.14.39     node13 Z4 J: O- ^7 X" Y# P1 ]8 p
10.228.103.72   node2- d- k  I. O$ R" r
10.35.15.26     node3 current-node     ...
, X0 L/ m+ |4 E6 b# vi /etc/hosts% Z' n" F9 b7 d2 _# ~3 ^) @
10.74.14.39     node1 current-node
' |* J3 @0 O' d4 c10.228.103.72   node2
. Y% n" Y% X$ M1 v0 p. h10.35.15.26     node3! i: w+ w/ [+ s3 n6 M# D9 N* U) q- A; r
Prepare authkey for optional cryptographic use:- d' O5 H6 S9 R" y6 D* X
On one of the nodes, say node2 run the corosync-keygen utility and follow the instructions.
6 B' F$ P1 Y( u! b' D) m$ {4 F: \[root@node2 ~]# corosync-keygen8 i; d1 s& R4 _9 }
  f4 M6 d* G, z
Corosync Cluster Engine Authentication key generator.3 f9 O2 s( [% s+ p
       Gathering 1024 bits for key from /dev/random.# t' {* P: J% O6 `# u" ~1 @3 J$ G
       Press keys on your keyboard to generate entropy./ a9 z! _; C) ?: ^
After completion the key will be found in /etc/corosync/authkey.
( F; B. S0 I9 h& y$ yNow let’s create the corosync configuration file:
( ]" s7 A: h2 R& s[root@node2 ~]# vi /etc/corosync/corosync.conf
* X& z* U) e2 g/ ?, nAdd the following content to the file:' ]* S- A: v- H3 a* `
# Please read the corosync.conf.5 manual page) W# O4 V1 }/ Z7 P1 D
compatibility: whitetank
5 a" c9 U" b1 ~" n" I: a5 \- C$ H2 s. S4 Y( @4 D4 o! i
totem {4 D, x/ `" p0 J8 M
        version: 2' u" }# q( _  }1 K( Z
        secauth: off/ w8 s  }4 ~. I
        interface {- |$ L3 _4 ^, T9 |- |: S9 a
                member {
$ _3 \; n2 |$ C! x  ?                        memberaddr: node19 i+ Q& ~4 n2 l( ]/ w3 O
                }6 h( U8 t" z( g: t3 O$ d
                member {
8 b+ Z% v- `  q: |                        memberaddr: node27 v* w; }8 p: o/ [
                }2 B# T' u( f+ z
                member {
& j; T! k0 h$ x9 s# Y, _; g                        memberaddr: node3: S; t, p* D1 N7 P/ v& E
                }
0 C/ O! n: ~% `6 [; x$ G             ringnumber: 0+ f. C9 e& |  ~) ]$ R
                 bindnetaddr: current-node
7 _% P/ C2 S; {" j                 mcastport: 5405+ w, K7 R1 C6 C' g' x' j
                 ttl: 1& y; a0 f$ z9 n
        }. R, v% R0 E8 m3 P
        transport: udpu
2 F) o3 H/ o2 o  N& W6 Q* k}) h- y( L8 V2 a/ U- P, f; b
$ }- E: }1 X+ @
logging {6 {( S9 l/ c4 o: F4 a8 m% A
        fileline: off" Z7 n8 n6 ^) U2 c
        to_logfile: yes
& @7 C; ]+ F2 w' M6 o9 u        to_syslog: yes
. e% X$ q; b8 w3 O0 [        logfile: /var/log/cluster/corosync.log7 l* v5 `7 @( w$ y
        debug: off# q6 j/ ~8 I+ V& \
        timestamp: on
5 C: i* f* K: l1 ?% A+ j6 p! U        logger_subsys {3 G1 I0 w9 }' H2 u9 X* x( k
                subsys: AMF
  _% @) y, C1 \: N" [                debug: off
' C8 R( H4 o% h$ g2 Z3 }9 u& E0 s
5 D; ~# k2 y+ k8 l" e& b/ I        }
' ^, v) N- o; y: x0 z4 ^}
2 z7 U) O' a* Y' D6 a# c* Z2 ~1 Z% B6 u8 R, Q  Q# _# l: r5 d! }
# this will start Pacemaker processes
6 c1 K( Q; M$ g5 d2 n9 P3 M0 eservice {& T% `9 O2 s9 B( L* f! N0 C
ver: 0
2 Z4 @0 j/ c6 C9 Pname: pacemaker4 D$ B. M  T4 h4 L1 `+ E$ q' e
}
! S; A8 V0 H3 L3 Z) X4 tA few notes here:1 l/ {% x$ a, T; h
Unicast UDP is used
/ K- y' o8 A, ^* w0 G2 A2 obindnetaddr for Corosync process is “current-node”, that has the right value on each node due to the alias added in /etc/hosts above: g) d; ]7 g# N8 U# Z, M) s5 F
Pacemaker processes are started by the Sorosync daemon, so there is no need to launch it via /etc/init.d/pacemaker start$ u: B0 X  ^+ k! W. T1 r# B
We can now copy configuration files and auth key on each of the other nodes:) Q& T4 f- ~3 e! y5 Z. Y! i% c
[root@node2 ~]# scp /etc/corosync/*  root@node1:/etc/corosync/
4 M5 L  [# T5 ^) Z' X5 Y( A...$ N  e5 G1 F( w* O5 A
[root@node2 ~]# scp /etc/corosync/*  root@nodeN:/etc/corosync/
2 g, U' f7 X+ [/ K6 cStep 3 - Start the Cluster
+ h( V. I# Q; qThe 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., \+ m# a7 L# L
For a quick start just disable iptables on each nodes:$ u; Z' h0 O8 K" k$ ?% Z
[root@node2 ~]# service iptables stop# W- U! }* J0 k
% K2 M" t- g! @: ~1 @$ W5 S& H
[root@nodeN ~]# service iptables stop
9 i" |7 z( }* b+ _3 t# ALet’s start Corosync on each node:
; ]+ U# S1 R# q. e" z7 R$ w4 [[root@node2 ~] #/etc/init.d/corosync start  t' D* U- S0 o
$ O) l& N: b$ G5 O
[root@nodeN ~] #/etc/init.d/corosync start
5 F7 s; g" Q0 X+ |and check if the corosync daemon is successfully bound to port 5405:; L. u! L+ }2 B+ ]- g8 D  J9 t
[root@node2 ~] #netstat -na | grep 54051 u9 |1 B/ a$ U- m+ B: s
9 O) ?6 m" o" L0 Z
udp        0      0 10.228.103.72:5405        0.0.0.0:*/ R7 C* T9 U2 R$ p+ L* B0 [( ~
Check also if other nodes are reachable with nc utility and option UDP (-u):
2 C5 q- F5 k0 ?2 B$ b[root@node2 ~] #echo "check ..."  | nc -u node1 5405
$ R8 g. Y8 b- o$ w[root@node2 ~] #echo "check ..."  | nc -u node3 5405
- \% g* u0 c! R5 f2 F& ?& d( @: h: C+ o3 \. c% J
[root@node1 ~] #echo "check ..."  | nc -u node2 5405
  c' C5 r; ]; ]1 S% @) }[root@node1 ~] #echo "check ..."  | nc -u node3 5405
  L8 q1 B& T7 D5 N0 gIf the following message is displayed:
- v# V6 n7 a( f' jnc: Write error: Connection refused
# m, Z: b0 m9 g0 hthere is an issue with communication between the nodes, this is most likely to be an issue with the firewall configuration on your nodes.5 X4 H: @: Q0 j% [
Please check and resolve issues with your firewall configuration.
+ U& J* z! O& ~We can check the cluster status, from any node, with this command:: N& {+ t0 Z5 A
[root@node3 ~]# crm status" F( j! z1 u  c! u, O+ a
After a while the output will look like:2 x3 J) V5 r6 Y' m
[root@node3 ~]# crm status% ]% s5 S3 F6 V# \5 B* y
Last updated: Mon Jun 30 12:47:53 2014
# {) J; K6 h& V! l' iLast change: Mon Jun 30 12:47:39 2014 via crmd on node2$ L6 Y; Y' y- V& A7 |7 G, B
Stack: classic openais (with plugin)
4 D- R" [2 X2 Y- j2 s+ u0 p- l: u# Y) fCurrent DC: node2 - partition with quorum& @/ a! D' h  T; g: |
Version: 1.1.10-14.el6_5.3-368c726
( ]3 K+ B5 `# i8 V0 l3 n1 I! U3 Nodes configured, 3 expected votes
5 r6 O2 s! e- ?; [) }, A0 Resources configured
4 s' P6 a/ \' _, t' r" P) J) a( f4 ~3 W' j! Z: C" G9 {

6 P  j; t6 D5 GOnline: [ node1 node2 node3 ]2 V5 N7 E) j3 f7 Z
The Cluster has been started successfully, that’s the first achievement so far!# l4 ~& |' `) E# r
Please note, in the basic setup we will disable the following properties:
" S9 p# ^* c+ Q1 b7 lstonith
- E( ~- e; M1 M2 c. p' B. Tquorum policy# ?' d3 c8 ~; x# d
[root@node3 ~]# crm configure property 'stonith-enabled'='false'
; D) A# m. e5 f$ I[root@node3 ~]# crm configure property 'no-quorum-policy'='ignore'
  V8 u: s  c, Q" UAfter these commands the configuration is automatically updated on every node and we want to check it from another node, say node1
5 F8 @# I, u  `5 ^' s2 E& O2 ?6 D. _[root@node1 ~]# crm configure show
+ B+ ~9 u, p  J" q  |% c: T5 V; Y5 U$ M$ N
node node1
, h& P) \- Q+ f$ @& Nnode node26 c, j* D: x; I$ M
node node3
9 q, A0 ~% \/ a8 Hproperty cib-bootstrap-options: \3 C) x8 V% N9 W, @- ?. L
        dc-version=1.1.10-14.el6_5.3-368c726 \
; Q/ G$ o/ X9 N5 S- F5 _' r1 u        cluster-infrastructure="classic openais (with plugin)" \
. s& M( p! R! J  }        expected-quorum-votes=3 \# j5 s2 K& H6 o! l- n( c
        stonith-enabled=false \# d' U1 I$ D& x* A& {
        no-quorum-policy=ignore \, D+ b: ^! T3 i  e5 p2 V. y
        placement-strategy=balanced \
' }9 \! g" H& g" R: _; @        default-resource-stickiness=infinity
- n( H0 B- x; p4 S/ p8 L9 V$ lWell done, the Corosync / Pacemaker cluster is now ready to manage resources, in the next steps we’ll add MaxScale.6 y' ~- G8 d  O& K8 h
Step 4 - Check MaxScale init script. v# {9 s5 a6 n( [
The new MaxScale /etc/init.d./maxscale script allows to start/stop/restart and monitor MaxScale process running in the system.
1 W; P- r8 l1 `% cThe script found in the RPM package is already working with the following path: /usr/local/skysql/maxscale
3 a& y  W$ L1 ?9 V& SIt 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_PATH; o$ n4 D/ ]2 R' J& q
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.! ]+ X$ k; r+ F% |( h
Following commands should be issued on each node, assuring the application could run and managed:8 i+ R3 W! S: E# e& p
[root@node1 ~]# /etc/init.d/maxscale
' U0 ?2 d4 k4 \5 I( s9 I( [% R+ q% ]Usage: /etc/init.d/maxscale {start|stop|status|restart|condrestart|reload}
, S- n8 u7 {6 x/ s1 Y6 D. aStart
- J. T4 q4 G) ?$ A[root@node1 ~]# /etc/init.d/maxscale start5 k% @- ^$ l6 U# D
Starting MaxScale: maxscale (pid 25892) is running...      [  OK  ]
2 P  [) i- _4 }. EStart again& X$ `; s+ @& A6 ?+ n/ A
[root@node1 ~]# /etc/init.d/maxscale start7 \) F$ N$ B6 L
Starting MaxScale:  found maxscale (pid  25892) is running.[  OK  ]. Y$ O' O1 ~) s- \" R7 S
Stop
. J+ I/ F/ `% y% ^[root@node1 ~]# /etc/init.d/maxscale stop& J; O8 I: \$ a( s2 A/ q
Stopping MaxScale:                                         [  OK  ]7 y0 x, E2 x" `) v8 ^7 y. l
Stop again
4 V0 \" ?' _0 z* f[root@node1 ~]# /etc/init.d/maxscale stop
% |+ _( R6 U! a7 U: [3 [4 HStopping MaxScale:                                         [FAILED]
7 q6 N3 l% }, Z2 [Status (MaxScale not running)) O- E0 s1 w2 P( v
[root@node1 ~]# /etc/init.d/maxscale status0 D* ^; t, M; t+ x" k. f0 ?
MaxScale is stopped                                        [FAILED], Y0 U# P4 F& y, ]# ^% G) W6 S
Status (MaxScale is running)
6 T) y1 i7 B3 K. o[root@node1 ~]# /etc/init.d/maxscale status
% H: ]1 f9 }0 sChecking MaxScale status: MaxScale (pid  25953) is running.[  OK  ]
9 z5 q4 f2 R6 H: L' p, e4 jAs 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.& d3 `6 j: Z+ D9 }
Step 5 - Configure MaxScale as a cluster resource
6 f7 A- G+ e- a  lWe are assuming here MaxScale could run on each node with the same configuration file./ [$ q* n( a+ K. T8 W  v
[root@node2 ~]# crm configure primitive MaxScale lsb:maxscale \- _% ?& p& ?( e1 ]% u. [
op monitor interval=”10s” timeout=”15s” \
& o5 o  ~( A4 r: ]op start interval=”0” timeout=”15s” \
4 X' }1 |" p( B( t7 M" }& p: [: Jop stop interval=”0” timeout=”30s”
1 g5 x0 r  u: N1 v  `7 yThe command above has configured MaxScale as a LSB resource, note “lsb:maxscale”
8 _0 t5 L8 t7 z! WIn Pacemaker there are two different ways for managing applications:
: _) p/ \5 v4 o! kResource Agents (VIP, MySQL, Filesystem etc). f( C% D/ Y- X+ E$ x5 y) v, c5 j
LSB scripts for applications that don’t require the complexity of a resource agent and custom applications, in general." W& ]: H8 H# s
MaxScale itself manages the backend servers we had configured in etc/MaxScale.cnf service sections such as:& z; R; p) Y: y; k
[RW Split Router]
. V* O2 g9 @% O$ B" o! q& ytype=service, x  z+ d5 U9 d* Q; j5 H" t
router=readwritesplit
. I9 r+ n& ?+ w: L0 p' x- p3 iservers=server1,server2,server3,server4,server5,server6,server7
2 j/ Q! }0 c8 a3 y- wuser=maxuser$ `; b! p' p& M8 {9 E8 j
passwd=maxpwd
8 \9 j% b6 I+ Y5 o6 nSo we only want Pacemaker to manage the MaxScale process and the LSB approach is well suitable here.$ ]" _9 I2 ^1 i. Y3 R: f. ~3 k, L
If everything is fine we should see the resource running:0 v( E( ~! ]  Q, X
[root@node2 ~]# crm status
2 c: q# @0 \* K$ W& {Last updated: Mon Jun 30 13:15:34 2014
# G# w5 l. Y0 I" pLast change: Mon Jun 30 13:15:28 2014 via cibadmin on node2. p1 Q( a2 Q; f9 |
Stack: classic openais (with plugin)
! }( o" y3 z% cCurrent DC: node2 - partition with quorum
( R. b( m6 p2 F, ?. s. m- \Version: 1.1.10-14.el6_5.3-368c7262 j9 V' E( z) O, n5 h* q& j
3 Nodes configured, 3 expected votes
- S& U) |5 S/ H( o; }' w3 A$ {1 Resources configured& A. y1 X3 ?7 w- b6 r

! J. n4 W& z1 b9 V1 \2 N1 g+ @Online: [ node1 node2 node3 ]1 V& _) C3 ]! e- E/ A; _& \
& y( e" d+ s& u- \& D: b% ]
MaxScale        (lsb:maxscale):        Started node1  I$ X2 g4 K$ F" q! M# T3 i# j4 {' h
Well done, another achievement here!' A- A+ M# `& T5 ^5 x  u
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:' C* T; @0 b7 f: [" P( q
# chkconfig maxscale off8 c6 M! ~# e# G- G; U+ t9 P
# chkconfig corosync on: o- a0 F% G( |; P8 Y7 Q
Step 6 - Does the HA software work? Let’s see a resource restarted after a failure:$ n5 `0 v5 Z. A; u2 _/ J
MaxScale application is now managed by the HA clustering software but what does it mean?
! v8 Z* F3 x( |5 h5 D/ HWill the application be restarted in case of any failure? It should be!
  F5 z" R5 A9 G/ T9 Q+ ^# H( _We try now to kill the MaxScale process and see what will happen ...( |8 d6 z- B0 ~5 n5 r) n4 ]# r
As we now MaxScale PID could be easily found in $MAXSCALE_HOME/log/maxscale.pid! h2 x" G: o. a. E/ R5 L
In this example the PID is 26114, and we kill the process with brute force:
  L- `4 o- f# l: c" |$ Z/ q: x[root@node2 ~]# kill -9 261148 R2 D0 R* t( k# a* @( ]

9 V- T  I9 {1 O3 }9 @% }( H[root@node2 ~]# crm status1 W4 {! y' P! B1 }
Last updated: Mon Jun 30 13:16:11 2014, w8 [% p+ M: c$ ~/ J2 g. c
Last change: Mon Jun 30 13:15:28 2014 via cibadmin on node2. z! f* W, ?6 F( }/ h" Q5 ?' d
Stack: classic openais (with plugin)
3 O8 e) |* b2 v& v  lCurrent DC: node2 - partition with quorum3 R5 p7 D8 O5 F, }3 R" t/ g) r  }
Version: 1.1.10-14.el6_5.3-368c726
3 `, W! U: [, C; Z; t$ k3 Nodes configured, 3 expected votes" n. f! }7 w; _6 o
1 Resources configured
1 I, \4 h% I# F. m  S9 Z
# D/ o( j  H! _1 u  ~Online: [ node1 node2 node3 ]0 ^( V$ D% A! |0 `

, t; M: _+ K+ U) G9 S' r" U$ E. y& ]Failed actions:
  O# T! X' x4 t0 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
4 O- U; E; v$ e8 G7 n/ N: SNote the MaxScale_monitor failed action above and ... after a few seconds it will be started again:
  L+ K+ _- M$ |[root@node2 ~]# crm status$ a# c! y2 u: [& I  |$ T# F
Last updated: Mon Jun 30 13:16:22 2014, _+ {$ J: ^8 C  Q* x' h# O
Last change: Mon Jun 30 13:15:28 2014 via cibadmin on node11 k6 n& a0 X& @* N9 L  k
Stack: classic openais (with plugin). X7 d" U* x; F) t; e
Current DC: node2 - partition with quorum
2 X) |+ C. t) p( u4 ?; m2 qVersion: 1.1.10-14.el6_5.3-368c7267 e/ _# o6 F6 C# @+ v5 C6 b. v( K
3 Nodes configured, 3 expected votes% ^8 o3 D( F! k) l) e
1 Resources configured
- N  z* |" i- ?+ y0 Y& X( g
/ k$ l; r, k( [4 n# d) \; y8 q9 V4 q% J) A6 p% v. N
Online: [ node1 node2 node3 ]) t" y4 b; e' o$ r9 |

  E% r/ w' Z% i MaxScale        (lsb:maxscale):        Started node1
2 P5 M( e. S( A8 H8 W. KThe 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?8 G) E: ~8 u+ K0 I- _& \5 v9 a- L
# mysql -h $MAXSCALE_IP -P 4006 -utest -p test
' T- N( h- ~% Q& d! _% a  TWhat is the $MAXSCALE_IP then? Let’s Follow the last step ...
: p) Q" P) Y( w' hStep 7 - Add a Virtual IP (VIP) to the cluster# s! |# [" l( u, C) y7 Z
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.
8 @/ Q* @3 E9 X3 k1 G6 i  wThe 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:
- p) ?  {5 {" D4 e[root@node2 ~]# crm configure primitive maxscale_vip ocf:heartbeat:IPaddr2 params ip=192.168.122.125 op monitor interval=10s2 a* @" A$ ]2 b/ ~- Z: \" h/ o8 q
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’.
5 D" v: r9 B( ]+ f[root@node2 ~]# crm configure group maxscale_service maxscale_vip MaxScale
/ {" g+ P! T2 UHere is the final configuration:& w" d6 I, S0 M8 G: C
[root@node3 ~]# crm configure show
/ _! }  I1 ?2 l+ T2 ^node node11 G* [+ t" S& ]
node node27 V( R8 F8 Y# A, b% }
node node3
$ Q! _" @! B5 X/ h# p+ L2 p/ Cprimitive MaxScale lsb:maxscale \* L# ?) c( \/ N6 Q: L
        op monitor interval=15s timeout=10s \. C' N5 o2 J6 F
        op start interval=0 timeout=15s \$ y3 X# ?5 A3 F; ?9 c. _- T
        op stop interval=0 timeout=30s
, i; ]1 _  X: k3 I6 vprimitive maxscale_vip IPaddr2 \, i0 P& _4 x/ H2 m
        params ip=192.168.122.125 \5 Y# H; ?8 V2 A5 O8 {
        op monitor interval=10s6 ?8 J0 Y! \$ A5 m
group maxscale_service maxscale_vip MaxScale \
% a+ z( _% b( T! h$ d8 g        meta target-role=Started
1 Y3 S: ?( f) i: Uproperty cib-bootstrap-options: \
! D$ Q) v% y  S2 u$ \4 M        dc-version=1.1.10-14.el6_5.3-368c726 \
# ]/ B, F7 T/ v  s% _; J        cluster-infrastructure="classic openais (with plugin)" \7 F* r" _  K( d! h, b% x
        expected-quorum-votes=3 \$ Z# I+ g- w; H6 h5 B
        stonith-enabled=false \
  S& G2 C2 j% C8 y) x% b( F        no-quorum-policy=ignore \
4 \9 p* U/ T& |' Z        placement-strategy=balanced \
& {' l* x2 {2 k' X        last-lrm-refresh=1404125486
& [( {4 C' C6 v/ d/ k, wCheck the resource status:
' K* j5 S8 I# t3 N[root@node1 ~]# crm status, M. q3 C! r' d3 H, Z7 _7 A- J
Last updated: Mon Jun 30 13:51:29 2014; O4 P6 Q' |5 ~, y3 g
Last change: Mon Jun 30 13:51:27 2014 via crmd on node1/ b3 O! l1 c# V4 j' ~+ q. p
Stack: classic openais (with plugin)% W1 J+ m- Q& y& S$ Q
Current DC: node2 - partition with quorum: h. h: E: q& ?' ~
Version: 1.1.10-14.el6_5.3-368c726# O+ w' ~. s5 U7 x
3 Nodes configured, 3 expected votes6 x) y; i! B8 l/ X: n
2 Resources configured
+ S; U+ g5 g. H  w' p$ W2 _1 `1 Q# o
2 D- j; Z$ Z( C& fOnline: [ node1 node2 node3 ]+ L% C; k& s! s
7 V. @" l2 ~3 c
Resource Group: maxscale_service
4 k  q3 D1 v/ Z9 b$ u; h/ o3 n     maxscale_vip        (ocf::heartbeat:IPaddr2):        Started node2
) T* ]; I% I$ v8 J     MaxScale        (lsb:maxscale):        Started node2 $ S% D- w- }. U% ^2 f, G2 B4 Q; o
With both resources on node2, now MaxScale service will be reachable via the configured VIP address 192.168.122.125:! z4 i9 v8 B# }# f2 o
# mysql -h 192.168.122.125 -P 4006 -utest -p test
: }& b) ~/ |- m* E( ]0 [Please note our three Linux boxes setup require now four IP addresses: one for each node plus the moving IP address assigned to MaxScale
9 z$ P: `% z$ h+ W& [; u3 {  i' dSummary
$ j6 y9 H0 ?: E" KThe goal of this post was to present a quick HA solution for a running MaxScale setup, using a widely adopted open-source clustering solution.9 _3 J+ P$ Z1 z
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.
8 K) ^; a# s$ h; |The reader might fin the LSB script tutorials interesting too, just enabling another application to the HA side,
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 点击这里给我发消息

GMT+8, 2026-4-8 15:21 , Processed in 0.089920 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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