ProxySQL

proxysql的作用


1.读写分离,server可以进行分读组和写组

2.动态指定某一个SQL进行cache

3.故障切换,依赖于他的配置动态加载,但是不能自动选主,需要依赖keepalived和MHA

4.配置动态更新

5.一个节点可以跑很多proxysql

6.percona公司的proxy

proxysql端口

监控的端口号:6633

管理端口号:6032

安装下载

[[email protected] tmp]# wget https://github.com/sysown/proxysql/releases/download/v1.4.0/proxysql-1.4.0-1-centos67.x86_64.rpm

[[email protected] tmp]# rpm -ivh proxysql-1.4.0-1-centos67.x86_64.rpm

[[email protected] tmp]# /etc/init.d/proxysql start

[[email protected] tmp]# ps -ef |grep proxy

root      50769      1  0 05:19 ?        00:00:00 proxysql -c /etc/proxysql.cnf -D /var/lib/proxysql

root      50770  50769  3 05:19 ?        00:00:00 proxysql -c /etc/proxysql.cnf -D /var/lib/proxysql

root      50798  50261  0 05:20 pts/3    00:00:00 grep proxy

#登陆:

[[email protected] proxysql]# mysql -u admin -padmin -h 127.0.0.1 -P6032 --prompt=‘Admin> ‘

Admin> show databases;

+-----+---------+-------------------------------+

| seq | name    | file                          |

+-----+---------+-------------------------------+

| 0   | main    |                               |

| 2   | disk    | /var/lib/proxysql/proxysql.db |

| 3   | stats   |                               |

| 4   | monitor |                               |

+-----+---------+-------------------------------+


多层配置系统

(1)允许自动更新配置

(2)大部分配置无需重启,在运行状态配置生效

(3)允许回滚错误的配置

三层结构图:

[1] LOAD MYSQL USERS FROM MEMORY / LOAD MYSQL USERS TO RUNTIME

loads MySQL users from the in-memory database to the runtime data structures

[2] SAVE MYSQL USERS TO MEMORY / SAVE MYSQL USERS FROM RUNTIME

persists the MySQL users from the runtime data structures to the in-memory database

[3] LOAD MYSQL USERS TO MEMORY / LOAD MYSQL USERS FROM DISK

loads MySQL users from the on-disk database to the in-memory database

[4] SAVE MYSQL USERS FROM MEMORY / SAVE MYSQL USERS TO DISK

persists the MySQL users from the in-memory database to the on-disk database

[5] LOAD MYSQL USERS FROM CONFIG

loads from the configuration file the users into the in-memory database

适用于表:

mysql_users mysql_servers

mysql_query_rules

mysql_variables

admin_variables

scheduler计划任务

scheduler是类似cron的任务调度计划,允许运行自定义脚本。

主要有两个表:

[email protected] [main]>SHOW TABLES LIKE ‘%scheduler%‘;

+-------------------+

| tables            |

+-------------------+

| scheduler         |

| runtime_scheduler |

+-------------------+

scheduler :可以用来设置调度计划

runtime_scheduler:只读,不能配置修改

[email protected] [main]> SHOW CREATE TABLE scheduler\G

*************************** 1. row ***************************

table: scheduler

Create Table: CREATE TABLE scheduler (

id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,

active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1,

interval_ms INTEGER CHECK (interval_ms>=100 AND interval_ms<=100000000) NOT NULL,

filename VARCHAR NOT NULL,

arg1 VARCHAR,

arg2 VARCHAR,

arg3 VARCHAR,

arg4 VARCHAR,

arg5 VARCHAR,

comment VARCHAR NOT NULL DEFAULT ‘‘)

In details:

id : unique identifier of the scheduler job

active : if set to 1, the job is active. Otherwise is not

interval_ms : how often (in millisecond) the job will be started. Minimum interval_ms is 100 milliseconds

filename : full path of the executable to be executed

arg1 to arg5 : arguments (maximum 5) that can be passed to the job

comment : an free form text field to annotate the purpose of the job

用户配置 Users Configuration


定义一个新的用户:

[email protected] [main]>INSERT INTO mysql_users(username,password) VALUES (‘user1‘,‘password1‘);

创建一个由hostgroup,schema的用户:

[email protected] [main]>INSERT INTO mysql_users(username,password,default_hostgroup,default_schema) VALUES (‘user2‘,‘password2‘,10,‘sbtest1‘);


修改user2用户的最大连接数为100个:

[email protected] [main]>UPDATE mysql_users SET max_connections=100 WHERE username=‘user2‘;

修改事务持久化:

[email protected] [main]> UPDATE mysql_users SET transaction_persistent=1 WHERE username=‘user2‘;

密码hash加密:

[email protected] [main]>load mysql users to runtime;

[email protected] [main]>save mysql users from runtime;

[email protected] [main]>save mysql users to disk;

服务配置 (server configuration )

1、往mysql_servers表中添加server时就为其划分好hostgroup_id(例如0表示写组,1表示读组)

2、往mysql_servers表中添加server时不区分hostgroup_id(例如全部设为0),然后通过mysql_replication_hostgroups表中的值,根据proxysql检测到的各server的read_only变量值来自动为后端server设置hostgroup_id

强烈推荐用第一种方式: 因为第一种是完全由我们控制的;而第二种假如我们误将读server的read_only属性设置为0,则proxysql会将其重新分配到写组,这绝对是不期望的。

(1)添加一个新的服务:

[email protected] [main]>insert into mysql_servers(hostgroup_id,hostname,max_connections) values(0,‘192.168.91.23‘,1000);

[email protected] [main]>insert into mysql_servers(hostgroup_id,hostname,max_connections) values(1,‘192.168.91.22‘,1000);

[email protected] [(none)]>select * from mysql_servers;

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| hostgroup_id | hostname      | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| 0            | 192.168.91.23 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

| 1            | 192.168.91.22 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

(2)修改限制连接数max_connections :

[email protected] [main]>UPDATE mysql_servers SET max_connections=10 WHERE hostname=‘192.168.91.23‘;

(3)修改权重值weight:

例如:一主两从的环境,设置不同的权重:

Admin> SELECT hostgroup_id,hostname,weight,max_replication_lag FROM mysql_servers;

+--------------+------------+--------+---------------------+

| hostgroup_id | hostname   | weight | max_replication_lag |

+--------------+------------+--------+---------------------+

| 0            | 172.16.0.1 | 1000   | 30                  |

| 1            | 172.16.0.2 | 1000   | 30                  |

| 1            | 172.16.0.3 | 1000   | 30                  |

| 1            | 172.16.0.1 | 1      | 30                  |

+--------------+------------+--------+---------------------+

上面的情况,如果有读事物,99.95%将会发送给172.16.0.2和172.16.0.3主机上,0.05%会发送到172.16.0.1主机上,如果172.16.0.2和172.16.0.3变得不可用了,则所有的读会有172.16.0.1承担

(4)修改复制延时最大值max_replication_lag :

[email protected] [main]>UPDATE mysql_servers SET max_replication_lag=30 WHERE hostname=‘192.168.91.23‘;

(5)打开压缩,把compression设置为非0

[email protected] [main]>UPDATE mysql_servers SET compression=2 WHERE hostname=‘192.168.91.23‘;

(6)优雅的关闭一个服务:

把状态改变成 status = offline_soft.

[email protected] [main]>UPDATE mysql_servers SET status=‘OFFLINE_SOFT‘ WHERE hostname=‘192.168.91.23‘;

(7)删除一个服务delete即可

在proxysql连接msyql server

[[email protected] ~]# mysql -u admin -padmin -h 127.0.0.1 -P6032

#配置DB主机:

[email protected] [main]>insert into mysql_servers(hostgroup_id,hostname) values(0,‘192.168.91.23‘);

[email protected] [main]>insert into mysql_servers(hostgroup_id,hostname) values(1,‘192.168.91.22‘);

[email protected] [(none)]>select * from mysql_servers;

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| hostgroup_id | hostname      | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| 0            | 192.168.91.23 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

| 1            | 192.168.91.22 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

#在mysql主库上创建监控用户:

[email protected] [(none)]>create user [email protected]‘192.168.91.%‘ identified by ‘monitor‘;

[email protected] [(none)]>grant all on *.* to [email protected]‘192.168.91.%‘;

#在proxysql中配置监控用户和密码:

[email protected] [(none)]>UPDATE global_variables SET variable_value=‘monitor‘ WHERE variable_name=‘mysql-monitor_username‘;

[email protected] [(none)]>UPDATE global_variables SET variable_value=‘monitor‘ WHERE variable_name=‘mysql-monitor_password‘;

#配置监控时间间隔:如mysql-monitor_connect_interval、  mysql-monitor_ping_interval、  mysql-monitor_read_only_interval:

[email protected] [(none)]>UPDATE global_variables SET variable_value=‘2000‘ WHERE variable_name IN (‘mysql-monitor_connect_interval‘,‘mysql-monitor_ping_interval‘,‘mysql-monitor_read_only_interval‘);

[email protected] [(none)]>select * from global_variables where variable_name like ‘mysql-monitor_%‘;

+-----------------------------------------------------+----------------+

| variable_name                                       | variable_value |

+-----------------------------------------------------+----------------+

| mysql-monitor_enabled                               | true           |

| mysql-monitor_connect_timeout                       | 600            |

| mysql-monitor_ping_max_failures                     | 3              |

| mysql-monitor_ping_timeout                          | 1000           |

| mysql-monitor_replication_lag_interval              | 10000          |

| mysql-monitor_replication_lag_timeout               | 1000           |

| mysql-monitor_groupreplication_healthcheck_interval | 5000           |

| mysql-monitor_groupreplication_healthcheck_timeout  | 800            |

| mysql-monitor_username                              | monitor        |

| mysql-monitor_password                              | monitor        |

| mysql-monitor_query_interval                        | 60000          |

| mysql-monitor_query_timeout                         | 100            |

| mysql-monitor_slave_lag_when_null                   | 60             |

| mysql-monitor_wait_timeout                          | true           |

| mysql-monitor_writer_is_also_reader                 | true           |

| mysql-monitor_history                               | 600000         |

| mysql-monitor_connect_interval                      | 2000           |

| mysql-monitor_ping_interval                         | 2000           |

| mysql-monitor_read_only_interval                    | 2000           |

| mysql-monitor_read_only_timeout                     | 500            |

+-----------------------------------------------------+----------------+

[email protected] [(none)]>LOAD MYSQL VARIABLES TO RUNTIME;

admin[email protected] [(none)]>SAVE MYSQL VARIABLES TO DISK;

[email protected] [(none)]>show tables from monitor;

+------------------------------------+

| tables                             |

+------------------------------------+

| mysql_server_connect               |

| mysql_server_connect_log           |

| mysql_server_group_replication_log |

| mysql_server_ping                  |

| mysql_server_ping_log              |

| mysql_server_read_only_log         |

| mysql_server_replication_lag_log   |

+------------------------------------+

[email protected] [(none)]>SELECT * FROM monitor.mysql_server_connect_log ORDER BY time_start_us DESC LIMIT 10;

+---------------+------+------------------+-------------------------+---------------+

| hostname      | port | time_start_us    | connect_success_time_us | connect_error |

+---------------+------+------------------+-------------------------+---------------+

| 192.168.91.23 | 3306 | 1495445436268761 | 1894                    | NULL          |

| 192.168.91.22 | 3306 | 1495445436267947 | 3301                    | NULL          |

| 192.168.91.23 | 3306 | 1495445434267631 | 601                     | NULL          |

| 192.168.91.22 | 3306 | 1495445434266684 | 1898                    | NULL          |

| 192.168.91.23 | 3306 | 1495445432267286 | 527                     | NULL          |

| 192.168.91.22 | 3306 | 1495445432266457 | 1646                    | NULL          |

+---------------+------+------------------+-------------------------+---------------+

[email protected] [(none)]>SELECT * FROM monitor.mysql_server_ping_log ORDER BY time_start_us DESC LIMIT 10;

+---------------+------+------------------+----------------------+------------+

| hostname      | port | time_start_us    | ping_success_time_us | ping_error |

+---------------+------+------------------+----------------------+------------+

| 192.168.91.23 | 3306 | 1495445542307107 | 147                  | NULL       |

| 192.168.91.22 | 3306 | 1495445542306299 | 504                  | NULL       |

| 192.168.91.23 | 3306 | 1495445540306625 | 173                  | NULL       |

| 192.168.91.22 | 3306 | 1495445540305786 | 596                  | NULL       |

| 192.168.91.23 | 3306 | 1495445538305981 | 165                  | NULL       |

+---------------+------+------------------+----------------------+------------+

[email protected] [(none)]>LOAD MYSQL SERVERS TO RUNTIME;


MySQL replication hostgroups

对应表 mysql_replication_hostgroups

表的作用:配置写组(比如1)和读组(比如2),ProxySQL会根据read_only参数把主机分配到对应的读组合写组中

如read_only=0 ,分配到hostgroup 1

如read_only=1 , 分配到 hostgroup 2

[email protected] [(none)]>INSERT INTO mysql_replication_hostgroups(writer_hostgroup,reader_hostgroup) VALUES (1,2);

[email protected] [(none)]>select * from  mysql_replication_hostgroups;

+------------------+------------------+---------+

| writer_hostgroup | reader_hostgroup | comment |

+------------------+------------------+---------+

| 1                | 2                | NULL    |

+------------------+------------------+---------+

#现在192.168.91.22是read_only=0,所以hostgroup_id=1:

[email protected] [(none)]>SELECT * FROM mysql_servers;

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| hostgroup_id | hostname      | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| 0            | 192.168.91.23 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

| 1            | 192.168.91.22 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

[email protected] [(none)]>load mysql servers to runtime;

[email protected] [(none)]>set global read_only=1;

[email protected] [(none)]>SELECT * FROM monitor.mysql_server_read_only_log ORDER BY time_start_us DESC LIMIT 10;

+---------------+------+------------------+-----------------+-----------+-------+

| hostname      | port | time_start_us    | success_time_us | read_only | error |

+---------------+------+------------------+-----------------+-----------+-------+

| 192.168.91.22 | 3306 | 1495449784913364 | 10240           | 1         | NULL  |

| 192.168.91.22 | 3306 | 1495449782913147 | 3161            | 1         | NULL  |

| 192.168.91.22 | 3306 | 1495449780912973 | 5600            | 1         | NULL  |

| 192.168.91.22 | 3306 | 1495449778913003 | 8661            | 1         | NULL  |  |

+---------------+------+------------------+-----------------+-----------+-------+

#现在192.168.91.22是read_only=1,所以被分配到hostgroup_id=2:

[email protected] [(none)]>select * from mysql_servers;

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| hostgroup_id | hostname      | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| 0            | 192.168.91.23 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

| 2            | 192.168.91.22 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

[email protected] [(none)]>SAVE MYSQL SERVERS TO DISK;

[email protected] [(none)]>save mysql variables to disk;

mysql_users

admin>INSERT INTO mysql_users(username,password,default_hostgroup) VALUES (‘user1‘,‘147258‘,0);

admin>INSERT INTO mysql_users(username,password,default_hostgroup) VALUES (‘user2‘,‘147258‘,1);

admin>INSERT INTO mysql_users(username,password,default_hostgroup) VALUES (‘user3‘,‘147258‘,2);

[email protected] [(none)]>load mysql users to runtime;

[email protected] [(none)]>save mysql users to disk;

#需要在数据库层面创建对应的用户名和密码才能登陆操作数据库:

[email protected] [(none)]>create user [email protected]‘%‘ identified by ‘147258‘;

[email protected] [(none)]>grant all on *.* to [email protected]‘%‘;

mysql -u user1 -p147258 -h 127.0.0.1 -P6033

[email protected] [testdb]>select @@hostname;

+------------+

| @@hostname |

+------------+

| Darren1    |

+------------+

#可以用sysbench做测试:

[[email protected] ~]# sysbench --time=20 --threads=4  --mysql-host=localhost --mysql-user=user1 --mysql-password=‘147258‘ --mysql-port=6033  --mysql-db=sbtest --tables=4 --table_size=1000  /home/mysql/sysbench-1.0.3/src/lua/oltp_read_write.lua prepare

[[email protected] ~]# sysbench --time=20 --threads=4  --mysql-host=localhost --mysql-user=user1 --mysql-password=‘147258‘ --mysql-port=6033  --mysql-db=sbtest --tables=4 --table_size=1000  /home/mysql/sysbench-1.0.3/src/lua/oltp_read_write.lua run

ProxySQL Statistics

ProxySQL可以通过stats库收集大量统计信息

[email protected] [(none)]>show tables from stats;

+-----------------------------------+

| tables                            |

+-----------------------------------+

| global_variables                  |

| stats_mysql_commands_counters     |

| stats_mysql_connection_pool       |

| stats_mysql_connection_pool_reset |

| stats_mysql_global                |

| stats_mysql_processlist           |

| stats_mysql_query_digest          |

| stats_mysql_query_digest_reset    |

| stats_mysql_query_rules           |

| stats_mysql_users                 |

+-----------------------------------+

#stats.stats_mysql_connection_pool表:

[email protected] [(none)]>SELECT * FROM stats.stats_mysql_connection_pool;

+-----------+---------------+----------+--------+----------+----------+--------+---------+---------+-----------------+-----------------+------------+

| hostgroup | srv_host      | srv_port | status | ConnUsed | ConnFree | ConnOK | ConnERR | Queries | Bytes_data_sent | Bytes_data_recv | Latency_us |

+-----------+---------------+----------+--------+----------+----------+--------+---------+---------+-----------------+-----------------+------------+

| 0         | 192.168.91.23 | 3306     | ONLINE | 0        | 0        | 0      | 22      | 0       | 0               | 0               | 168        |

| 2         | 192.168.91.22 | 3306     | ONLINE | 0        | 0        | 0      | 0       | 0       | 0               | 0               | 926        |

| 1         | 192.168.91.22 | 3306     | ONLINE | 0        | 0        | 0      | 176     | 0       | 0               | 0               | 926        |

+-----------+---------------+----------+--------+----------+----------+--------+---------+---------+-----------------+-----------------+------------+

#stats_mysql_commands_counters表:

作用:

returns detailed information about the type of statements executed, and the distribution of execution time!

#统计一些sql的操作:

[email protected] [(none)]>select * from stats_mysql_commands_counters;

+-------------------+---------------+-----------+-----------+-----------+---------+---------+----------+----------+-----------+-----------+--------+--------+---------+----------+

| Command           | Total_Time_us | Total_cnt | cnt_100us | cnt_500us | cnt_1ms | cnt_5ms | cnt_10ms | cnt_50ms | cnt_100ms | cnt_500ms | cnt_1s | cnt_5s | cnt_10s | cnt_INFs |

+-------------------+---------------+-----------+-----------+-----------+---------+---------+----------+----------+-----------+-----------+--------+--------+---------+----------+

| ALTER_TABLE       | 0             | 0         | 0         | 0         | 0       | 0       | 0        | 0        | 0         | 0         | 0      | 0      | 0       | 0        |

| ALTER_VIEW        | 0             | 0         | 0         | 0         | 0       | 0       | 0        | 0        | 0         | 0         | 0      | 0      | 0       | 0        |

| ANALYZE_TABLE     | 0             | 0         | 0         | 0         | 0       | 0       | 0        | 0        | 0         | 0         | 0      | 0      | 0       | 0        |

| BEGIN             | 0             | 0         | 0         | 0         | 0       | 0       | 0        | 0        | 0         | 0         | 0      | 0      | 0       | 0        |

| CALL              | 0             | 0         | 0         | 0         | 0       | 0       | 0        | 0        | 0         | 0         | 0      | 0      | 0       | 0        |

| CHANGE_MASTER     | 0             | 0         | 0         | 0         | 0       | 0       | 0        | 0        | 0         | 0         | 0      | 0      | 0       | 0        |

| COMMIT            | 0             | 0         | 0         | 0         | 0       | 0       | 0        | 0        | 0         | 0

...........

#stats_mysql_query_digest查看执行过的查询操作

[email protected] [(none)]>SELECT * FROM stats_mysql_query_digest ORDER BY sum_time DESC;

+-----------+--------------------+----------+--------------------+-----------------------------------+------------+------------+------------+----------+----------+----------+

| hostgroup | schemaname         | username | digest             | digest_text                       | count_star | first_seen | last_seen  | sum_time | min_time | max_time |

+-----------+--------------------+----------+--------------------+-----------------------------------+------------+------------+------------+----------+----------+----------+

| 0         | information_schema | user1    | 0x1E092DAEFFBBF262 | select ?                          | 1          | 1495462584 | 1495462584 | 111316   | 111316   | 111316   |

| 0         | testdb             | user1    | 0x3765930C7143F468 | select * from t1                  | 1          | 1495462644 | 1495462644 | 101438   | 101438   | 101438   |

| 0         | information_schema | user1    | 0x99531AEFF718C501 | show tables                       | 2          | 1495462594 | 1495

.......

#查询表stats_mysql_query_digest_reset的作用就是把表stats_mysql_query_digest清空

[email protected] [(none)]>select * from stats_mysql_query_digest_reset;

[email protected] [(none)]>select * from stats_mysql_query_digest;

Empty set (0.00 sec)

路由规则(MySQL Query Rules)

表: mysql_query_rules

作用:控制读写分离

表中:apply=1 means that no further rules are checked if there is a match

#创建一个rule:表示SELECT * FROM t1$开头的SQL语句会通过hostgroup为0的主机执行:

[email protected] [(none)]>INSERT INTO mysql_query_rules (rule_id,active,username,match_digest,destination_hostgroup,apply) VALUES (10,1,‘user1‘,‘^SELECT * FROM t1$‘,0,1);

[email protected] [(none)]>LOAD MYSQL QUERY RULES TO RUNTIME;

[[email protected] lua]# mysql -u user1 -p147258 -h 127.0.0.1 -P6033

[email protected] [testdb]>select * from t1;

#可以看到前面的select语句分配到hostgroup为0的服务器上:

[email protected] [(none)]>SELECT hostgroup hg, sum_time, count_star, digest_text FROM stats_mysql_query_digest ORDER BY sum_time DESC;

+----+----------+------------+------------------+

| hg | sum_time | count_star | digest_text      |

+----+----------+------------+------------------+

| 0  | 716      | 1          | select * from t1 |

+----+----------+------------+------------------+

时间: 2024-10-09 22:12:19

ProxySQL的相关文章

MySQL ProxySQL读写分离使用初探

目的 在美团点评DBProxy读写分离使用说明文章中已经说明了使用目的,本文介绍ProxySQL的使用方法以及和DBProxy的性能差异.具体的介绍可以看官网的相关说明,并且这个中间件也是percona推的一款中间件.其特性和其他读写分离的中间件差距不大,具体的会在文中介绍.本文大致简单的介绍在使用过程中的一些说明,也可以看官方的wiki获得使用帮助. 环境:  Distributor ID: Ubuntu Description: Ubuntu 14.04.5 LTS Release: 14.

ProxySQL读写分离

我们首先看一下自己的环境: MHA已经搭建: master:172.16.16.35:3306 slave:172.16.16.35:3307 slave:172.16.16.34:3307 MHA manager在172.16.16.34,配置文件如下: [[email protected] bin]# cat /etc/masterha/app1.cnf [server default] manager_log=/var/log/mha/app1/manager.log manager_wo

MHA+ProxySQL实现读写分离高可用

最近在研究ProxySQL,觉得还挺不错的,所以就简单的折腾了一下,ProxySQL目前也是Percona在推荐的一个读写分离的中间件.关于详细的介绍可以参考官方文档.https://github.com/sysown/proxysql/wiki 本文主要介绍的是MHA+ProxySQL读写分离以及高可用,ProxySQL的细节请参考文档,目前已经有人写发非常详细了,文章最后会给出链接.当然和Group Replication,PXC搭配那是更完美的.关于MHA的配置参考我前面的文章,本文就不再

ProxySQL 读写分离实践

前言 ProxySQL是一个高性能的MySQL中间件,拥有强大的规则引擎.具有以下特性: 连接池,而且是 multiplexing 主机和用户的最大连接数限制 自动下线后端DB 延迟超过阀值 ping 延迟超过阀值 网络不通或宕机 强大的规则路由引擎 实现读写分离 查询重写 sql流量镜像 支持prepared statement 支持Query Cache 支持负载均衡,与gelera结合自动failover 官方参考文档 https://github.com/sysown/proxysql/

proxysql安装配置和读写分离初识

前言 笔者从事MySQL的相关工作,最近线上需要一款性能上佳的MySQL中间件产品,本人在了解一些如ProxySQL.MariaDB MaxScale.MySQL Router.Atlas.DBProxy等相关产品后,经过反复对比和相关测试,初步选用了proxysql.本文是proxysql系列的第一篇,笔者计划proxysql系列的博文将为您介绍proxysql的安装配置.读写分离.可用性测试.深入了解proxysql各组件.proxysql+keepalived实现高可用.proxysql和

MySQL ProxySQL读写分离实践

目的 在上一篇文章MySQL ProxySQL读写分离使用初探里初步介绍了ProxySQL的使用,本文继续介绍它的一些特点和DBProxy的性能差异.深入一些去了解ProxySQL,通过例子来说明ProxySQL的一些特性和用sysbench对其进行测试来对比分析说明. 环境:  Distributor ID: Ubuntu Description : Ubuntu 14.04.5 LTS Release : 14.04 Codename : trusty MySQL Master :192.1

mysql+proxysql+keepalived实现高可用的数据库读写分离

前言 为了降低一台数据库的IO,远程连接数据库的时候,可以实现读写分离进行调度.这里就出现了一个单点,所以必须要做一个高可用.当然数据库服务器也需要做主从复制. 实验结构 说明:上图的拓扑只是整个架构中的一个小部分,其余功能的实现此图并未规划出来.此拓扑实现的目的是利用proxysql实现数据读写分离,并对proxysql高可用.两台安装了Keepalived和proxysql虚拟成一个VIP对外提供服务.这两台mysql服务器做的半同步复制,192.168.32.111是主节点负责用户的写操作

MHA + proxysql 高可用以及读写分离

环境 vip 192.168.1.101 slave 192.168.1.16 5.7.17 3306 master 192.168.1.135 5.7.17 3306 proxysql 192.168.1.16(为方便proxysql放在了16节点上) 一   MHA的搭建 1.安装MHA软件,首先安装epel源.(2台机器) rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm 2

Proxysql,MariaDB 主从复制和读写分离

准备: 4台vm (centos 7.3): 192.168.1.120 proxysql 192.168.1.121 node1 master 192.168.1.122 node2 slave 192.168.1.123 node3 slave 一. 在node1,node2,node3安装mariadb, mariadb-server (以root用户安装) 1. yum安装 # yum install mariadb mariadb-server -y 2. 启动服务 # systemc