SlideShare a Scribd company logo
Scaling Out MariaDB
Server w/ MaxScale
By Wagner Bianchi
Principal RDBA
wagner.bianchi@mariadb.com
M|17
The Conrad Hotel, NYC
April 11 - 12, 2017
m17.mariadb.com
Promo code: BIGAPPLE
Europe Roadshow

Locations in May & June
Berlin

May 18
Munich

May 11
Bonn

June 30
Amsterdam

May 23
Paris
June 30
Madrid

May 18
Milan
May 11
Details and registration:
http://go.mariadb.com/Europe-Roadshow-LP.html
More dates and locations will be announced soon!
Meetup’s Agenda
• With MariaDB Server:
• Replication::ReadWriteSplit;
• Replication::ConnectionRouting;
• Replication::SchemaRouter;
• With MariaDB Cluster:
• Configuring it as Master/Slave cluster
• New features MaxScale 2.1 (coming soon)
4
Scalability and, what are we talking about?
5
Scaling-Out MariaDB Server
6
MariaDB Server, Replication::ReadWriteSplit
• The readwritesplit router is designed to increase the read-only processing capability of
a cluster while maintaining consistency;
• This is achieved by splitting the query load into read and write queries;
• Read queries, which do not modify data, are spread across multiple nodes while all write
queries will be sent to a single node;
• This router is designed to be used with a traditional Master-Slave replication cluster;
MaxScale> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
myrocksdb01 | 192.168.50.11 | 3306 | 0 | Master, Running
myrocksdb02 | 192.168.50.12 | 3306 | 0 | Slave, Running
myrocksdb03 | 192.168.50.13 | 3306 | 0 | Slave, Running
-------------------+-----------------+-------+-------------+--------------------
7
MariaDB Server, Replication::ReadWriteSplit
• The following operations are routed to master:
• write statements;
• all statements within an open transaction;
• stored procedure calls, and user-defined function calls;
• DDL statements (DROP|CREATE|ALTER TABLE … etc.);
• EXECUTE (prepared) statements;
• all statements using temporary tables.
8
MariaDB Server, Replication::ReadWriteSplit
• Queries which can be routed to slaves must be auto committed and belong to one of the
following group:
• read-only database queries;
• read-only queries to system, or user-defined variables;
• SHOW statements, and system function calls.
• Slaves can be set as per max_slave_connections as it sets the maximum number of
slaves a router session uses at any moment - default is all including master;
• One can use router_options to remove current master to the current read pool;
9
MariaDB Server, Replication::ReadWriteSplit
• router_options
• it may include multiple readwritesplit-specific options;
• slave_selection_criteria, how requests will be sent to slaves;
• LEAST_GLOBAL_CONNECTIONS, the slave with least connections
from MariaDB MaxScale
• LEAST_ROUTER_CONNECTIONS, the slave with least connections
from this service
• LEAST_BEHIND_MASTER, the slave with smallest replication lag
• LEAST_CURRENT_OPERATIONS (default), the slave with least active
operations
10
MariaDB Server, Replication::ReadWriteSplit
• router_options
• master_accept_reads = [true|false]
• the is the option that can include or remove master from the reading pool;
• master_failure_mode
• fail_instantly, when the failure of the master server is detected, the connection
will be closed immediately.
• fail_on_write, the client connection is closed if a write query is received when
no master is available.
• error_on_write, If no master is available and a write query is received, an
error is returned stating that the connection is in read-only mode.
11
MariaDB Server, Replication::ReadWriteSplit
[myrocksdb03]
type=server
address=192.168.50.13
port=3306
protocol=MySQLBackend
persistpoolmax=100
persistmaxtime=3600
[CLI]
type=service
router=cli
[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
socket=default
[Splitter Service]
type=service
router=readwritesplit
servers=myrocksdb01,myrocksdb02,myrocksdb03
router_options=slave_selection_criteria=LEAST
_BEHIND_MASTER,master_accept_reads=FALSE,mast
er_failure_mode=erro
r_on_write
max_slave_connections=2
max_slave_replication_lag=30
user=maxuser
passwd=YqztlYG…
[Splitter Listener]
type=listener
service=Splitter Service
protocol=MySQLClient
port=3306
socket=/tmp/myrocksdb_cluster.sock
[Replication Monitor]
type=monitor
module=mysqlmon
servers=myrocksdb01,myrocksdb02,myroc
ksdb03
detect_replication_lag=1
detect_stale_master=1
user=maxuser
passwd=YqztlYG…
[myrocksdb01]
type=server
address=192.168.50.11
port=3306
protocol=MySQLBackend
persistpoolmax=100
persistmaxtime=3600
[myrocksdb02]
type=server
address=192.168.50.12
port=3306
protocol=MySQLBackend
persistpoolmax=100
persistmaxtime=3600
12
MariaDB Server, Replication::ConnectionRoute Router
• The readconnroute router provides simple and lightweight load balancing across a set
of servers;
• The router can also be configured to balance connections based on a weighting parameter
defined in the server's section;
• Differs from readwritesplit router as this router needs one port for reads and another
one for writes and router_options can be used as well;
• One can define a goos strategy here:
• point the master directly on the maxscale’s configuration file for writes;
• point the slaves for reads, in case a master crash, adjust configuration file and reload;
13
MariaDB Server, Replication::ConnectionRoute Router
• Let’s consider the following scenario:
MaxScale> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
myrocksdb01 | 192.168.50.11 | 3306 | 0 | Master, Running
myrocksdb02 | 192.168.50.12 | 3306 | 0 | Slave, Running
myrocksdb03 | 192.168.50.13 | 3306 | 0 | Slave, Running
-------------------+-----------------+-------+-------------+--------------------
MaxScale> list services
Services.
--------------------------+----------------------+--------+---------------
Service Name | Router Module | #Users | Total Sessions
--------------------------+----------------------+--------+---------------
Write Service | readconnroute | 2 | 2
Read Service | readconnroute | 1 | 1
CLI | cli | 2 | 2
--------------------------+----------------------+--------+---------------
14
MariaDB Server, Replication::ConnectionRoute Router
• Let’s shutdown current master:
• We do the manual switch on the MariaDB server:
• reset slave all; on myrocksdb02;
• change master to master_host=‘myrocksdb02’; on myrocksdb03;
• On Maxscale, comment server myrocksdb01, remove it form the list of servers on [Replication
Monitor] and on Write Service, on the latter, put myrocksdb02;
• set server myrocksdb02 master
#: stop/crash current master
[root@box01 ~]# systemctl stop mariadb
#: maxscale logs
Server 192.168.50.11:3306 lost the master status.
Server changed state: myrocksdb01[192.168.50.11:3306]: master_down. [Master, Running] -> [Down]
15
MariaDB Server, Replication::ConnectionRoute Router
• After these…
#: new scenario
[root@maxscale maxscale_config]# maxadmin -e "list servers"
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
myrocksdb01 | 192.168.50.11 | 3306 | 0 | Down
myrocksdb02 | 192.168.50.12 | 3306 | 0 | Master, Running
myrocksdb03 | 192.168.50.13 | 3306 | 0 | Slave, Running
-------------------+-----------------+-------+-------------+--------------------
#: maxscale logs
Update server protocol for server 192.168.50.13 to protocol MySQLBackend.
Update server protocol for server 192.168.50.12 to protocol MySQLBackend.
Update router for service Read Service to readconnroute.
Update router for service Write Service to readconnroute.
Server changed state: myrocksdb02[192.168.50.12:3306]: new_slave. [Master, Slave, Running] ->
[Slave, Running]
16
MariaDB Server, Replication::ConnectionRoute Router
• Configuration for readconnroute load balancer
[Write Service]
type=service
router=readconnroute
router_options=master
servers=myrocksdb01
user=maxuser
password=123456
[Read Service]
type=service
router=readconnroute
router_options=slave
servers=myrocksdb02,myrocksdb03
weightby=serv_weight
user=maxuser
password=123456
[Write Listener]
type=listener
service=Write Service
protocol=MySQLClient
port=33066
socket=/tmp/myrocksdb_readconnroute.sock
[Read Listener]
type=listener
service=Read Service
protocol=MySQLClient
port=33077
[myrocksdb01]
type=server
address=192.168.50.11
port=3306
protocol=MySQLBackend
[myrocksdb02]
type=server
address=192.168.50.12
port=3306
protocol=MySQLBackend
serv_weight=3
[myrocksdb03]
type=server
address=192.168.50.13
port=3306
protocol=MySQLBackend
serv_weight=2 17
MariaDB Server, Replication::SchemaRouter Module
18
Scaling-Out MariaDB Cluster
19
Scaling-Out MariaDB Cluster
• MaxScale makes your life easier when working with MariaDB Cluster:
• Checks on severs roles;
• Setup monitors and trigger alerts from nodes status changes;
• Transparently configure good practices in read/write split;
• Elect new “master" node to receive write traffic;
• Add a server under maintenance and clear up its status;
• One can use Galera Monitor or the ReadWriteSplit Module for MariaDB Cluster:
• Galera Monitor: http://bit.ly/2nshrOk
• ReadWriteSplit: http://bit.ly/2oTPXxY
20
Scaling-Out MariaDB Cluster
• Galera Monitor:
• The Galera Monitor is a monitoring module for MaxScale that monitors a Galera
cluster;
• It detects whether nodes are a part of the cluster and if they are in sync with the rest of
the cluster;
• It can also assign master and slave roles inside MaxScale, allowing Galera clusters to be
used with modules designed for traditional master-slave clusters.
21
Scaling-Out MariaDB Cluster
• Listing servers:
• Listing Monitors
MaxScale> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------------
wbwsrep01 | 192.168.50.11 | 3306 | 0 | Master, Synced, Running
wbwsrep02 | 192.168.50.12 | 3306 | 0 | Slave, Synced, Running
wbwsrep03 | 192.168.50.13 | 3306 | 0 | Slave, Synced, Running
-------------------+-----------------+-------+-------------+--------------------------
MaxScale> list monitors
---------------------+---------------------
Monitor | Status
---------------------+---------------------
Galera Monitor | Running
---------------------+---------------------
22
Scaling-Out MariaDB Cluster
• Galera Monitor (or galeramon)
• Avoid new master election by MaxScale when new server is added to the cluster with
Galera’s monitor parameter: disable_master_failback=true
• Use priority to give MaxScale and galeramon the ability to chose a new master in case
current master is down: use_priority=true
• If the SST method of your cluster is set to xtrabackup-v2 (wsrep_sst_method), this
following parameter is interesting to avoid white flag alerts, as this is keep node’s status
as Synced even being a Donor (DONOR/DESYNCED): available_when_donor=true
23
Scaling-Out MariaDB Cluster
• When using priorities to elect current master:
[root@maxscale ~]# maxadmin -e "list servers"
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
wbwsrep01 | 192.168.50.11 | 3306 | 654 | Master, Synced, Running
wbwsrep02 | 192.168.50.12 | 3306 | 76 | Slave, Synced, Running
wbwsrep03 | 192.168.50.13 | 3306 | 89 | Slave, Synced, Running
-------------------+-----------------+-------+-------------+--------------------
[root@maxscale ~]# vim /etc/maxscale.cnf # edited priorities
[root@maxscale ~]# systemctl restart maxscale
[root@maxscale ~]# maxadmin -e "list servers"
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
wbwsrep01 | 192.168.50.11 | 3306 | 78 | Slave, Synced, Running
wbwsrep02 | 192.168.50.12 | 3306 | 3 | Slave, Synced, Running
wbwsrep03 | 192.168.50.13 | 3306 | 12 | Master, Synced, Running
-------------------+-----------------+-------+-------------+--------------------
24
Scaling-Out MariaDB Cluster
• When using priorities to elect current master:
#: monitor section
[Galera Monitor]
type=monitor
module=galeramon
servers=wbwsrep01,wbwsrep02,wbwsrep03
disable_master_failback=true
available_when_donor=true
use_priority=true
user=maxmon
passwd=123
#: servers section
[wbwsrep01]
type=server
address=192.168.50.11
port=3306
protocol=MySQLBackend
priority=3
[wbwsrep02]
type=server
address=192.168.50.12
port=3306
protocol=MySQLBackend
priority=2
[wbwsrep03]
type=server
address=192.168.50.13
port=3306
protocol=MySQLBackend
priority=1
25
Scaling-Out MariaDB Cluster
• In case you need to execute a current master’s restart:
#: stop current master
[root@box03 ~]# systemctl stop mariadb
#: set current master in maintenance
MaxScale> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
wbwsrep01 | 192.168.50.11 | 3306 | 72 | Slave, Synced, Running
wbwsrep02 | 192.168.50.12 | 3306 | 327 | Master, Synced, Running
wbwsrep03 | 192.168.50.13 | 3306 | 0 | Maintenance, Down
—————————+-----------------+-------+-------------+--------------------
#: new master elected (checking logs - /var/log/maxscale/maxscale1.log)
Server changed state: wbwsrep02[192.168.50.12:3306]: new_master. [Slave, Synced, Running] ->
[Master, Synced, Running]
Server changed state: wbwsrep03[192.168.50.13:3306]: master_down. [Master, Synced, Running] ->
[Down]
26
Scaling-Out MariaDB Cluster
• When former master comes back online:
#: when the former master comes back online, now as a slave due to monitor configs we applied
MaxScale> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
wbwsrep01 | 192.168.50.11 | 3306 | 0 | Slave, Synced, Running
wbwsrep02 | 192.168.50.12 | 3306 | 0 | Master, Synced, Running
wbwsrep03 | 192.168.50.13 | 3306 | 0 | Maintenance, Down
-------------------+-----------------+-------+-------------+--------------------
MaxScale> clear server wbwsrep03 maintenance
MaxScale> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
wbwsrep01 | 192.168.50.11 | 3306 | 0 | Slave, Synced, Running
wbwsrep02 | 192.168.50.12 | 3306 | 0 | Master, Synced, Master Stickiness, Running
wbwsrep03 | 192.168.50.13 | 3306 | 0 | Slave, Synced, Running
-------------------+-----------------+-------+-------------+--------------------
27
Scaling-Out MariaDB Cluster
• Adding a new galera cluster's node:
• Provision a new node on cluster level and go for the proper settings;
• Raise the new node and make sure it’s part of the PRIMARY component;
• Make sure the new node is in Sync status:
• On MaxScale 2.0 config file:
• Make sure you add the new [servername] entry on servers definition;
• Make sure the Galera Service and the Galera Monitor lists the the servers name;
• Use maxadmin -e “reload configs"
#: tailing the log file after configurations and restart
Server changed state: wbwsrep01[192.168.50.11:3306]: new_slave. [Running] -> [Slave, Synced, Running]
Server changed state: wbwsrep02[192.168.50.12:3306]: new_slave. [Running] -> [Slave, Synced, Running]
Server changed state: wbwsrep03[192.168.50.13:3306]: new_master. [Running] -> [Master, Synced, Running]
Server changed state: wbwsrep04[192.168.50.14:3306]: new_slave. [Running] -> [Slave, Synced, Running]
28
Scaling-Out MariaDB Cluster
• The new scenario we have by now:
#: listing servers again, with the new added one
[root@maxscale ~]# maxadmin -e "list servers"
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
wbwsrep01 | 192.168.50.11 | 3306 | 0 | Slave, Synced, Running
wbwsrep02 | 192.168.50.12 | 3306 | 0 | Slave, Synced, Running
wbwsrep03 | 192.168.50.13 | 3306 | 0 | Master, Synced, Running
wbwsrep04 | 192.168.50.14 | 3306 | 0 | Slave, Synced, Running
-------------------+-----------------+-------+-------------+--------------------
29
New MaxScale 2.1
30
New MaxScale 2.1
• One of the big new features in 2.1 is the ability to add, remove and alter the server
definitions at runtime when one can starts MaxScale with a minimal configuration:
• After proper configurations to the Monitor, the listener for RWSplit can be created:
• Next step is to define the servers and link then to the monitor and service:
#: add a new monitor, stopped state after creation
maxadmin create monitor cluster-monitor mysqlmon
maxadmin alter monitor cluster-monitor user=maxuser password=maxpwd monitor_interval=1000
maxadmin restart monitor cluster-monitor
#: add the listener, no need of additional configs, started state
maxadmin create listener rwsplit-service rwsplit-listener 0.0.0.0 4006
#: add servers
maxadmin create server db-serv-west 172.0.10.2 3306
maxadmin create server db-serv-east 172.0.10.4 3306
#: link server, monitor and service
maxadmin add server db-serv-west cluster-monitor rwsplit-service
maxadmin add server db-serv-east cluster-monitor rwsplit-service
31
New MaxScale 2.1
• Cache
• The cache will now also be used and populated in a transaction that is not explicitly read
only, but only until the first statement that modifies the database is encountered:
• SELECT statements that refer to user or system variables are not cached;
• SELECT statements using functions whose result depend upon the current user or
context are not cached. Examples of such functions are USER(), RAND() or
CURRENT_TIME().
• Firewall Filter
• Prepared statements are now treated exactly like non-prepared statements.
• Statements can now be accepted/rejected based upon function usage.
32
New MaxScale 2.1
• ProxySQL performs slightly better then MaxScale 2.0 and MaxScale 2.1 performs better
than the both;
Source: https://mariadb.com/resources/blog/improving-performance-mariadb-maxscale 33
New MaxScale 2.1
• When connections grows largely, MaxScale 2.1 and ProxySQL are roughly on par;
Source: https://mariadb.com/resources/blog/improving-performance-mariadb-maxscale 34
New MaxScale 2.1
• The same here, MaxScale 2.1 and ProxySQL are roughly on par;
Source: https://mariadb.com/resources/blog/improving-performance-mariadb-maxscale 35
Thank you
Wagner Bianchi
Principal RDBA
wagner.bianchi@mariadb.com

More Related Content

PDF
ProxySQL High Avalability and Configuration Management Overview
PDF
Redo log improvements MYSQL 8.0
PDF
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
PDF
M|18 Architectural Overview: MariaDB MaxScale
PDF
binary log と 2PC と Group Commit
PPTX
re:Invent 2022 DAT326 Deep dive into Amazon Aurora and its innovations
PDF
ProxySQL and the Tricks Up Its Sleeve - Percona Live 2022.pdf
PDF
ProxySQL High Availability (Clustering)
ProxySQL High Avalability and Configuration Management Overview
Redo log improvements MYSQL 8.0
MySQL Database Architectures - MySQL InnoDB ClusterSet 2021-11
M|18 Architectural Overview: MariaDB MaxScale
binary log と 2PC と Group Commit
re:Invent 2022 DAT326 Deep dive into Amazon Aurora and its innovations
ProxySQL and the Tricks Up Its Sleeve - Percona Live 2022.pdf
ProxySQL High Availability (Clustering)

What's hot (20)

PDF
MySQL InnoDB Cluster - A complete High Availability solution for MySQL
PDF
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
PDF
MySQLレプリケーションあれやこれや
PDF
Maxscale_메뉴얼
PDF
MariaDB Galera Cluster - Simple, Transparent, Highly Available
PDF
Vacuum徹底解説
PDF
Mobageの技術を体験(MyDNS編)
PPTX
My sql failover test using orchestrator
PDF
MySQL Performance Tuning: Top 10 Tips
PDF
MySQL Administrator 2021 - 네오클로바
PPTX
MySQL8.0_performance_schema.pptx
PDF
InnoDb Vs NDB Cluster
PPT
Intro to MySQL Master Slave Replication
PDF
MySQL 상태 메시지 분석 및 활용
PDF
20180918_ops on azure-main
PDF
Maxscale switchover, failover, and auto rejoin
PPT
Galera Cluster Best Practices for DBA's and DevOps Part 1
PDF
MySQL on AWS RDS
PPTX
MySQL5.6でGTIDを試してそっと閉じた
PPTX
Maxscale 소개 1.1.1
MySQL InnoDB Cluster - A complete High Availability solution for MySQL
[오픈소스컨설팅]Day #1 MySQL 엔진소개, 튜닝, 백업 및 복구, 업그레이드방법
MySQLレプリケーションあれやこれや
Maxscale_메뉴얼
MariaDB Galera Cluster - Simple, Transparent, Highly Available
Vacuum徹底解説
Mobageの技術を体験(MyDNS編)
My sql failover test using orchestrator
MySQL Performance Tuning: Top 10 Tips
MySQL Administrator 2021 - 네오클로바
MySQL8.0_performance_schema.pptx
InnoDb Vs NDB Cluster
Intro to MySQL Master Slave Replication
MySQL 상태 메시지 분석 및 활용
20180918_ops on azure-main
Maxscale switchover, failover, and auto rejoin
Galera Cluster Best Practices for DBA's and DevOps Part 1
MySQL on AWS RDS
MySQL5.6でGTIDを試してそっと閉じた
Maxscale 소개 1.1.1
Ad

Similar to NY Meetup: Scaling MariaDB with Maxscale (20)

PDF
Using all of the high availability options in MariaDB
PDF
MySQL database replication
PPTX
User Camp High Availability Presentation
PPTX
ProxySQL for MySQL
PPTX
MySQL Replication Evolution -- Confoo Montreal 2017
PPTX
Getting the most out of MariaDB MaxScale
PPTX
MaxScale - The Pluggable Router
PPTX
ConFoo MySQL Replication Evolution : From Simple to Group Replication
PPTX
Deploying MariaDB databases with containers at Nokia Networks
PDF
Fortify aws aurora_proxy
PDF
What’s new in Galera 4
PPTX
NoSQL on MySQL - MySQL Document Store by Vadim Tkachenko
PDF
Galera Cluster 4 presentation at Percona Live Austin 2019
PDF
Les fonctionnalites mariadb
PPT
2010 12 mysql_clusteroverview
PDF
Basic MySQL Troubleshooting for Oracle Database Administrators
ODP
MySQL 101 PHPTek 2017
PPT
Maria db the new mysql (Colin Charles)
PDF
MariaDB 5.5 and what comes next - Percona Live NYC 2012
PDF
Percona Cluster with Master_Slave for Disaster Recovery
Using all of the high availability options in MariaDB
MySQL database replication
User Camp High Availability Presentation
ProxySQL for MySQL
MySQL Replication Evolution -- Confoo Montreal 2017
Getting the most out of MariaDB MaxScale
MaxScale - The Pluggable Router
ConFoo MySQL Replication Evolution : From Simple to Group Replication
Deploying MariaDB databases with containers at Nokia Networks
Fortify aws aurora_proxy
What’s new in Galera 4
NoSQL on MySQL - MySQL Document Store by Vadim Tkachenko
Galera Cluster 4 presentation at Percona Live Austin 2019
Les fonctionnalites mariadb
2010 12 mysql_clusteroverview
Basic MySQL Troubleshooting for Oracle Database Administrators
MySQL 101 PHPTek 2017
Maria db the new mysql (Colin Charles)
MariaDB 5.5 and what comes next - Percona Live NYC 2012
Percona Cluster with Master_Slave for Disaster Recovery
Ad

More from Wagner Bianchi (20)

PDF
Migrations from PLSQL and Transact-SQL - m18
PDF
Meetup São Paulo, Maxscale Implementação e Casos de Uso
PDF
Escalando o ambiente com MariaDB Cluster (Portuguese Edition)
PDF
Webinar: MariaDB Provides the Solution to Ease Multi-Source Replication
PDF
MySQL Multi-Source Replication for PL2016
PDF
MySQL 5.7 Multi-Source Replication
PDF
UNIFAL - MySQL 5.6 - Replicação
PDF
UNIFAL - MySQL Logs - 5.0/5.6
PDF
UNIFAL - MySQL Transações - 5.0/5.6
PDF
UNIFAL - MySQL Storage Engine - 5.0/5.6
PDF
UNIFAL - MySQL Views - 5.0/5.6
PDF
UNIFAL - MySQL Triggers - 5.0/5.6
PDF
UNIFAL - MySQL Stored Routines - 5.0/5.6
PDF
UNIFAL - MySQL Linguagem SQL Básico - 5.0/5.6
PDF
UNIFAL - MySQL & Vagrant (iniciando os trabalhos)
PDF
Wagner Bianchi, GUOB 2014 MySQL Cluster 7.3
PPTX
Introdução ao MySQL 5.6
PPT
Mysql for IBMers
PPT
InnoDB Plugin - II Fórum da Comunidade MySQL
PPTX
MySQL Cluster Product Overview
Migrations from PLSQL and Transact-SQL - m18
Meetup São Paulo, Maxscale Implementação e Casos de Uso
Escalando o ambiente com MariaDB Cluster (Portuguese Edition)
Webinar: MariaDB Provides the Solution to Ease Multi-Source Replication
MySQL Multi-Source Replication for PL2016
MySQL 5.7 Multi-Source Replication
UNIFAL - MySQL 5.6 - Replicação
UNIFAL - MySQL Logs - 5.0/5.6
UNIFAL - MySQL Transações - 5.0/5.6
UNIFAL - MySQL Storage Engine - 5.0/5.6
UNIFAL - MySQL Views - 5.0/5.6
UNIFAL - MySQL Triggers - 5.0/5.6
UNIFAL - MySQL Stored Routines - 5.0/5.6
UNIFAL - MySQL Linguagem SQL Básico - 5.0/5.6
UNIFAL - MySQL & Vagrant (iniciando os trabalhos)
Wagner Bianchi, GUOB 2014 MySQL Cluster 7.3
Introdução ao MySQL 5.6
Mysql for IBMers
InnoDB Plugin - II Fórum da Comunidade MySQL
MySQL Cluster Product Overview

Recently uploaded (20)

PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Big Data Technologies - Introduction.pptx
PDF
KodekX | Application Modernization Development
PDF
Review of recent advances in non-invasive hemoglobin estimation
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Electronic commerce courselecture one. Pdf
PPTX
A Presentation on Artificial Intelligence
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
cuic standard and advanced reporting.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
“AI and Expert System Decision Support & Business Intelligence Systems”
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Unlocking AI with Model Context Protocol (MCP)
MYSQL Presentation for SQL database connectivity
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Dropbox Q2 2025 Financial Results & Investor Presentation
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Big Data Technologies - Introduction.pptx
KodekX | Application Modernization Development
Review of recent advances in non-invasive hemoglobin estimation
The AUB Centre for AI in Media Proposal.docx
Advanced methodologies resolving dimensionality complications for autism neur...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Understanding_Digital_Forensics_Presentation.pptx
Electronic commerce courselecture one. Pdf
A Presentation on Artificial Intelligence
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
cuic standard and advanced reporting.pdf

NY Meetup: Scaling MariaDB with Maxscale

  • 1. Scaling Out MariaDB Server w/ MaxScale By Wagner Bianchi Principal RDBA wagner.bianchi@mariadb.com
  • 2. M|17 The Conrad Hotel, NYC April 11 - 12, 2017 m17.mariadb.com Promo code: BIGAPPLE
  • 3. Europe Roadshow
 Locations in May & June Berlin
 May 18 Munich
 May 11 Bonn
 June 30 Amsterdam
 May 23 Paris June 30 Madrid
 May 18 Milan May 11 Details and registration: http://go.mariadb.com/Europe-Roadshow-LP.html More dates and locations will be announced soon!
  • 4. Meetup’s Agenda • With MariaDB Server: • Replication::ReadWriteSplit; • Replication::ConnectionRouting; • Replication::SchemaRouter; • With MariaDB Cluster: • Configuring it as Master/Slave cluster • New features MaxScale 2.1 (coming soon) 4
  • 5. Scalability and, what are we talking about? 5
  • 7. MariaDB Server, Replication::ReadWriteSplit • The readwritesplit router is designed to increase the read-only processing capability of a cluster while maintaining consistency; • This is achieved by splitting the query load into read and write queries; • Read queries, which do not modify data, are spread across multiple nodes while all write queries will be sent to a single node; • This router is designed to be used with a traditional Master-Slave replication cluster; MaxScale> list servers Servers. -------------------+-----------------+-------+-------------+-------------------- Server | Address | Port | Connections | Status -------------------+-----------------+-------+-------------+-------------------- myrocksdb01 | 192.168.50.11 | 3306 | 0 | Master, Running myrocksdb02 | 192.168.50.12 | 3306 | 0 | Slave, Running myrocksdb03 | 192.168.50.13 | 3306 | 0 | Slave, Running -------------------+-----------------+-------+-------------+-------------------- 7
  • 8. MariaDB Server, Replication::ReadWriteSplit • The following operations are routed to master: • write statements; • all statements within an open transaction; • stored procedure calls, and user-defined function calls; • DDL statements (DROP|CREATE|ALTER TABLE … etc.); • EXECUTE (prepared) statements; • all statements using temporary tables. 8
  • 9. MariaDB Server, Replication::ReadWriteSplit • Queries which can be routed to slaves must be auto committed and belong to one of the following group: • read-only database queries; • read-only queries to system, or user-defined variables; • SHOW statements, and system function calls. • Slaves can be set as per max_slave_connections as it sets the maximum number of slaves a router session uses at any moment - default is all including master; • One can use router_options to remove current master to the current read pool; 9
  • 10. MariaDB Server, Replication::ReadWriteSplit • router_options • it may include multiple readwritesplit-specific options; • slave_selection_criteria, how requests will be sent to slaves; • LEAST_GLOBAL_CONNECTIONS, the slave with least connections from MariaDB MaxScale • LEAST_ROUTER_CONNECTIONS, the slave with least connections from this service • LEAST_BEHIND_MASTER, the slave with smallest replication lag • LEAST_CURRENT_OPERATIONS (default), the slave with least active operations 10
  • 11. MariaDB Server, Replication::ReadWriteSplit • router_options • master_accept_reads = [true|false] • the is the option that can include or remove master from the reading pool; • master_failure_mode • fail_instantly, when the failure of the master server is detected, the connection will be closed immediately. • fail_on_write, the client connection is closed if a write query is received when no master is available. • error_on_write, If no master is available and a write query is received, an error is returned stating that the connection is in read-only mode. 11
  • 12. MariaDB Server, Replication::ReadWriteSplit [myrocksdb03] type=server address=192.168.50.13 port=3306 protocol=MySQLBackend persistpoolmax=100 persistmaxtime=3600 [CLI] type=service router=cli [CLI Listener] type=listener service=CLI protocol=maxscaled socket=default [Splitter Service] type=service router=readwritesplit servers=myrocksdb01,myrocksdb02,myrocksdb03 router_options=slave_selection_criteria=LEAST _BEHIND_MASTER,master_accept_reads=FALSE,mast er_failure_mode=erro r_on_write max_slave_connections=2 max_slave_replication_lag=30 user=maxuser passwd=YqztlYG… [Splitter Listener] type=listener service=Splitter Service protocol=MySQLClient port=3306 socket=/tmp/myrocksdb_cluster.sock [Replication Monitor] type=monitor module=mysqlmon servers=myrocksdb01,myrocksdb02,myroc ksdb03 detect_replication_lag=1 detect_stale_master=1 user=maxuser passwd=YqztlYG… [myrocksdb01] type=server address=192.168.50.11 port=3306 protocol=MySQLBackend persistpoolmax=100 persistmaxtime=3600 [myrocksdb02] type=server address=192.168.50.12 port=3306 protocol=MySQLBackend persistpoolmax=100 persistmaxtime=3600 12
  • 13. MariaDB Server, Replication::ConnectionRoute Router • The readconnroute router provides simple and lightweight load balancing across a set of servers; • The router can also be configured to balance connections based on a weighting parameter defined in the server's section; • Differs from readwritesplit router as this router needs one port for reads and another one for writes and router_options can be used as well; • One can define a goos strategy here: • point the master directly on the maxscale’s configuration file for writes; • point the slaves for reads, in case a master crash, adjust configuration file and reload; 13
  • 14. MariaDB Server, Replication::ConnectionRoute Router • Let’s consider the following scenario: MaxScale> list servers Servers. -------------------+-----------------+-------+-------------+-------------------- Server | Address | Port | Connections | Status -------------------+-----------------+-------+-------------+-------------------- myrocksdb01 | 192.168.50.11 | 3306 | 0 | Master, Running myrocksdb02 | 192.168.50.12 | 3306 | 0 | Slave, Running myrocksdb03 | 192.168.50.13 | 3306 | 0 | Slave, Running -------------------+-----------------+-------+-------------+-------------------- MaxScale> list services Services. --------------------------+----------------------+--------+--------------- Service Name | Router Module | #Users | Total Sessions --------------------------+----------------------+--------+--------------- Write Service | readconnroute | 2 | 2 Read Service | readconnroute | 1 | 1 CLI | cli | 2 | 2 --------------------------+----------------------+--------+--------------- 14
  • 15. MariaDB Server, Replication::ConnectionRoute Router • Let’s shutdown current master: • We do the manual switch on the MariaDB server: • reset slave all; on myrocksdb02; • change master to master_host=‘myrocksdb02’; on myrocksdb03; • On Maxscale, comment server myrocksdb01, remove it form the list of servers on [Replication Monitor] and on Write Service, on the latter, put myrocksdb02; • set server myrocksdb02 master #: stop/crash current master [root@box01 ~]# systemctl stop mariadb #: maxscale logs Server 192.168.50.11:3306 lost the master status. Server changed state: myrocksdb01[192.168.50.11:3306]: master_down. [Master, Running] -> [Down] 15
  • 16. MariaDB Server, Replication::ConnectionRoute Router • After these… #: new scenario [root@maxscale maxscale_config]# maxadmin -e "list servers" Servers. -------------------+-----------------+-------+-------------+-------------------- Server | Address | Port | Connections | Status -------------------+-----------------+-------+-------------+-------------------- myrocksdb01 | 192.168.50.11 | 3306 | 0 | Down myrocksdb02 | 192.168.50.12 | 3306 | 0 | Master, Running myrocksdb03 | 192.168.50.13 | 3306 | 0 | Slave, Running -------------------+-----------------+-------+-------------+-------------------- #: maxscale logs Update server protocol for server 192.168.50.13 to protocol MySQLBackend. Update server protocol for server 192.168.50.12 to protocol MySQLBackend. Update router for service Read Service to readconnroute. Update router for service Write Service to readconnroute. Server changed state: myrocksdb02[192.168.50.12:3306]: new_slave. [Master, Slave, Running] -> [Slave, Running] 16
  • 17. MariaDB Server, Replication::ConnectionRoute Router • Configuration for readconnroute load balancer [Write Service] type=service router=readconnroute router_options=master servers=myrocksdb01 user=maxuser password=123456 [Read Service] type=service router=readconnroute router_options=slave servers=myrocksdb02,myrocksdb03 weightby=serv_weight user=maxuser password=123456 [Write Listener] type=listener service=Write Service protocol=MySQLClient port=33066 socket=/tmp/myrocksdb_readconnroute.sock [Read Listener] type=listener service=Read Service protocol=MySQLClient port=33077 [myrocksdb01] type=server address=192.168.50.11 port=3306 protocol=MySQLBackend [myrocksdb02] type=server address=192.168.50.12 port=3306 protocol=MySQLBackend serv_weight=3 [myrocksdb03] type=server address=192.168.50.13 port=3306 protocol=MySQLBackend serv_weight=2 17
  • 20. Scaling-Out MariaDB Cluster • MaxScale makes your life easier when working with MariaDB Cluster: • Checks on severs roles; • Setup monitors and trigger alerts from nodes status changes; • Transparently configure good practices in read/write split; • Elect new “master" node to receive write traffic; • Add a server under maintenance and clear up its status; • One can use Galera Monitor or the ReadWriteSplit Module for MariaDB Cluster: • Galera Monitor: http://bit.ly/2nshrOk • ReadWriteSplit: http://bit.ly/2oTPXxY 20
  • 21. Scaling-Out MariaDB Cluster • Galera Monitor: • The Galera Monitor is a monitoring module for MaxScale that monitors a Galera cluster; • It detects whether nodes are a part of the cluster and if they are in sync with the rest of the cluster; • It can also assign master and slave roles inside MaxScale, allowing Galera clusters to be used with modules designed for traditional master-slave clusters. 21
  • 22. Scaling-Out MariaDB Cluster • Listing servers: • Listing Monitors MaxScale> list servers Servers. -------------------+-----------------+-------+-------------+-------------------------- Server | Address | Port | Connections | Status -------------------+-----------------+-------+-------------+-------------------------- wbwsrep01 | 192.168.50.11 | 3306 | 0 | Master, Synced, Running wbwsrep02 | 192.168.50.12 | 3306 | 0 | Slave, Synced, Running wbwsrep03 | 192.168.50.13 | 3306 | 0 | Slave, Synced, Running -------------------+-----------------+-------+-------------+-------------------------- MaxScale> list monitors ---------------------+--------------------- Monitor | Status ---------------------+--------------------- Galera Monitor | Running ---------------------+--------------------- 22
  • 23. Scaling-Out MariaDB Cluster • Galera Monitor (or galeramon) • Avoid new master election by MaxScale when new server is added to the cluster with Galera’s monitor parameter: disable_master_failback=true • Use priority to give MaxScale and galeramon the ability to chose a new master in case current master is down: use_priority=true • If the SST method of your cluster is set to xtrabackup-v2 (wsrep_sst_method), this following parameter is interesting to avoid white flag alerts, as this is keep node’s status as Synced even being a Donor (DONOR/DESYNCED): available_when_donor=true 23
  • 24. Scaling-Out MariaDB Cluster • When using priorities to elect current master: [root@maxscale ~]# maxadmin -e "list servers" Servers. -------------------+-----------------+-------+-------------+-------------------- Server | Address | Port | Connections | Status -------------------+-----------------+-------+-------------+-------------------- wbwsrep01 | 192.168.50.11 | 3306 | 654 | Master, Synced, Running wbwsrep02 | 192.168.50.12 | 3306 | 76 | Slave, Synced, Running wbwsrep03 | 192.168.50.13 | 3306 | 89 | Slave, Synced, Running -------------------+-----------------+-------+-------------+-------------------- [root@maxscale ~]# vim /etc/maxscale.cnf # edited priorities [root@maxscale ~]# systemctl restart maxscale [root@maxscale ~]# maxadmin -e "list servers" Servers. -------------------+-----------------+-------+-------------+-------------------- Server | Address | Port | Connections | Status -------------------+-----------------+-------+-------------+-------------------- wbwsrep01 | 192.168.50.11 | 3306 | 78 | Slave, Synced, Running wbwsrep02 | 192.168.50.12 | 3306 | 3 | Slave, Synced, Running wbwsrep03 | 192.168.50.13 | 3306 | 12 | Master, Synced, Running -------------------+-----------------+-------+-------------+-------------------- 24
  • 25. Scaling-Out MariaDB Cluster • When using priorities to elect current master: #: monitor section [Galera Monitor] type=monitor module=galeramon servers=wbwsrep01,wbwsrep02,wbwsrep03 disable_master_failback=true available_when_donor=true use_priority=true user=maxmon passwd=123 #: servers section [wbwsrep01] type=server address=192.168.50.11 port=3306 protocol=MySQLBackend priority=3 [wbwsrep02] type=server address=192.168.50.12 port=3306 protocol=MySQLBackend priority=2 [wbwsrep03] type=server address=192.168.50.13 port=3306 protocol=MySQLBackend priority=1 25
  • 26. Scaling-Out MariaDB Cluster • In case you need to execute a current master’s restart: #: stop current master [root@box03 ~]# systemctl stop mariadb #: set current master in maintenance MaxScale> list servers Servers. -------------------+-----------------+-------+-------------+-------------------- Server | Address | Port | Connections | Status -------------------+-----------------+-------+-------------+-------------------- wbwsrep01 | 192.168.50.11 | 3306 | 72 | Slave, Synced, Running wbwsrep02 | 192.168.50.12 | 3306 | 327 | Master, Synced, Running wbwsrep03 | 192.168.50.13 | 3306 | 0 | Maintenance, Down —————————+-----------------+-------+-------------+-------------------- #: new master elected (checking logs - /var/log/maxscale/maxscale1.log) Server changed state: wbwsrep02[192.168.50.12:3306]: new_master. [Slave, Synced, Running] -> [Master, Synced, Running] Server changed state: wbwsrep03[192.168.50.13:3306]: master_down. [Master, Synced, Running] -> [Down] 26
  • 27. Scaling-Out MariaDB Cluster • When former master comes back online: #: when the former master comes back online, now as a slave due to monitor configs we applied MaxScale> list servers Servers. -------------------+-----------------+-------+-------------+-------------------- Server | Address | Port | Connections | Status -------------------+-----------------+-------+-------------+-------------------- wbwsrep01 | 192.168.50.11 | 3306 | 0 | Slave, Synced, Running wbwsrep02 | 192.168.50.12 | 3306 | 0 | Master, Synced, Running wbwsrep03 | 192.168.50.13 | 3306 | 0 | Maintenance, Down -------------------+-----------------+-------+-------------+-------------------- MaxScale> clear server wbwsrep03 maintenance MaxScale> list servers Servers. -------------------+-----------------+-------+-------------+-------------------- Server | Address | Port | Connections | Status -------------------+-----------------+-------+-------------+-------------------- wbwsrep01 | 192.168.50.11 | 3306 | 0 | Slave, Synced, Running wbwsrep02 | 192.168.50.12 | 3306 | 0 | Master, Synced, Master Stickiness, Running wbwsrep03 | 192.168.50.13 | 3306 | 0 | Slave, Synced, Running -------------------+-----------------+-------+-------------+-------------------- 27
  • 28. Scaling-Out MariaDB Cluster • Adding a new galera cluster's node: • Provision a new node on cluster level and go for the proper settings; • Raise the new node and make sure it’s part of the PRIMARY component; • Make sure the new node is in Sync status: • On MaxScale 2.0 config file: • Make sure you add the new [servername] entry on servers definition; • Make sure the Galera Service and the Galera Monitor lists the the servers name; • Use maxadmin -e “reload configs" #: tailing the log file after configurations and restart Server changed state: wbwsrep01[192.168.50.11:3306]: new_slave. [Running] -> [Slave, Synced, Running] Server changed state: wbwsrep02[192.168.50.12:3306]: new_slave. [Running] -> [Slave, Synced, Running] Server changed state: wbwsrep03[192.168.50.13:3306]: new_master. [Running] -> [Master, Synced, Running] Server changed state: wbwsrep04[192.168.50.14:3306]: new_slave. [Running] -> [Slave, Synced, Running] 28
  • 29. Scaling-Out MariaDB Cluster • The new scenario we have by now: #: listing servers again, with the new added one [root@maxscale ~]# maxadmin -e "list servers" Servers. -------------------+-----------------+-------+-------------+-------------------- Server | Address | Port | Connections | Status -------------------+-----------------+-------+-------------+-------------------- wbwsrep01 | 192.168.50.11 | 3306 | 0 | Slave, Synced, Running wbwsrep02 | 192.168.50.12 | 3306 | 0 | Slave, Synced, Running wbwsrep03 | 192.168.50.13 | 3306 | 0 | Master, Synced, Running wbwsrep04 | 192.168.50.14 | 3306 | 0 | Slave, Synced, Running -------------------+-----------------+-------+-------------+-------------------- 29
  • 31. New MaxScale 2.1 • One of the big new features in 2.1 is the ability to add, remove and alter the server definitions at runtime when one can starts MaxScale with a minimal configuration: • After proper configurations to the Monitor, the listener for RWSplit can be created: • Next step is to define the servers and link then to the monitor and service: #: add a new monitor, stopped state after creation maxadmin create monitor cluster-monitor mysqlmon maxadmin alter monitor cluster-monitor user=maxuser password=maxpwd monitor_interval=1000 maxadmin restart monitor cluster-monitor #: add the listener, no need of additional configs, started state maxadmin create listener rwsplit-service rwsplit-listener 0.0.0.0 4006 #: add servers maxadmin create server db-serv-west 172.0.10.2 3306 maxadmin create server db-serv-east 172.0.10.4 3306 #: link server, monitor and service maxadmin add server db-serv-west cluster-monitor rwsplit-service maxadmin add server db-serv-east cluster-monitor rwsplit-service 31
  • 32. New MaxScale 2.1 • Cache • The cache will now also be used and populated in a transaction that is not explicitly read only, but only until the first statement that modifies the database is encountered: • SELECT statements that refer to user or system variables are not cached; • SELECT statements using functions whose result depend upon the current user or context are not cached. Examples of such functions are USER(), RAND() or CURRENT_TIME(). • Firewall Filter • Prepared statements are now treated exactly like non-prepared statements. • Statements can now be accepted/rejected based upon function usage. 32
  • 33. New MaxScale 2.1 • ProxySQL performs slightly better then MaxScale 2.0 and MaxScale 2.1 performs better than the both; Source: https://mariadb.com/resources/blog/improving-performance-mariadb-maxscale 33
  • 34. New MaxScale 2.1 • When connections grows largely, MaxScale 2.1 and ProxySQL are roughly on par; Source: https://mariadb.com/resources/blog/improving-performance-mariadb-maxscale 34
  • 35. New MaxScale 2.1 • The same here, MaxScale 2.1 and ProxySQL are roughly on par; Source: https://mariadb.com/resources/blog/improving-performance-mariadb-maxscale 35
  • 36. Thank you Wagner Bianchi Principal RDBA wagner.bianchi@mariadb.com