Weitere ähnliche Inhalte
Ähnlich wie Proxy SQL 2.0 with PXC (20)
Mehr von Vinicius M Grippa (8)
Kürzlich hochgeladen (20)
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
- 5. © 2019 Percona5
Traditional MySQL replication
- Replication delay
- Switchover interval
- Single point of failure
- Data integrity problem
- 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
- 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
- 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!