SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Downloaden Sie, um offline zu lesen
© 2019 Percona1
Vinicius M. Grippa
Brothers in Arms: Using ProxySQL + PXC
Ensuring transparent high availability and scalability for your application
Support Engineer for MySQL / MongoDB
© 2019 Percona2
About Percona
▪ Solutions for your success with MySQL, MongoDB, and PostgreSQL
▪ Support, Consulting, Managed Services, and Software
▪ Our Software is 100% Open Source and Free
▪ Support Broad Ecosystem
▪ MySQL, MariaDB, Amazon RDS, and others
▪ In Business for 12 years
▪ More than 3000 customers, including top Internet companies and
enterprises
© 2019 Percona3
About me
▪ Support Engineer at Percona since 2017
▪ Working with MySQL for over 6 years
▪ Working with Databases for over 9 years
▪ Speaker at Percona Live
© 2019 Percona4
Percona XtraDB Cluster
© 2019 Percona5
Traditional MySQL replication
- Replication delay
- Switchover interval
- Single point of failure
- Data integrity problem
© 2019 Percona6
PXC/Galera
- All nodes can act as a master
- Data integrity
- Synchronous replication
- Read scalability
© 2019 Percona7
Automatic Node Provisioning
- Bootstrapping cluster
- SST (Snapshot State Transfer)
(rsync, xtrabackup, mysqldump)
- IST(incremental state transfer)
Auto-catchup cluster state
© 2019 Percona8
Workload Conflict
- Brute force abort
- Forceful abort of conflicting
transaction
- Certification failure
© 2019 Percona9
Flow Control
- Trx are queued. Queue full can cause
flow-control
- Dynamic Control of the workload
© 2019 Percona10
Cluster-safe-mode
- Workload that is not safe to the
cluster
- Pxc_strict_mode
(Enforcing,
Master,
Permissive,
Disabled)
© 2019 Percona11
Load Balancer
- PXC can operate with multiple load
balancers (HA Proxy, ProxySQL,
etc…)
- PXC suggests ProxySQL
- Integrated and close
development
- Feature rich load balancer
© 2019 Percona12
ProxySQL 2.0
© 2019 Percona13
ProxySQL Features
•Query Caching
•Query Routing
•Firewall
•Advanced configuration with 0 downtime
•ProxySQL cluster
•Open source :)
© 2019 Percona14
ProxySQL topology
© 2019 Percona15
ProxySQL topology
© 2019 Percona16
ProxySQL topology
© 2019 Percona17
ProxySQL 2.0
•ProxySQL v2.0 has native support for Galera Clustering (In previous versions of
ProxySQL an external scheduler was required to track the status of Galera nodes)
•Introduces mysql_galera_hostgroups and
mysql_server_galera_log tables
© 2019 Percona18
ProxySQL Configuration
© 2019 Percona19
ProxySQL Example
IPs
172.16.2.181 - node3
172.16.1.54 - node2
172.16.3.136 - node1
Hostgroups
Writer HG-> 100
Reader HG-> 101
BackupW HG-> 102
offHG HG-> 9101
© 2019 Percona20
ProxySQL Example
Servers first:
INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight)
VALUES ('172.16.2.181',101,3306,1000);
INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight)
VALUES ('172.16.1.54',101,3306,100);
INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight)
VALUES ('172.16.3.136',101,3306,100);
save mysql servers to disk;
load mysql servers to runtime;
© 2019 Percona21
ProxySQL Example
Creating user (it is necessary to create the user on PXC as well):
insert into mysql_users (username,
password,default_hostgroup) values ('app_test','app_test',
100);
load mysql users to runtime;
save mysql users from runtime;
save mysql users to disk;
© 2019 Percona22
ProxySQL Example
Creating Rules:
insert into mysql_query_rules
(rule_id,proxy_port,schemaname,username,destination_hostgroup,active,
retries,match_digest,apply)
values(1040,6033,'*','app_test',100,1,3,'^SELECT.*FOR UPDATE',1);
insert into mysql_query_rules
(rule_id,proxy_port,schemaname,username,destination_hostgroup,active,
retries,match_digest,apply)
values(1041,6033,'*','app_test',101,1,3,'^SELECT.*@@',1);
save mysql query rules to disk;
load mysql query rules to run;
© 2019 Percona23
ProxySQL Example
Then the galera settings:
insert into mysql_galera_hostgroups
(writer_hostgroup,backup_writer_hostgroup,reader_hostgroup,
offline_hostgroup,active,max_writers,writer_is_also_reader,ma
x_transactions_behind) values (100,102,101,9101,0,1,1,16);
# max_transactions_behind - determines the maximum number of writesets
behind the cluster that ProxySQL should allow before shunning the node to
prevent stale reads (this is determined by querying the
wsrep_local_recv_queue Galera variable).
© 2019 Percona24
ProxySQL Example
Setting version:
update global_variables set variable_value='5.7.25' where
variable_name='mysql-server_version';
LOAD MYSQL VARIABLES TO RUNTIME;SAVE MYSQL VARIABLES TO DISK;
© 2019 Percona25
ProxySQL Example
Create monitor user on MySQL and adjust on ProxySQL:
UPDATE global_variables SET variable_value='admin'WHERE
variable_name='mysql-monitor_username';
UPDATE global_variables SET variable_value='admin'WHERE
variable_name='mysql-monitor_password';
© 2019 Percona26
ProxySQL Example
PXC: admin@127.0.0.1 ((none)) > select * from
runtime_mysql_galera_hostgroups G
*************************** 1. row ***************************
writer_hostgroup: 100
backup_writer_hostgroup: 102
reader_hostgroup: 101
offline_hostgroup: 9101
active: 0 ← https://github.com/sysown/proxysql/issues/1902
max_writers: 1
writer_is_also_reader: 1
max_transactions_behind: 16
comment: NULL
1 row in set (0.01 sec)
© 2019 Percona27
ProxySQL+PXC Features
PXC: root@localhost ((none)) > set global pxc_maint_mode = maintenance;
# Sends a shutdown signal
$ systemctl stop mysqld
© 2019 Percona28
ProxySQL Features
PXC: admin@127.0.0.1 ((none)) > select hostgroup_id,hostname,status from
runtime_mysql_servers;
+--------------+--------------+---------+
| hostgroup_id | hostname | status |
+--------------+--------------+---------+
| 101 | 172.16.2.181 | ONLINE |
| 9101 | 172.16.1.54 | SHUNNED |
| 9101 | 172.16.3.136 | SHUNNED |
| 100 | 172.16.2.181 | ONLINE |
+--------------+--------------+---------+
4 rows in set (0.00 sec)
© 2019 Percona29
ProxySQL Features
© 2019 Percona30
Compile
yum install make cmake gcc gcc-c++ epel-release
https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm git wget zlib-devel openssl-devel
yum --disablerepo=mysql80-community --enablerepo=mysql57-community install mysql-community-libs-compat.x86_64
boost-devel.x86_64 mysql-community-devel
cd /usr/include/mysql
MYSQL_VERSION=$(rpm -qa | grep mysql-community-devel | awk -F'-' '{print $4}')
wget https://raw.githubusercontent.com/mysql/mysql-server/mysql-${MYSQL_VERSION}/include/hash.h
cd
git clone https://github.com/sysown/proxysql_mysqlbinlog.git
cd proxysql_mysqlbinlog
cd libslave/
cmake . && make
cd ..
ln -s /usr/lib64/mysql/libmysqlclient.a /usr/lib64/libmysqlclient.a
make
ProxySQL Features
© 2019 Percona31
Run
yum install epel-release
yum install boost-system
./proxysql_binlog_reader -h 127.0.0.1 -u root -psekret -P 3306 -l 3307 -L binlogreader.log
ProxySQL Features
© 2019 Percona32
PMM + ProxySQL + PXC
# ProxySQL
https://pmmdemo.percona.com/graph/d/fwWR9oiiz/proxysql-overview?refresh=1m&
orgId=1
#PXC
https://pmmdemo.percona.com/graph/d/s_k9wGNiz/pxc-galera-cluster-overview?refr
esh=1m&orgId=1
© 2019 Percona33
Questions?
© 2019 Percona34
© 2019 Percona35
● Write for our community blog
percona.com/community-blog
● Join in with our community forums
percona.com/forums
● Contribute to our open source projects
Join in: Percona Community
© 2019 Percona36
We are hiring!
● We are a remote first company
● Current EMEA roles: Database QA Engineer,
DevOps/QA Engineer, Golang and Kubernetes Software
Engineer, Senior MySQL DBA, C/C++ Software Engineer,
Solution Engineer, MongoDB Technical Lead, MySQL DBA,
UK Enterprise Sales, Director Marketing Communications,
Director Marketing Operations
● We offer $1000 for successful referrals
● See percona.com/careers for more info or talk to us today!
DATABASE PERFORMANCE
MATTERS
Database Performance MattersDatabase Performance MattersDatabase Performance MattersDatabase Performance Matters
Champions of Unbiased
Open Source Database Solutions

Weitere ähnliche Inhalte

Was ist angesagt?

Lab 10 instruction 2017
Lab 10 instruction   2017Lab 10 instruction   2017
Lab 10 instruction 2017
trayyoo
 
Whitepaper MS SQL Server on Linux
Whitepaper MS SQL Server on LinuxWhitepaper MS SQL Server on Linux
Whitepaper MS SQL Server on Linux
Roger Eisentrager
 
Redis学习笔记
Redis学习笔记Redis学习笔记
Redis学习笔记
yongboy
 
Mysql Fun
Mysql FunMysql Fun
Mysql Fun
SHC
 
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
maclean liu
 
Installation of pfSense on Soekris 6501
Installation of pfSense on Soekris 6501Installation of pfSense on Soekris 6501
Installation of pfSense on Soekris 6501
robertguerra
 

Was ist angesagt? (20)

Lab 10 instruction 2017
Lab 10 instruction   2017Lab 10 instruction   2017
Lab 10 instruction 2017
 
Install elasticsearch, logstash and kibana
Install elasticsearch, logstash and kibana Install elasticsearch, logstash and kibana
Install elasticsearch, logstash and kibana
 
Percona Xtrabackup Best Practices
Percona Xtrabackup Best PracticesPercona Xtrabackup Best Practices
Percona Xtrabackup Best Practices
 
Whitepaper MS SQL Server on Linux
Whitepaper MS SQL Server on LinuxWhitepaper MS SQL Server on Linux
Whitepaper MS SQL Server on Linux
 
Site-to-Site IPSEC VPN Between Cisco ASA and Pfsense
Site-to-Site IPSEC VPN Between Cisco ASA and PfsenseSite-to-Site IPSEC VPN Between Cisco ASA and Pfsense
Site-to-Site IPSEC VPN Between Cisco ASA and Pfsense
 
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
Nginx A High Performance Load Balancer, Web Server & Reverse ProxyNginx A High Performance Load Balancer, Web Server & Reverse Proxy
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
 
Query logging with proxysql
Query logging with proxysqlQuery logging with proxysql
Query logging with proxysql
 
MySQL Group Replicatio in a nutshell - MySQL InnoDB Cluster
MySQL Group Replicatio  in a nutshell - MySQL InnoDB ClusterMySQL Group Replicatio  in a nutshell - MySQL InnoDB Cluster
MySQL Group Replicatio in a nutshell - MySQL InnoDB Cluster
 
[OpenStack 하반기 스터디] HA using DVR
[OpenStack 하반기 스터디] HA using DVR[OpenStack 하반기 스터디] HA using DVR
[OpenStack 하반기 스터디] HA using DVR
 
Redis学习笔记
Redis学习笔记Redis学习笔记
Redis学习笔记
 
Mysql Fun
Mysql FunMysql Fun
Mysql Fun
 
High Availability Content Caching with NGINX
High Availability Content Caching with NGINXHigh Availability Content Caching with NGINX
High Availability Content Caching with NGINX
 
NGINX: High Performance Load Balancing
NGINX: High Performance Load BalancingNGINX: High Performance Load Balancing
NGINX: High Performance Load Balancing
 
NGINX: Basics & Best Practices - EMEA Broadcast
NGINX: Basics & Best Practices - EMEA BroadcastNGINX: Basics & Best Practices - EMEA Broadcast
NGINX: Basics & Best Practices - EMEA Broadcast
 
Mysql master slave setup
Mysql master slave setupMysql master slave setup
Mysql master slave setup
 
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
图文详解安装Net backup 6.5备份恢复oracle 10g rac 数据库
 
NAT with ASA & ASA Security Context
NAT with ASA & ASA Security ContextNAT with ASA & ASA Security Context
NAT with ASA & ASA Security Context
 
OTRS
OTRSOTRS
OTRS
 
Rate Limiting with NGINX and NGINX Plus
Rate Limiting with NGINX and NGINX PlusRate Limiting with NGINX and NGINX Plus
Rate Limiting with NGINX and NGINX Plus
 
Installation of pfSense on Soekris 6501
Installation of pfSense on Soekris 6501Installation of pfSense on Soekris 6501
Installation of pfSense on Soekris 6501
 

Ähnlich wie Proxy SQL 2.0 with PXC

The State of the Dolphin, MySQL Keynote at Percona Live Europe 2019, Amsterda...
The State of the Dolphin, MySQL Keynote at Percona Live Europe 2019, Amsterda...The State of the Dolphin, MySQL Keynote at Percona Live Europe 2019, Amsterda...
The State of the Dolphin, MySQL Keynote at Percona Live Europe 2019, Amsterda...
Geir Høydalsvik
 

Ähnlich wie Proxy SQL 2.0 with PXC (20)

Deploying Percona XtraDB Cluster in Openshift
Deploying Percona XtraDB Cluster in OpenshiftDeploying Percona XtraDB Cluster in Openshift
Deploying Percona XtraDB Cluster in Openshift
 
Guob - MySQL e LGPD
Guob - MySQL e LGPDGuob - MySQL e LGPD
Guob - MySQL e LGPD
 
ProxySQL para mysql
ProxySQL para mysqlProxySQL para mysql
ProxySQL para mysql
 
How to upgrade like a boss to MySQL 8.0 - PLE19
How to upgrade like a boss to MySQL 8.0 -  PLE19How to upgrade like a boss to MySQL 8.0 -  PLE19
How to upgrade like a boss to MySQL 8.0 - PLE19
 
The State of the Dolphin, MySQL Keynote at Percona Live Europe 2019, Amsterda...
The State of the Dolphin, MySQL Keynote at Percona Live Europe 2019, Amsterda...The State of the Dolphin, MySQL Keynote at Percona Live Europe 2019, Amsterda...
The State of the Dolphin, MySQL Keynote at Percona Live Europe 2019, Amsterda...
 
Intro ProxySQL
Intro ProxySQLIntro ProxySQL
Intro ProxySQL
 
How to upgrade like a boss to my sql 8.0?
How to upgrade like a boss to my sql 8.0?How to upgrade like a boss to my sql 8.0?
How to upgrade like a boss to my sql 8.0?
 
Mysql 8 vs Mariadb 10.4 Webinar 2020 Feb
Mysql 8 vs Mariadb 10.4 Webinar 2020 FebMysql 8 vs Mariadb 10.4 Webinar 2020 Feb
Mysql 8 vs Mariadb 10.4 Webinar 2020 Feb
 
Securing Big Data at rest with encryption for Hadoop, Cassandra and MongoDB o...
Securing Big Data at rest with encryption for Hadoop, Cassandra and MongoDB o...Securing Big Data at rest with encryption for Hadoop, Cassandra and MongoDB o...
Securing Big Data at rest with encryption for Hadoop, Cassandra and MongoDB o...
 
HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18HandsOn ProxySQL Tutorial - PLSC18
HandsOn ProxySQL Tutorial - PLSC18
 
NoSQL on MySQL - MySQL Document Store by Vadim Tkachenko
NoSQL on MySQL - MySQL Document Store by Vadim TkachenkoNoSQL on MySQL - MySQL Document Store by Vadim Tkachenko
NoSQL on MySQL - MySQL Document Store by Vadim Tkachenko
 
OSMC 2022 | Ignite: Observability with Grafana & Prometheus for Kafka on Kube...
OSMC 2022 | Ignite: Observability with Grafana & Prometheus for Kafka on Kube...OSMC 2022 | Ignite: Observability with Grafana & Prometheus for Kafka on Kube...
OSMC 2022 | Ignite: Observability with Grafana & Prometheus for Kafka on Kube...
 
PartnerSkillUp_Enable a Streaming CDC Solution
PartnerSkillUp_Enable a Streaming CDC SolutionPartnerSkillUp_Enable a Streaming CDC Solution
PartnerSkillUp_Enable a Streaming CDC Solution
 
Introduction to Vitess on Kubernetes for MySQL - Webinar
Introduction to Vitess on Kubernetes for MySQL -  WebinarIntroduction to Vitess on Kubernetes for MySQL -  Webinar
Introduction to Vitess on Kubernetes for MySQL - Webinar
 
stackconf 2020 | The Path to OpenSource DBaaS with Kubernetes by Peter Zaitsev
stackconf 2020 | The Path to OpenSource DBaaS with Kubernetes by Peter Zaitsevstackconf 2020 | The Path to OpenSource DBaaS with Kubernetes by Peter Zaitsev
stackconf 2020 | The Path to OpenSource DBaaS with Kubernetes by Peter Zaitsev
 
NGINX ADC: Basics and Best Practices – EMEA
NGINX ADC: Basics and Best Practices – EMEANGINX ADC: Basics and Best Practices – EMEA
NGINX ADC: Basics and Best Practices – EMEA
 
Percona Server 8.0
Percona Server 8.0Percona Server 8.0
Percona Server 8.0
 
Stackato Presentation Techzone 2013
Stackato Presentation Techzone 2013Stackato Presentation Techzone 2013
Stackato Presentation Techzone 2013
 
Oracle Fleet Patching and Provisioning Deep Dive Webcast Slides
Oracle Fleet Patching and Provisioning Deep Dive Webcast SlidesOracle Fleet Patching and Provisioning Deep Dive Webcast Slides
Oracle Fleet Patching and Provisioning Deep Dive Webcast Slides
 
CISCO - Presentation at Hortonworks Booth - Strata 2014
CISCO - Presentation at Hortonworks Booth - Strata 2014CISCO - Presentation at Hortonworks Booth - Strata 2014
CISCO - Presentation at Hortonworks Booth - Strata 2014
 

Mehr von Vinicius M Grippa

Mehr von Vinicius M Grippa (8)

MySQL up and running 30 minutes.pdf
MySQL up and running 30 minutes.pdfMySQL up and running 30 minutes.pdf
MySQL up and running 30 minutes.pdf
 
PL22 - Backup and Restore Performance.pptx
PL22 - Backup and Restore Performance.pptxPL22 - Backup and Restore Performance.pptx
PL22 - Backup and Restore Performance.pptx
 
MySQL backup and restore performance
MySQL backup and restore performanceMySQL backup and restore performance
MySQL backup and restore performance
 
Moving mongo db to the cloud strategies and points to consider
Moving mongo db to the cloud  strategies and points to considerMoving mongo db to the cloud  strategies and points to consider
Moving mongo db to the cloud strategies and points to consider
 
Cpu analysis with flamegraphs
Cpu analysis with flamegraphsCpu analysis with flamegraphs
Cpu analysis with flamegraphs
 
Percona Live 2019 - MySQL Security
Percona Live 2019 - MySQL SecurityPercona Live 2019 - MySQL Security
Percona Live 2019 - MySQL Security
 
K8s - Setting up minikube
K8s  - Setting up minikubeK8s  - Setting up minikube
K8s - Setting up minikube
 
Enhancing MySQL Security
Enhancing MySQL SecurityEnhancing MySQL Security
Enhancing MySQL Security
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

Proxy SQL 2.0 with PXC

  • 1. © 2019 Percona1 Vinicius M. Grippa Brothers in Arms: Using ProxySQL + PXC Ensuring transparent high availability and scalability for your application Support Engineer for MySQL / MongoDB
  • 2. © 2019 Percona2 About Percona ▪ Solutions for your success with MySQL, MongoDB, and PostgreSQL ▪ Support, Consulting, Managed Services, and Software ▪ Our Software is 100% Open Source and Free ▪ Support Broad Ecosystem ▪ MySQL, MariaDB, Amazon RDS, and others ▪ In Business for 12 years ▪ More than 3000 customers, including top Internet companies and enterprises
  • 3. © 2019 Percona3 About me ▪ Support Engineer at Percona since 2017 ▪ Working with MySQL for over 6 years ▪ Working with Databases for over 9 years ▪ Speaker at Percona Live
  • 4. © 2019 Percona4 Percona XtraDB Cluster
  • 5. © 2019 Percona5 Traditional MySQL replication - Replication delay - Switchover interval - Single point of failure - Data integrity problem
  • 6. © 2019 Percona6 PXC/Galera - All nodes can act as a master - Data integrity - Synchronous replication - Read scalability
  • 7. © 2019 Percona7 Automatic Node Provisioning - Bootstrapping cluster - SST (Snapshot State Transfer) (rsync, xtrabackup, mysqldump) - IST(incremental state transfer) Auto-catchup cluster state
  • 8. © 2019 Percona8 Workload Conflict - Brute force abort - Forceful abort of conflicting transaction - Certification failure
  • 9. © 2019 Percona9 Flow Control - Trx are queued. Queue full can cause flow-control - Dynamic Control of the workload
  • 10. © 2019 Percona10 Cluster-safe-mode - Workload that is not safe to the cluster - Pxc_strict_mode (Enforcing, Master, Permissive, Disabled)
  • 11. © 2019 Percona11 Load Balancer - PXC can operate with multiple load balancers (HA Proxy, ProxySQL, etc…) - PXC suggests ProxySQL - Integrated and close development - Feature rich load balancer
  • 13. © 2019 Percona13 ProxySQL Features •Query Caching •Query Routing •Firewall •Advanced configuration with 0 downtime •ProxySQL cluster •Open source :)
  • 17. © 2019 Percona17 ProxySQL 2.0 •ProxySQL v2.0 has native support for Galera Clustering (In previous versions of ProxySQL an external scheduler was required to track the status of Galera nodes) •Introduces mysql_galera_hostgroups and mysql_server_galera_log tables
  • 18. © 2019 Percona18 ProxySQL Configuration
  • 19. © 2019 Percona19 ProxySQL Example IPs 172.16.2.181 - node3 172.16.1.54 - node2 172.16.3.136 - node1 Hostgroups Writer HG-> 100 Reader HG-> 101 BackupW HG-> 102 offHG HG-> 9101
  • 20. © 2019 Percona20 ProxySQL Example Servers first: INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight) VALUES ('172.16.2.181',101,3306,1000); INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight) VALUES ('172.16.1.54',101,3306,100); INSERT INTO mysql_servers (hostname,hostgroup_id,port,weight) VALUES ('172.16.3.136',101,3306,100); save mysql servers to disk; load mysql servers to runtime;
  • 21. © 2019 Percona21 ProxySQL Example Creating user (it is necessary to create the user on PXC as well): insert into mysql_users (username, password,default_hostgroup) values ('app_test','app_test', 100); load mysql users to runtime; save mysql users from runtime; save mysql users to disk;
  • 22. © 2019 Percona22 ProxySQL Example Creating Rules: insert into mysql_query_rules (rule_id,proxy_port,schemaname,username,destination_hostgroup,active, retries,match_digest,apply) values(1040,6033,'*','app_test',100,1,3,'^SELECT.*FOR UPDATE',1); insert into mysql_query_rules (rule_id,proxy_port,schemaname,username,destination_hostgroup,active, retries,match_digest,apply) values(1041,6033,'*','app_test',101,1,3,'^SELECT.*@@',1); save mysql query rules to disk; load mysql query rules to run;
  • 23. © 2019 Percona23 ProxySQL Example Then the galera settings: insert into mysql_galera_hostgroups (writer_hostgroup,backup_writer_hostgroup,reader_hostgroup, offline_hostgroup,active,max_writers,writer_is_also_reader,ma x_transactions_behind) values (100,102,101,9101,0,1,1,16); # max_transactions_behind - determines the maximum number of writesets behind the cluster that ProxySQL should allow before shunning the node to prevent stale reads (this is determined by querying the wsrep_local_recv_queue Galera variable).
  • 24. © 2019 Percona24 ProxySQL Example Setting version: update global_variables set variable_value='5.7.25' where variable_name='mysql-server_version'; LOAD MYSQL VARIABLES TO RUNTIME;SAVE MYSQL VARIABLES TO DISK;
  • 25. © 2019 Percona25 ProxySQL Example Create monitor user on MySQL and adjust on ProxySQL: UPDATE global_variables SET variable_value='admin'WHERE variable_name='mysql-monitor_username'; UPDATE global_variables SET variable_value='admin'WHERE variable_name='mysql-monitor_password';
  • 26. © 2019 Percona26 ProxySQL Example PXC: admin@127.0.0.1 ((none)) > select * from runtime_mysql_galera_hostgroups G *************************** 1. row *************************** writer_hostgroup: 100 backup_writer_hostgroup: 102 reader_hostgroup: 101 offline_hostgroup: 9101 active: 0 ← https://github.com/sysown/proxysql/issues/1902 max_writers: 1 writer_is_also_reader: 1 max_transactions_behind: 16 comment: NULL 1 row in set (0.01 sec)
  • 27. © 2019 Percona27 ProxySQL+PXC Features PXC: root@localhost ((none)) > set global pxc_maint_mode = maintenance; # Sends a shutdown signal $ systemctl stop mysqld
  • 28. © 2019 Percona28 ProxySQL Features PXC: admin@127.0.0.1 ((none)) > select hostgroup_id,hostname,status from runtime_mysql_servers; +--------------+--------------+---------+ | hostgroup_id | hostname | status | +--------------+--------------+---------+ | 101 | 172.16.2.181 | ONLINE | | 9101 | 172.16.1.54 | SHUNNED | | 9101 | 172.16.3.136 | SHUNNED | | 100 | 172.16.2.181 | ONLINE | +--------------+--------------+---------+ 4 rows in set (0.00 sec)
  • 30. © 2019 Percona30 Compile yum install make cmake gcc gcc-c++ epel-release https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm git wget zlib-devel openssl-devel yum --disablerepo=mysql80-community --enablerepo=mysql57-community install mysql-community-libs-compat.x86_64 boost-devel.x86_64 mysql-community-devel cd /usr/include/mysql MYSQL_VERSION=$(rpm -qa | grep mysql-community-devel | awk -F'-' '{print $4}') wget https://raw.githubusercontent.com/mysql/mysql-server/mysql-${MYSQL_VERSION}/include/hash.h cd git clone https://github.com/sysown/proxysql_mysqlbinlog.git cd proxysql_mysqlbinlog cd libslave/ cmake . && make cd .. ln -s /usr/lib64/mysql/libmysqlclient.a /usr/lib64/libmysqlclient.a make ProxySQL Features
  • 31. © 2019 Percona31 Run yum install epel-release yum install boost-system ./proxysql_binlog_reader -h 127.0.0.1 -u root -psekret -P 3306 -l 3307 -L binlogreader.log ProxySQL Features
  • 32. © 2019 Percona32 PMM + ProxySQL + PXC # ProxySQL https://pmmdemo.percona.com/graph/d/fwWR9oiiz/proxysql-overview?refresh=1m& orgId=1 #PXC https://pmmdemo.percona.com/graph/d/s_k9wGNiz/pxc-galera-cluster-overview?refr esh=1m&orgId=1
  • 35. © 2019 Percona35 ● Write for our community blog percona.com/community-blog ● Join in with our community forums percona.com/forums ● Contribute to our open source projects Join in: Percona Community
  • 36. © 2019 Percona36 We are hiring! ● We are a remote first company ● Current EMEA roles: Database QA Engineer, DevOps/QA Engineer, Golang and Kubernetes Software Engineer, Senior MySQL DBA, C/C++ Software Engineer, Solution Engineer, MongoDB Technical Lead, MySQL DBA, UK Enterprise Sales, Director Marketing Communications, Director Marketing Operations ● We offer $1000 for successful referrals ● See percona.com/careers for more info or talk to us today!
  • 37. DATABASE PERFORMANCE MATTERS Database Performance MattersDatabase Performance MattersDatabase Performance MattersDatabase Performance Matters Champions of Unbiased Open Source Database Solutions