4. MaxScale
-‐
Objectives
•Highly
Scalable
•Extendible
•Lightweight,
with
small
footprint
•Must
provide
authentication
•Minimum
possible
latency
•Highly
available
•Must
be
transparent
to
the
application
!
4
5. MaxScale
Core
•Event
driven
network
I/O
processor
•Polling,
event
driven
mechanism
that
is
responsible
for
dispatching
events
to
the
various
modules
that
make
up
the
MaxScale
application
•Events
in
MaxScale
=
Network
requests,
such
as:
•Handling
an
incoming
connection
on
a
listener
socket
•Incoming
data
for
a
client
connection
•Data
arriving
on
a
connection
from
a
backend
database
server
•A
socket
error
on
one
of
the
client
or
database
connections
•A
socket
closure
•The
availability
of
connections
to
receive
more
data
5
6. MaxScale
Polling
•Linux
epoll
mechanism
to
poll
for
activity
on
the
file
descriptors
•The
epoll
mechanism
allows
a
file
descriptor
to
be
registered
along
with
some
user
data
•MaxScale
makes
use
of
this
user
data
to
register
a
descriptor
control
block
for
each
descriptor
6
7. Descriptor
Control
Block
-‐
DCB
•The
main
source
of
state
information
that
is
used
within
the
event
processing
core
of
MaxScale.
•On
an
event
occurring
for
a
descriptor
the
corresponding
DCB
is
used
to
determine
how
that
event
should
be
handled.
•DCB
Members:
•State
-‐
used
to
determine
where
in
its
lifecycle
the
DCB
currently
is.
•Func
-‐
set
of
function
pointers
for
routines
that
are
called
when
particular
events
occur
or
when
MaxScale
wishes
to
perform
certain
operations.
It
allows
MaxScale
to
be
extended
to
support
new
protocols
without
the
need
to
alter
the
MaxScale
core
itself.
•Session
-‐
a
pointer
to
the
session
to
which
this
connection
belongs.
•Service
-‐
the
service
that
this
connection
belongs
to.
•Writeq
-‐
a
pointer
to
a
chain
of
GWBUF
structures
that
contain
data
waiting
to
be
written.
•Delayq
-‐
similar
to
writeq,
it
buffer
data
that
has
to
be
held
due
to
some
other
activity.
7
8. testroute | Router | V1.0.0
debugcli | Router | V1.0.0
readconnroute | Router | V1.0.0
(gdb)
Descriptor
Control
Block
-‐
DCB
Descriptor Control Blocks
The Descriptor Control Block (DCB) is an important concept within MaxScale since it is this
block that is passed to the polling system, when an event occurs it is that structure that is
available and from this structure it must be possible to navigate to all other structures that
contain state regarding the session and protocol in use.
!
gw_dcb_state2string (int state) {!
! switch(state) {!
! ! case DCB_STATE_ALLOC:!
! ! ! return "DCB Allocated";!
! ! case DCB_STATE_POLLING:!
! ! ! return "DCB in the polling loop";!
! ! case DCB_STATE_LISTENING:!
! ! ! return "DCB for listening socket";!
! ! case DCB_STATE_DISCONNECTED:!
! ! ! return "DCB socket closed";!
! ! case DCB_STATE_FREED:!
! ! ! return "DCB memory could be freed";!
! ! case DCB_STATE_ZOMBIE:!
! ! ! return "DCB Zombie";!
! ! default:!
! ! ! return "DCB (unknown)";!
! }!
}
Similar print routines exist for the DCB
(gdb) call printAllDCBs()
DCB: 0x60ead0
DCB state:
DCB for listening socket
Queued write data:
0
8
9. Descriptor
Control
Block
-‐
DCB
!
DCB: 0xfb1650!
! DCB state:
! Service:
! Statistics:!
! ! No. of Reads:
! ! No. of Writes:
! ! No. of Buffered
! ! No. of Accepts:
DCB: 0x1050bc0!
! DCB state:
! Service:
! Statistics:!
! ! No. of Reads:
! ! No. of Writes:
! ! No. of Buffered
! ! No. of Accepts:
DCB: 0xfae370!
! DCB state:
! Service:
! Statistics:!
! ! No. of Reads:
! ! No. of Writes:
! ! No. of Buffered
! ! No. of Accepts:
DCB: 0x107ff50!
! DCB state:
! Service:
! Connected to:
! Statistics:!
! ! No. of Reads:
! ! No. of Writes:
! ! No. of Buffered
! ! No. of Accepts:
!
DCB for listening socket!
RW Split Router!
0!
0!
Writes: 0!
1324!
DCB for listening socket!
HTTPD Router!
0!
0!
Writes: 0!
0!
DCB for listening socket!
Debug Interface!
0!
0!
Writes: 0!
1!
DCB: 0x10ed970!
! DCB state:
! Service:
! Statistics:!
! ! No. of Reads:
! ! No. of Writes:
! ! No. of Buffered
! ! No. of Accepts:
DCB: 0x10a0640!
! DCB state:
! Service:
! Statistics:!
! ! No. of Reads:
! ! No. of Writes:
! ! No. of Buffered
! ! No. of Accepts:
DCB: 0x10a6e40!
! DCB state:
! Service:
! Connected to:
! Statistics:!
! ! No. of Reads:
! ! No. of Writes:
! ! No. of Buffered
! ! No. of Accepts:
DCB in the polling loop!
RW Split Router!
4!
3!
Writes: 0!
0!
DCB in the polling loop!
RW Split Router!
3!
2!
Writes: 0!
0!
DCB in the polling loop!
Debug Interface!
127.0.0.1!
12!
205!
Writes: 0!
0!
DCB in the polling loop!
RW Split Router!
192.168.0.20!
3!
3!
Writes: 0!
0
9
12. Module
•A
separate
code
entity
that
may
be
loaded
dynamically
into
MaxScale
to
increase
the
available
functionality.
•Modules
are
implemented
as
run-‐
time
loadable
shared
objects
!
MaxScale> show modules!
!
Module Name
| Module Type | Version!
----------------+-------------+---------!
MySQLBackend
| Protocol
| V2.0.0!
telnetd
| Protocol
| V1.0.1!
HTTPD
| Protocol
| V1.0.1!
MySQLClient
| Protocol
| V1.0.0!
mysqlmon
| Monitor
| V1.0.0!
readwritesplit | Router
| V1.0.2!
testroute
| Router
| V1.0.0!
debugcli
| Router
| V1.0.1
12
13. Server
•An
individual
database
server
to
which
a
client
can
be
connected
via
MaxScale
!
MaxScale> show servers!
Server 0xfae860!
! Server:
192.168.0.21!
! Status:
Master, Running!
! Protocol:! !
MySQLBackend!
! Port:! ! !
3306!
! Number of connections: 1320!
! Current no. of connections:!1!
Server 0xfb15c0!
! Server:
192.168.0.22!
! Status:
Slave, Running!
! Protocol:
MySQLBackend!
! Port:
3306!
! Number of connections: 298!
! Current no. of connections:!0!
Server 0xfb1530!
! Server:
192.168.0.23!
! Status:
Slave, Running!
! Protocol:
MySQLBackend!
! Port:
3306!
! Number of connections: 365!
! Current no. of connections:!0!
Server 0xfb14a0!
! Server:
192.168.0.24!
! Status:
Slave, Running!
! Protocol:
MySQLBackend!
! Port:
3306!
! Number of connections: 365!
! Current no. of connections:!0!
Server 0xfb1410!
! Server:
192.168.0.25!
! Status:
Slave, Running!
! Protocol:
MySQLBackend!
! Port:
3306!
! Number of connections: 292!
! Current no. of connections:!1!
MaxScale>
13
14. Monitor
•A
module
that
can
be
executed
within
MaxScale
to
monitor
the
state
of
a
set
of
database.
•The
use
of
an
internal
monitor
is
optional,
monitoring
may
be
performed
externally
to
MaxScale.
!
MaxScale> show monitors!
Monitor: 0x104ddc0!
! Name:! ! MariaDB10 Monitor!
! Monitor running!
! Monitored servers:!192.168.0.21:3306, 192.168.0.22:3306, 192.168.0.23:3306, 192.168.0.24:3306, 192.168.0.25:3306
14
15. Router
•A
module
within
MaxScale
that
will
route
client
request
to
the
various
database
server
which
MaxScale
provides
a
service
interface
to
15
16. Connection
Routing
•A
method
of
handling
requests
in
which
MaxScale
will
accept
connections
from
a
client
and
route
data
on
that
connection
to
a
single
database
using
a
single
connection.
•Connection
based
routing
sets
the
connection
to
a
database
and
it
does
not
examine
requests
on
the
connection.
•Once
the
connection
with
a
database
is
established,
it
cannot
be
moved.
16
17. Statement
Routing
•A
method
of
handling
requests
in
which
each
request
within
a
connection
will
be
handled
individually.
•Requests
may
be
sent
to
one
or
more
servers
and
connections
may
be
dynamically
added
or
removed
from
the
session.
17
18. Protocol
•A
software
module
that
is
used
to
communicate
with
another
software
entity
within
the
system.
•MaxScale
supports
the
dynamic
loading
of
protocol
modules.
18
19. Listener
•The
network
endpoint
that
is
used
to
listen
for
connections
to
MaxScale
from
the
client
applications.
•A
listener
is
associated
to
a
single
service,
however
a
service
may
have
many
listeners.
19
20. Service
•MaxScale
offers
a
set
of
services
to
the
clients
•Each
service
is
a
protocol/port
pair
+
a
query
routing
module
+
backends
•The
protocol
that
should
be
used
•The
port
on
which
to
listen
for
incoming
client
requests
•The
query
routing
module
defines
the
choice
of
backed
server
used
to
execute
the
statement
received
from
the
client
•The
backends
are
the
servers
that
statements
may
be
sent
to
as
part
of
this
service
•A
service
may
have
more
than
one
protocol/port
associated
with
it
!
MaxScale> show services!
Service 0x104cd40!
! Service:! ! RW Split Router!
! Router:! ! ! readwritesplit (0x7ff2a1921d40)!
! Number of router sessions:
! 1320!
! Current no. of router sessions:
! 1!
! Number of queries forwarded:
!
34308!
! Number of queries forwarded to master:!
26691!
! Number of queries forwarded to slave: !
6189!
! Number of queries forwarded to all:
!
1428!
! Started:! ! Wed Jan 1 11:15:17 2014!
! Backend databases!
! ! 192.168.0.25:3306 Protocol: MySQLBackend!
! ! 192.168.0.24:3306 Protocol: MySQLBackend!
! ! 192.168.0.23:3306 Protocol: MySQLBackend!
! ! 192.168.0.22:3306 Protocol: MySQLBackend!
! ! 192.168.0.21:3306 Protocol: MySQLBackend!
! Users data:
! 0x104dd00!
! Total connections:! 1321!
! Currently connected:!2!
Service 0xfaf380!
! Service:! ! HTTPD Router!
! Router:! ! ! testroute (0x7ff2a1b277c0)!
! Started:! ! Wed Jan 1 11:15:17 2014!
! Backend databases!
! ! 192.168.0.25:3306 Protocol: MySQLBackend!
! ! 192.168.0.24:3306 Protocol: MySQLBackend!
! ! 192.168.0.23:3306 Protocol: MySQLBackend!
! ! 192.168.0.22:3306 Protocol: MySQLBackend!
! ! 192.168.0.21:3306 Protocol: MySQLBackend!
! Users data:
! 0xfaf740!
! Total connections:! 1!
! Currently connected:!1!
Service 0xfae8f0!
! Service:! ! Debug Interface!
! Router:! ! ! debugcli (0x7ff2a1d31500)!
! Started:! ! Wed Jan 1 11:15:17 2014!
! Backend databases!
! Users data:
! 0xfaf1b0!
! Total connections:! 2!
! Currently connected:!2
20
21. Connection
Failover
•When
a
connection
currently
being
used
between
MaxScale
and
the
database
server
fails
a
replacement
will
be
automatically
created
to
another
server
by
MaxScale
without
client
intervention
21
25. Set
the
Environment
Variables
and
Start
MaxScale
!
[root@Sky6 ~]# MAXSCALE_HOME=/usr/local/skysql/maxscale/MaxScale!
[root@Sky6 ~]# LD_LIBRARY_PATH=/usr/local/skysql/maxscale/lib!
[root@Sky6 ~]# /usr/local/skysql/maxscale/bin/maxscale!
!
!
SkySQL MaxScale! Tue Dec 31 14:59:16 2013!
------------------------------------------------------!
Info : MaxScale will be run in a daemon process.!
! See the log from the following log files :!
!
Error log
Message log
Trace log
Debug log
:!
:!
:!
:!
/usr/local/skysql/maxscale/MaxScale/log/skygw_err1.log!
/usr/local/skysql/maxscale/MaxScale/log/skygw_msg1.log!
/usr/local/skysql/maxscale/MaxScale/log/skygw_trace1.log!
/usr/local/skysql/maxscale/MaxScale/log/skygw_debug1.log!
!
Listening MySQL connections at 0.0.0.0:4004!
Listening http connections at 0.0.0.0:6444!
Listening telnet connections at 0.0.0.0:4444
…or
create
a
3
lines
script
25
26. Checking
MaxScale
!
[root@Sky6 ~]# telnet localhost 4444!
Trying ::1...!
telnet: connect to address ::1: Connection refused!
Trying 127.0.0.1...!
Connected to localhost.!
Escape character is '^]'.!
Welcome the SkySQL MaxScale Debug Interface (V1.0.1).!
Type help for a list of available commands.!
!
MaxScale login: admin!
Password:!
!
MaxScale>
UID/PWD:
admin
/
skysql
!
MaxScale> help!
Available commands:!
add user!
clear server!
remove user!
restart monitor!
restart service!
set server!
show dcbs!
show dcb!
show dbusers!
show epoll!
show modules!
show monitors!
show server!
show servers!
show services!
show session!
show sessions!
show users!
shutdown maxscale!
shutdown monitor!
shutdown service!
reload config!
reload dbusers!
enable log!
disable log
26
28. Configuration
Template
!
[root@Sky6 etc]# cat MaxScale_template.cnf!
#!
# Example MaxScale.cnf configuration file!
#!
# Number of server threads!
# Valid options are:!
# ! hreads=<number of threads>!
t
!
[maxscale]!
threads=1!
…!
!
[Monitor Module]!
…!
!
[R/W Split Module]!
…!
!
[Read Connection Router]!
…!
!
[HTTPD Router]!
…!
!
[Debug Interface]!
…
!
# Listener definitions for the services!
#!
# Valid options are:!
#!
# ! ervice=<name of service defined elsewhere>!
s
# ! rotocol=<name of protocol module with which to listen>!
p
# ! ort=<Listening port>!
p
!
[RW Split Listener]!
…!
!
[Read Connection Listener]!
…!
!
[Debug Listener]!
…!
!
[HTTPD Listener]!
…!
!
# Definition of the servers!
!
[server1]!
…!
!
[serverN]!
…
28
29. Database
Settings
•Create
a
valid
MaxScale
user
•Allow
access
from
the
MaxScale
node
!
MariaDB [test]> create user maxuser identified by 'maxpwd';!
Query OK, 0 rows affected (0.01 sec)!
!
MariaDB [test]> grant all on *.* to maxuser@‘192.168.0.26’;!
Query OK, 0 rows affected (0.00 sec)
29
30. Global
Settings
!
•Settings
used
to
configure
the
core
of
MaxScale
[maxscale]!
threads=1!
•Options:
•threads
-‐
number
of
user
threads
that
poll
for
network
traffic
• Start
with
the
smallest
number
and
try
to
increase
to
check
the
impact
on
high
workload
• This
parameter
does
not
include
the
number
of
“internal
threads”
30
31. Server
Settings
•Settings
used
to
configure
the
backend
•type
-‐
the
server
type
•Options:
•address
-‐
The
IP
address
used
by
MaxScale
to
connect
to
the
server
•port
-‐
The
TCP
port
used
by
MaxScale
to
connect
to
the
server
•Protocol
-‐
The
DB
protocol.
• MySQLBackend
is
the
native
MySQL
protocol
•MonitorUser
-‐
The
DB
user
used
by
MaxScale
to
connect
with
the
Monitoring
module
• When
MonitorUser
is
not
present,
MaxScale
uses
the
credentials
set
in
the
Monitor
section
•MonitorPW
-‐
The
DB
user
password
!
[max1]!
type=server!
address=192.168.0.21!
port=3006!
protocol=MySQLBackend!
!
[max2]!
type=server!
address=192.168.0.22!
port=3006!
protocol=MySQLBackend!
!
…!
!
[max5]!
type=server!
address=192.168.0.25!
port=3006!
protocol=MySQLBackend
31
32. Monitor
Settings
•Settings
used
to
configure
the
monitor
module
for
MySQL/MariaDB
•type
-‐
the
monitor
type
•Options:
•module
-‐
The
loadable
module,
mysqlmon
for
MySQL/
MariaDB
•servers
-‐
Comma
separated
list
of
the
servers
to
monitor
• Servers
must
be
of
the
same
type
(e.g.
MySQL/MariaDB
servers)
•user
-‐
DB
user
used
to
connect
to
the
server
• Used
when
the
credentials
are
not
available
in
the
server
section
•passwd
-‐
DB
user
password
!
[MariaDB10 Monitor]!
type=monitor!
module=mysqlmon!
servers=max1,!
max2,!
max3,!
max4,!
max5!
user=maxuser!
passwd=maxpwd
32
33. SLB
with
Read/Write
Split
Service
Settings
•Settings
used
to
configure
the
service
module
for
statement-‐based
load
balancing
(with
read/write
splitting)
•type
-‐
the
service
type
•Options:
•router
-‐
The
loadable
module,
readwritesplit
for
MySQL/
MariaDB
R/W
splitting
with
MySQL
Replication
•servers
-‐
Comma
separated
list
of
the
servers
to
monitor
•user
-‐
DB
user
used
to
connect
to
the
server
to
extract
the
list
of
the
database
users
to
allow
local
authentication
•passwd
-‐
DB
user
password
!
[RW Split Router]!
type=service!
router=readwritesplit!
servers=max1,!
max2,!
max3,!
max4,!
max5 !
user=maxuser!
passwd=maxpwd
33
34. CLB
Service
Settings
•Settings
used
to
configure
the
service
module
for
statement-‐
based
load
balancing
(with
read/write
splitting)
•type
-‐
the
service
type
•Options:
•router
-‐
The
loadable
module,
readconnroute
for
connection
load
balancing
with
MySQL
Replication
•router_options
-‐
options
passed
to
the
module.
• slave
means
that
the
load
balancing
is
applied
only
to
the
slave
servers
• master,slave
means
that
the
load
balancing
is
applied
master
and
slave
servers
•servers
-‐
Comma
separated
list
of
the
servers
to
monitor
•user
-‐
DB
user
used
to
connect
to
the
server
to
extract
the
list
of
the
database
users
to
allow
local
authentication
•passwd
-‐
DB
user
password
!
[Read Connection Router]!
type=service!
router=readconnroute!
router_options=slave!
servers=max1,!
max2,!
max3,!
max4,!
max5!
user=maxuser!
passwd=maxpwd
34
35. Listener
Settings
-‐
SLB
!
•Set
the
Protocol
and
Service
pair.
This
is
used
to
offer
the
SLB
with
Read/Write
Splitting
•type
-‐
the
listener
type
[RW Split Listener]!
type=listener!
service=RW Split Router!
protocol=MySQLClient!
port=4006!
•Options:
•service
-‐
The
service
associated
to
the
listener
(e.g.
RW
Split
Router)
•protocol
-‐
The
protocol
paired
to
the
service
(e.g.
MySQLClient)
•port
-‐
The
TCP
port
used
to
listen
to
the
client
requests
35
36. Listener
Settings
-‐
Debug
&
HTTP
!
•These
listeners
are
used
to
offer
a
debug
and
a
HTTP
interface
to
MaxScale
•type
-‐
the
listener
type
•Options:
•service
-‐
DBAs
can
connect
to
MaxScale
using
telnet
or
via
a
restful
API
•protocol
-‐
The
protocol
paired
to
the
service
(e.g.
telnetd
and
httpd
)
•port
-‐
The
TCP
port
used
to
listen
to
the
client
requests
[Debug Listener]!
type=listener!
service=Debug Interface!
protocol=telnetd!
port=4444!
!
[HTTPD Listener]!
type=listener!
service=HTTPD Router!
protocol=HTTPD!
port=6444
36
37. Final
Configuration
!
[root@Sky6 etc]# cat MaxScale.cnf!
#!
# Number of server threads!
# Valid options are:!
# !
threads=<number of threads>!
[maxscale]!
threads=1!
!
#!
# Define a monitor that can be used to determine the state!
# and role of the servers.!
#!
# Valid options are:!
#!
# !
module=<name of module to load>!
# !
servers=<server name>,<server name>,...!
# !
user =<user name - must have slave replication and!
#
slave client privileges>!
# !
passwd=<password of the above user,
#
plain text currently>!
[MariaDB10 Monitor]!
type=monitor!
module=mysqlmon!
servers=max1,max2,max3,max4,max5!
user=maxuser!
passwd=maxpwd
!
#!
# A series of service definition!
#!
# Valid options are:!
#!
# !
router=<name of router module>!
# !
servers=<server name>,<server name>,...!
# !
user=<User to fetch password inforamtion with>!
# !
passwd=<Password of the user, plain text currently>!
#!
# Valid router modules currently are:!
# !
readwritesplit, readconnroute and debugcli!
[RW Split Router]!
type=service!
router=readwritesplit!
servers=max1,max2,max3,max4,max5!
user=maxuser!
passwd=maxpwd!
!
[HTTPD Router]!
type=service!
router=testroute!
servers=max1,max2,max3,max4,max5!
!
[Debug Interface]!
type=service!
router=debugcli
37
38. Final
Configuration
!
#!
# Listener definitions for the services!
#!
# Valid options are:!
#!
# !
service=<name of service defined elsewhere>!
# !
protocol=<name of protocol module with which to listen>!
# !
port=<Listening port>!
[RW Split Listener]!
type=listener!
service=RW Split Router!
protocol=MySQLClient!
port=4004!
!
[Debug Listener]!
type=listener!
service=Debug Interface!
protocol=telnetd!
port=4444!
!
[HTTPD Listener]!
type=listener!
service=HTTPD Router!
protocol=HTTPD!
port=6444!
!
# Servers Definition!
[max1]!
type=server!
address=192.168.0.21!
port=3306!
protocol=MySQLBackend!
!
[max2]!
type=server!
address=192.168.0.22!
port=3306!
protocol=MySQLBackend!
!
[max3]!
type=server!
address=192.168.0.23!
port=3306!
protocol=MySQLBackend!
!
[max4]!
type=server!
address=192.168.0.24!
port=3306!
protocol=MySQLBackend!
!
[max5]!
type=server!
address=192.168.0.25!
port=3306!
protocol=MySQLBackend
38
39. Password
Encryption
•Used
to
remove
plain
password
from
the
config
file
•Passwords
are
stored
in
a
readonly
file
(default
$MAXSCALE_HOME/etc/.secrets)
•Plain
passwords
in
the
config
file
can
be
replaced
with
the
encrypted
password
!
[root@Sky6 ~]# /usr/local/skysql/maxscale/bin/
maxkeys /usr/local/skysql/maxscale/MaxScale/
etc/.secrets!
!
[root@Sky6 ~]# MAXSCALE_HOME=/usr/local/skysql/
maxscale/MaxScale!
[root@Sky6 ~]# /usr/local/skysql/maxscale/bin/
maxpasswd maxpwd!
14AE17C29AE7E6DB94EA5E6068D9833D!
!
[root@Sky6 ~]# vi /usr/local/skysql/maxscale/
MaxScale/etc/MaxScale.cnf!
!
…!
[MariaDB10 Monitor]!
type=monitor!
module=mysqlmon!
servers=max1,max2,max3,max4,max5!
user=maxuser!
passwd=14AE17C29AE7E6DB94EA5E6068D9833D!
…
39
40. Checking
MaxScale
SLB
R/W
Splimer
(for
the
users)
RESTful
API
(under
development)
Telnet
Interface
(for
debugging
and
DBAs)
!
MaxScale> show services!
Service 0x8e1d40!
! Service:! ! RW Split Router!
! Router:! ! ! readwritesplit (0x7ff7dd4d0d40)!
! Number of router sessions:
! 0!
! Current no. of router sessions:
! 0!
! Number of queries forwarded:
! 0!
! Number of queries forwarded to master:! 0!
! Number of queries forwarded to slave: ! 0!
! Number of queries forwarded to all:
! 0!
! Started:! ! Tue Dec 31 17:36:13 2013!
! Backend databases!
! ! 192.168.0.25:3006 Protocol: MySQLBackend!
! ! 192.168.0.24:3006 Protocol: MySQLBackend!
! ! 192.168.0.23:3006 Protocol: MySQLBackend!
! ! 192.168.0.22:3006 Protocol: MySQLBackend!
! ! 192.168.0.21:3006 Protocol: MySQLBackend!
! Users data:
!0x8e2d00!
! Total connections:! 1!
! Currently connected:! 1!
Service 0x844380!
! Service:! ! HTTPD Router!
! Router:! ! ! testroute (0x7ff7dd6d67c0)!
! Started:! ! Tue Dec 31 17:36:13 2013!
! Backend databases!
! ! 192.168.0.25:3006 Protocol: MySQLBackend!
! ! 192.168.0.24:3006 Protocol: MySQLBackend!
! ! 192.168.0.23:3006 Protocol: MySQLBackend!
! ! 192.168.0.22:3006 Protocol: MySQLBackend!
! ! 192.168.0.21:3006 Protocol: MySQLBackend!
! Users data:
!0x844740!
! Total connections:! 1!
! Currently connected:! 1!
Service 0x8438f0!
! Service:! ! Debug Interface!
! Router:! ! ! debugcli (0x7ff7dd8e0500)!
! Started:! ! Tue Dec 31 17:36:13 2013!
! Backend databases!
! Users data:
!0x8441b0!
! Total connections:! 2!
! Currently connected:! 2
40
41. Troubleshooting
!
2013 12/31 17:47:24 Error : access for secrets file [/usr/local/skysql/maxscale/MaxScale/etc/.secrets]
failed. Error 2, No such file or directory.
MaxScale
cannot
fine
the
encrypted
password
file
!
[root@Sky6 bin]# /usr/local/skysql/maxscale/MaxScale/bin/maxkeys /usr/local/skysql/maxscale/MaxScale/
etc/.secrets!
41
42. Troubleshooting
!
[root@Sky0 ~]# mysql -uroot -h 192.168.0.26 -P4004 -p!
Enter password:!
ERROR 1045 (2800): Authorization failed!
[root@Sky0 ~]#
root
is
not
loaded
to
the
available
users
to
connect
via
MaxScale
!
<<<< User [root] was not found!
<<< CLIENT AUTH FAILED for user [root]!
!
[root@Sky0 ~]# mysql -umaxuser -h 192.168.0.26 -P4004 -pmaxpwd!
Welcome to the MariaDB monitor. Commands end with ; or g.!
Your MySQL connection id is 1535!
Server version: 5.5.22-SKYSQL-0.1.0 MariaDB Server!
!
Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.!
!
Careful
with
this!
Type 'help;' or 'h' for help. Type 'c' to clear the current
input statement.!
!
MySQL [(none)]>
42
43. Troubleshooting
From
MaxScale
You
see
the
Max1
process
list
!
MySQL [(none)]> show processlist;!
+-----+---------+-------------------+------+-------------+-------+----------------------------------------+------------------+----------+!
| Id | User
| Host
| db
| Command
| Time | State
| Info
| Progress |!
+-----+---------+-------------------+------+-------------+-------+----------------------------------------+------------------+----------+!
|
5 | root
| skycluster3:33830 | NULL | Binlog Dump | 82453 | Master has sent all binlog to slave; … | NULL
|
0.000 |!
|
6 | root
| skycluster4:43403 | NULL | Binlog Dump | 82389 | Master has sent all binlog to slave; … | NULL
|
0.000 |!
|
7 | root
| skycluster5:46878 | NULL | Binlog Dump | 82382 | Master has sent all binlog to slave; … | NULL
|
0.000 |!
|
8 | root
| skycluster2:54912 | NULL | Binlog Dump | 82376 | Master has sent all binlog to slave; … | NULL
|
0.000 |!
| 100 | root
| skycluster0:41977 | NULL | Sleep
|
0 |
| NULL
|
0.000 |!
| 101 | root
| skycluster0:41997 | NULL | Sleep
|
60 |
| NULL
|
0.000 |!
| 129 | maxuser | skycluster6:55557 | NULL | Sleep
|
5 |
| NULL
|
0.000 |!
| 132 | maxuser | skycluster6:55565 | NULL | Query
|
0 | init
| show processlist |
0.000 |!
| 135 | maxuser | skycluster6:55571 | NULL | Sleep
|
41 |
| NULL
|
0.000 |!
+-----+---------+-------------------+------+-------------+-------+----------------------------------------+------------------+----------+!
9 rows in set (0.00 sec)
This
is
directly
from
Max2
!
MariaDB [(none)]> show processlist;!
+----+-------------+-------------------+------+---------+-------+----------------------------------+------------------+----------+!
| Id | User
| Host
| db
| Command | Time | State
| Info
| Progress |!
+----+-------------+-------------------+------+---------+-------+----------------------------------+------------------+----------+!
| 4 | system user |
| NULL | Connect | 82804 | Waiting for master to send event | NULL
|
0.000 |!
| 5 | system user |
| NULL | Connect | 73387 | Slave has read all relay log; wa…| NULL
|
0.000 |!
| 14 | root
| skycluster0:35933 | NULL | Sleep
|
0 |
| NULL
|
0.000 |!
| 15 | root
| skycluster0:35936 | NULL | Sleep
|
216 |
| NULL
|
0.000 |!
| 44 | maxuser
| skycluster6:46518 | NULL | Sleep
|
3 |
| NULL
|
0.000 |!
| 46 | root
| localhost
| NULL | Query
|
0 | init
| show processlist |
0.000 |!
+----+-------------+-------------------+------+---------+-------+----------------------------------+------------------+----------+!
6 rows in set (0.00 sec)
43
45. MaxScale
with
MySQL
Replication
using
Connection
Load
Balancing
For
applicaLons
that
are
“ReplicaLon
aware”,
i.e.
they
can
use
2
connecLons,
one
for
the
master
and
one
for
the
slave
servers
MaxScale
Each
applicaeon
server
uses
2
conneceon:
1
Read/Write,
1
Read/Only
Conneceon
load
balancing
is
fast,
lightweight
and
it
provides
high
availability
Database
Database
Database
Database
Database
MaxScale
connects
the
R/W
client
conneceon
to
the
master
and
it
load
balances
the
R/O
client
conneceon
to
one
of
the
slaves
MHA
provides
the
automaec
failover
in
case
of
fault
of
the
master
45
46. MaxScale
with
MySQL
Replication
using
Connection
Load
Balancing
[Write Listener]
type=listener
service=Write Service
protocol=MySQLClient
port=4007
[Read Listener]
type=listener
service=Read Service
protocol=MySQLClient
port=4006
MaxScale
[Write Service]
type=service
router=readconnroute
router_options=master
servers=s1,s2,s3,s4,s5
user=maxuser
auth=maxpwd
[Read Service]
type=service
router=readconnroute
router_options=slave
servers=s1,s2,s3,s4,s5
user=maxuser
auth=maxpwd
Database
Database
Database
Database
Database
46
47. MaxScale
with
Galera
using
Connection
Load
Balancing
Each
applicaeon
server
uses
only
1
conneceon
For
applicaLons
that
can
use
the“all-‐
master”
capabiliLes
of
Galera
MaxScale
MaxScale
monitors
the
state
of
each
Galera
Cluster
and
it
applies
load
balancing
only
on
synced
nodes
MaxScale
load
balances
the
client
conneceons
to
the
Galera
nodes
Database
Database
Database
47
48. MaxScale
with
Galera
using
Connection
Load
Balancing
[Read Listener]
type=listener
service=Read Service
protocol=MySQLClient
port=4006
MaxScale
[Galera Service]
type=service
router=readconnroute
router_options=synced
servers=s1,s2,s3,s4,s5
user=maxuser
auth=maxpwd
Database
Database
Database
48
49. MaxScale
with
MySQL
Replication
using
Read/Write
Splitting
Each
applicaeon
server
uses
only
1
conneceon
For
applicaLons
that
have
been
designed
to
work
with
a
single
server
and
require
read
scalability
MaxScale
MaxScale
monitors
the
state
of
each
node
and
it
applies
load
balancing
only
on
the
available
slaves
Database
Database
Database
Database
Database
MaxScale
creates
2
conneceons,
one
for
R/W
on
the
master
node
and
one
R/O
load
balanced
on
the
slave
nodes
49
50. How
does
MaxScale
compare
to…
•HA
Proxy
•MySQL
Proxy
•Sharding
solutions
-‐
ScaleBase,
DBShards,
Parelastic,
etc.
50
51. JSON
over
http
and
BSON
Strictly
Confidential
-‐
SkySQL
Internal
Use
Only
51
53. Where
To
Find
More
Material
GitHub
Project
hUps://github.com/skysql/MaxScale
Tarball
hUps://downloads.skysql.com/files/SkySQL/MaxScale
Documentaeon
hUps://github.com/skysql/MaxScale/tree/master/DocumentaLon
53