percona live europe 2016 use proxysql to improve …percona live europe 2016 use proxysql to improve...
TRANSCRIPT
![Page 1: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/1.jpg)
Percona Live Europe 2016Use ProxySQL to Improve
Your MySQL High Availability Solution
Marco Tusa Manager ConsultingAmsterdam, Netherlands | October 3 – 5, 2016
![Page 2: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/2.jpg)
Percona Live 2017Use ProxySQL to Improve
Your MySQL High Availability Solution
Marco tusaSanta Clara, California | April 24th – 27th, 2017
![Page 3: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/3.jpg)
3
� Marco “The Grinch”• Open source enthusiast
About me
![Page 4: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/4.jpg)
4
•Brief ProxySQL introduction•How it interact Master-slave •How interact with PXC•Extending with scheduler•ProxySQL HA•Time cost
Agenda
![Page 5: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/5.jpg)
5
What is HA9 0. 0 0 0 % (36 days) MySQL Replication9 9. 9 0 0 % (8 hours) Linux Heartbeat with DRBD9 9. 9 0 0 % (8 hours) RHCS with Shared Storage (Active/Passive)9 9. 9 9 0 % (52 minutes) MHA with at least 3 nodes9 9. 9 9 0 % (52 minutes) Linux Heartbeat with DRBD and Replication9 9. 9 9 0 % (52 minutes) Linux Heartbeat with Shared Storage and Replication9 9 .9 9 5 % (26 minutes) Multi Master (galera - percona cluster) 3 node minimum9 9. 9 9 9 % (5 minutes) MySQL Cluster
![Page 6: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/6.jpg)
6
What is HA
![Page 7: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/7.jpg)
7
What is HA
![Page 8: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/8.jpg)
8
Who will save the Day?
![Page 9: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/9.jpg)
9
Who will save the Day?
![Page 10: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/10.jpg)
10
Objectively What we have is:
MySQL Group Replication
![Page 11: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/11.jpg)
11
The telephone game
![Page 12: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/12.jpg)
12
All talking
![Page 13: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/13.jpg)
13
Black box:
![Page 14: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/14.jpg)
14
Use the Right Tool for the Job…
![Page 15: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/15.jpg)
15
What we need
![Page 16: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/16.jpg)
16
MANAGEBLEFAST
SCALABLEFREE
Solution should be
![Page 17: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/17.jpg)
17
… and do the right thing!My Motto
![Page 18: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/18.jpg)
18
ProxySQL
![Page 19: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/19.jpg)
19
ProxySQL
![Page 20: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/20.jpg)
20
Understand the basics - what it does ...
Write / Read (Master/Slave)
Multiple WritersSharding &
Geographic Distribution
Traffic Load dispatch (aka Mirroring)
Query re-write
![Page 21: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/21.jpg)
21
Define UsersServers group by function
Host GroupsRules define what, where and how
Query RulesSpecial Grouping for Replication
Replication Host Group
Understand the basics – how this is done?
![Page 22: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/22.jpg)
22
HostGroup (HG) & Replication HG
Understand the basics
![Page 23: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/23.jpg)
23
Query rules
Understand the basics
![Page 24: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/24.jpg)
24
Scheduler
Understand the basics
![Page 25: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/25.jpg)
25
Basic scenario
HG: 10U: app_RW
HG: 11U: app_R
HG: 12U: ETL_R
![Page 26: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/26.jpg)
26
insert into mysql_users(username,password,active,default_hostgroup,default_schema) values ('app_RW','test',1,10,'test_schema');
insert into mysql_users(username,password,active,default_hostgroup,default_schema) values ('app_R','test',1,11,'test_schema');
insert into mysql_users
(username,password,active,default_hostgroup,default_schema) values ('etl_R','test',1,12,’etl_schema');LOAD MYSQL USERS TO RUNTIME;SAVE MYSQL USERS TO DISK;
Basic scenario - Users
![Page 27: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/27.jpg)
27
INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight) VALUES ('192.168.1.5',10,3306,1000);INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight, max_replication_lag) VALUES ('192.168.1.6',11,3306,10000,2);INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight, max_replication_lag) VALUES ('192.168.1.7',11,3306,10000,2);INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight, max_replication_lag) VALUES ('192.168.1.5',11,3306,1,2);INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight) VALUES ('192.168.1.8',12,3306,10);INSERT INTO mysql_replication_hostgroups VALUES (10,11);LOAD MYSQL SERVERS TO RUNTIME; SAVE MYSQL SERVERS TO DISK;
Basic scenario – Servers / HG
![Page 28: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/28.jpg)
28
insert into mysql_query_rules(username,destination_hostgroup,active,retries,match_digest,apply) values(’app_RW',10,1,3,'^SELECT.*FOR UPDATE',1); insert into mysql_query_rules(username,destination_hostgroup,active,retries,match_digest,apply) values(’app_RW',11,1,3,'^SELECT ',1); insert into mysql_query_rules (username,destination_hostgroup,active) values(’app_R',11,1);insert into mysql_query_rules (username,destination_hostgroup,active) values('etl_R',12,1);
LOAD MYSQL QUERY RULES TO RUNTIME;SAVE MYSQL QUERY RULES TO DISK;
Basic scenario – Query rules
![Page 29: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/29.jpg)
29
Basic scenario – with ProxySQL
Writes
ReadsReads
![Page 30: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/30.jpg)
30
READ_ONLY = 0 WRITE HGREAD_ONLY = 1 READ HG
ProxySQL – Replication HG – danger!
READ_ONLY=0 READ_ONLY=1 READ_ONLY=1
HG 10 & HG:11HG 11 HG 11
READ_ONLY=0
HG 10 & HG 11
![Page 31: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/31.jpg)
31
ProxySQL + MHA (or any controller)
Writes
ReadsReads
![Page 32: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/32.jpg)
32
No movable part like:
VIPDNS (Route 53 or similar)
No Crazy scripts to manage other proxy (ie HAProxy)
ProxySQL + MHA (or any controller)
![Page 33: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/33.jpg)
33
MHA discovery time (ping x 3 times) -> ~9 secMHA recovery (binlog) variable time
MHA Slave shift + Master READ-ONLY < 2 sec
ProxySQL will react as soon as READ_ONLY=0
What timing with MHA?
![Page 34: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/34.jpg)
34
Nothing all defaults
master_ip_failover_script=master_ip_failovermaster_ip_online_change_script=master_ip_online_change
Test it:masterha_master_switch --master_state=alive --conf=/etc/mha.cnf --orig_master_is_new_slave --interactive=0 --running_updates_limit=0
What is needed with MHA?
![Page 35: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/35.jpg)
35
Given no VIP or centralize element.
Consistent distributed behavior for HA?
![Page 36: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/36.jpg)
36
Integration with PXC\Galera
![Page 37: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/37.jpg)
37
Integration with PXC\Galera
![Page 38: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/38.jpg)
38
Integration with PXC\Galera
![Page 39: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/39.jpg)
39
Integration with PXC\Galera read_onlywsrep_statuswsrep_rejectquerieswsrep_donorrejectquerieswsrep_connectedwsrep_desinccountwsrep_readywsrep_providerwsrep_segmentNumber of nodes in by segmentRetry loop
Online Offline_softOffline_hardShunned
But we also have HostgroupsReplication HG
![Page 40: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/40.jpg)
40
Integration with PXC\Galera
![Page 41: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/41.jpg)
41
Integration with PXC\Galera
HG: 10
HG: 10
HG: 12HG: 11
HG: 11HG: 12
![Page 42: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/42.jpg)
42
Multiple writer vs Single writerMulti writer based on weight and Hostgroups
Need Replication HG and READ_ONLYFailover is done without the need of performing actions on the nodes
Failover is done modifying the READ_ONLY valueSingle WRITER node isolation not guarantee
Single WRITER node isolation is guarantee
Integration with PXC\Galera
![Page 43: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/43.jpg)
43
insert into mysql_users(username,password,active,default_hostgroup,default_schema) values ('app_RW','test',1,10,'test_schema');
insert into mysql_users(username,password,active,default_hostgroup,default_schema) values ('app_R','test',1,11,'test_schema');
insert into mysql_users
(username,password,active,default_hostgroup,default_schema) values (‘appDR_R','test',1,12,’etl_schema');LOAD MYSQL USERS TO RUNTIME;SAVE MYSQL USERS TO DISK;
Integration with PXC\Galera - Users
![Page 44: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/44.jpg)
44
insert into mysql_query_rules(username,destination_hostgroup,active,retries,match_digest,apply) values(’app_RW',10,1,3,'^SELECT.*FOR UPDATE',1);
insert into mysql_query_rules(username,destination_hostgroup,active,retries,match_digest,apply) values(’app_RW',11,1,3,'^SELECT ',1);
insert into mysql_query_rules (username,destination_hostgroup,active) values(’app_R',11,1);
insert into mysql_query_rules (username,destination_hostgroup,active) values(‘appDR_R',12,1);LOAD MYSQL QUERY RULES TO RUNTIME;SAVE MYSQL QUERY RULES TO DISK;
Integration with PXC\Galera – QR
![Page 45: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/45.jpg)
45
INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight)
VALUES ('192.168.1.5',10,3306,50000);192.168.1.6 … 10000; 192.168.1.7 … 10
INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight)
VALUES ('192.168.1.5',11,3306,1);192.168.1.6 … 30000; 192.168.1.7 … 30000
INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight) VALUES ('192.168.1.8',12,3306,100);192.168.1.9 … 100;LOAD MYSQL SERVERS TO RUNTIME; SAVE MYSQL SERVERS TO DISK;
Integration with PXC\Galera – HG MW
![Page 46: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/46.jpg)
46
INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight) VALUES
('192.168.1.5',10,3306,100);
INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight) VALUES
('192.168.1.5',11,3306,1);INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight) VALUES
('192.168.1.6',11,3306,100);INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight) VALUES ('192.168.1.7',11,3306,100);
INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight) VALUES ('192.168.1.8',12,3306,100);192.168.1.9 … 100;INSERT INTO mysql_replication_hostgroups VALUES (10,11);LOAD MYSQL SERVERS TO RUNTIME; SAVE MYSQL SERVERS TO DISK;
Integration with PXC\Galera HG SW
![Page 47: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/47.jpg)
47
ProxySQL is configured Now what?
Example scripthttps://github.com/Tusamarco/proxy_sql_toolsFull guide: https://goo.gl/vcDFZx
Integration with PXC
![Page 48: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/48.jpg)
48
Set the script:INSERT INTO scheduler (id,active,interval_ms,filename,arg1) values (10,0,2000,"/var/lib/proxysql/galera_check.pl","-u=admin -p=admin -h=192.168.1.50 -H=500:W,501:R -P=3310 --execution_time=1 --retry_down=2 --retry_up=1 --main_segment=1 --debug=0 --log=/var/lib/proxysql/galeraLog");LOAD SCHEDULER TO RUNTIME;SAVE SCHEDULER TO DISK;
update scheduler set active=1 where id=10;LOAD SCHEDULER TO RUNTIME;
Integration with PXC
![Page 49: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/49.jpg)
49
+--------------+-------------+--------+------------+---------+
| hostgroup_id | hostname | status | weight | comment |+--------------+-------------+--------+------------+---------+
| 10 | 192.168.1.5 | ONLINE | 50000 | || 10 | 192.168.1.6 | ONLINE | 10000 | |
| 10 | 192.168.1.7 | ONLINE | 10 | |
| 11 | 192.168.1.5 | ONLINE | 1 | || 11 | 192.168.1.6 | ONLINE | 10000 | |
| 11 | 192.168.1.7 | ONLINE | 10000 | || 12 | 192.168.1.8 | ONLINE | 100 | |
| 12 | 192.168.1.9 | ONLINE | 100 | |+--------------+-------------+--------+------------+---------+
Integration with PXC MW
![Page 50: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/50.jpg)
50
+--------------+-------------+--------+------------+---------+
| hostgroup_id | hostname | status | weight | comment |+--------------+-------------+--------+------------+---------+
| 10 | 192.168.1.5 |OFFLINE_SOFT | 50000 | 10_W_11_R_retry_up=0;10_W_11_R_retry_down=0; | 10 | 192.168.1.6 | ONLINE | 10000 | |
| 10 | 192.168.1.7 | ONLINE | 10 | || 11 | 192.168.1.5 | OFFLINE_SOFT | 1 | ... |
| 11 | 192.168.1.6 | ONLINE | 10000 | || 11 | 192.168.1.7 | ONLINE | 10000 | |
| 12 | 192.168.1.8 | ONLINE | 100 | |
| 12 | 192.168.1.9 | ONLINE | 100 | |+--------------+-------------+--------+------------+---------+
Integration with PXC MW
![Page 51: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/51.jpg)
51
+---------------------------------+-------+| Variable_name | Value |+---------------------------------+-------+| wsrep_sst_donor_rejects_queries | ON |+---------------------------------+-------+
ProxySQL Think all is ok
Application writes will fail
Integration with PXC MW
![Page 52: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/52.jpg)
52
+--------------+-------------+--------+------------+---------+
| hostgroup_id | hostname | status | weight | comment |+--------------+-------------+--------+------------+---------+
| 10 | 192.168.1.6 | ONLINE | 10000 | || 10 | 192.168.1.7 | ONLINE | 10 | |
| 11 | 192.168.1.6 | ONLINE | 100000 | |
| 11 | 192.168.1.7 | ONLINE | 100000 | || 12 | 192.168.1.8 | ONLINE | 100 | |
| 12 | 192.168.1.9 | ONLINE | 100 | || 9010 | 192.168.1.5 | ONLINE | 50000 | || 9011 | 192.168.1.5 | ONLINE | 1 | |+--------------+-------------+--------+------------+---------+
Integration with PXC MW
![Page 53: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/53.jpg)
53
WRITE Fail-over is automatically perform by ProxySQL
following the weightUntil an active node exists the HG
Integration with PXC MW
![Page 54: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/54.jpg)
54
WRITE Fail-over will not happen
Until READ_ONLY variableis modified on a reader HG node.
WRITER if DONOR will never be OFFLINE_SOFT
Integration with PXC SW
![Page 55: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/55.jpg)
55
Integration with PXC\Galera SW manual
![Page 56: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/56.jpg)
56
Integration with PXC\Galera SW Auto
![Page 57: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/57.jpg)
57
Change state to:OFFLINE_SOFT = ~2 secHostGroup 9000 = ~2 secProxySQL Shunned = ~1.2 sec (5 fails in 1sec)Failover (auto) = ~3 sec
Integration with PXC - Timing
![Page 58: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/58.jpg)
58
Avoid SPOF
![Page 59: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/59.jpg)
59
Avoid SPOF using Keepalived
![Page 60: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/60.jpg)
60
Avoid SPOF using Keepalived
![Page 61: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/61.jpg)
61
Cost in time
![Page 62: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/62.jpg)
62
Cost in time
![Page 63: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/63.jpg)
63
So what.. 9 0. 0 0 0 % (36 days) MySQL Replication9 9. 9 0 0 % (8 hours) Linux Heartbeat with DRBD9 9. 9 0 0 % (8 hours) RHCS with Shared Storage (Active/Passive)9 9. 9 9 0 % (52 minutes) MHA with at least 3 nodes9 9. 9 9 0 % (52 minutes) Linux Heartbeat with DRBD and Replication9 9. 9 9 0 % (52 minutes) Linux Heartbeat with Shared Storage and Replication9 9 .9 9 5 % (26 minutes) Multi Master (galera - perconacluster) 3 node minimum9 9. 9 9 9 % (5 minutes) MySQL Cluster
![Page 64: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/64.jpg)
64
Cost in $$$
![Page 65: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/65.jpg)
65
Improve service flexibility with r/w split;Allow simple way to manage access to specific servers by
usage (like DW-ETL);Implement sharding;
Allow Query revrite/query fix/blocking without need to modify code;
Improve failover time;Reduce master downtime impact on reads;
Not SPOF (as vip)
Brief summary
![Page 66: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/66.jpg)
66
Integration with MHA
![Page 67: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/67.jpg)
67
![Page 68: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/68.jpg)
68
![Page 69: Percona Live Europe 2016 Use ProxySQL to Improve …Percona Live Europe 2016 Use ProxySQL to Improve Your MySQL High Availability Solution Marco Tusa Manager Consulting Amsterdam,](https://reader030.vdocuments.net/reader030/viewer/2022011901/5f069f897e708231d418e9da/html5/thumbnails/69.jpg)
69
ContactsTo contact Me
To follow me
http://www.tusacentral.net/
http://www.percona.com/blog/
https://www.facebook.com/marco.tusa.94
@marcotusa
http://it.linkedin.com/in/marcotusa/
“Consulting = No mission refused!”