Presentation shows how ProxySQL can improve the HA in solution like MySQL async and sync replication without the need to increase the platform complexity.
Digital collaboration with Microsoft 365 as extension of Drupal
Proxysql ha plam_2016_2_keynote
1. Percona Live Europe 2016
Use ProxySQL to Improve Your
MySQL High Availability Solution
Marco Tusa Manager Consulting
Amsterdam, Netherlands | October 3 – 5, 2016
31. 15
Servers group by function
Host Groups
Understand the basics – how this is done?
32. 15
Servers group by function
Host Groups
Rules define what, where and how
Understand the basics – how this is done?
33. 15
Servers group by function
Host Groups
Rules define what, where and how
Query Rules
Understand the basics – how this is done?
34. 15
Servers group by function
Host Groups
Rules define what, where and how
Query Rules
Special Grouping for Replication
Understand the basics – how this is done?
35. 15
Servers group by function
Host Groups
Rules define what, where and how
Query Rules
Special Grouping for Replication
Replication Host Group
Understand the basics – how this is done?
42. 20
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
43. 21
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,1000000,2);
INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight,
max_replication_lag) VALUES ('192.168.1.7',11,3306,1000000,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
44. 22
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
58. 26
No movable part like:
VIP
DNS (Route 53 or similar)
ProxySQL + MHA (or any controller)
59. 26
No movable part like:
VIP
DNS (Route 53 or similar)
No Crazy scripts to manage other proxy (ie HAProxy)
ProxySQL + MHA (or any controller)
60. 26
No movable part like:
VIP
DNS (Route 53 or similar)
No Crazy scripts to manage other proxy (ie HAProxy)
Better distributed HA
ProxySQL + MHA (or any controller)
63. 27
MHA discovery time (ping x 3 times) -> ~9 sec
MHA recovery (binlog) variable time
What timing with MHA?
64. 27
MHA discovery time (ping x 3 times) -> ~9 sec
MHA recovery (binlog) variable time
MHA Slave shift + Master READ-ONLY < 2 sec
What timing with MHA?
65. 27
MHA discovery time (ping x 3 times) -> ~9 sec
MHA 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?
81. 35
Multiple writer vs Single writer
Multi writer based on weight and Hostgroups
Integration with PXCGalera
82. 35
Multiple writer vs Single writer
Multi writer based on weight and Hostgroups
Need Replication HG and READ_ONLY
Integration with PXCGalera
83. 35
Multiple writer vs Single writer
Multi writer based on weight and Hostgroups
Need Replication HG and READ_ONLY
Failover is done without the need of performing actions on
the nodes
Integration with PXCGalera
84. 35
Multiple writer vs Single writer
Multi writer based on weight and Hostgroups
Need Replication HG and READ_ONLY
Failover is done without the need of performing actions on
the nodes
Failover is done modifying the READ_ONLY value
Integration with PXCGalera
85. 35
Multiple writer vs Single writer
Multi writer based on weight and Hostgroups
Need Replication HG and READ_ONLY
Failover is done without the need of performing actions on
the nodes
Failover is done modifying the READ_ONLY value
Single WRITER node isolation not guarantee
Integration with PXCGalera
86. 35
Multiple writer vs Single writer
Multi writer based on weight and Hostgroups
Need Replication HG and READ_ONLY
Failover is done without the need of performing actions on
the nodes
Failover is done modifying the READ_ONLY value
Single WRITER node isolation not guarantee
Single WRITER node isolation is guarantee
Integration with PXCGalera
87. 36
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 PXCGalera - Users
88. 37
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 PXCGalera – QR
89. 38
INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight)
VALUES ('192.168.1.5',10,3306,1000000000);
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 … 100000; 192.168.1.7 … 100000
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 PXCGalera – HG MW
90. 39
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 PXCGalera HG SW
93. 40
ProxySQL is configured Now what?
Example script
https://github.com/Tusamarco/proxy_sql_tools
Full guide: https://goo.gl/vcDFZx
Integration with PXC
94. 41
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
99. 44
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| wsrep_sst_donor_rejects_queries | ON |
+---------------------------------+-------+
ProxySQL Think all is ok
Application writes will fail
Integration with PXC MW
102. 47
WRITE Fail-over
will not happen
Until READ_ONLY variable
is modified on a reader HG node.
WRITER if DONOR
will never be OFFLINE_SOFT
Integration with PXC SW
120. 55
Improve service flexibility with r/w split;
Allow simple way to manage access to specific servers by
usage (like DW-ETL);
Brief summary
121. 55
Improve service flexibility with r/w split;
Allow simple way to manage access to specific servers by
usage (like DW-ETL);
Implement sharding;
Brief summary
122. 55
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;
Brief summary
123. 55
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;
Brief summary
124. 55
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;
Brief summary
125. 55
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