ProxySQL读写分离

时间:2019-05-10 23:42:14   收藏:0   阅读:251
中间件ProxySQL读写分离试验
主机 IP 作用
Master 192.168.37.7 主服务器
Slave 192.168.37.17 从服务器
ProxySQL 192.168.37.27 中间件服务器
Clinet 192.168.37.37 客户主机

前期准备:
Master、Slave(从服务器my.cnf文件中必须要加上read_only,因为ProxSQL通过此语句判断主从服务器)先完成主从复制。ProxySQL安装Mariadb,Clinet最少要安装MySQL客户端

ProxySQL设置

MySQL [(none)]> select * from mysql_server_connect_log;
+---------------+------+------------------+-------------------------+---------------+
| hostname      | port | time_start_us    | connect_success_time_us | connect_error |
+---------------+------+------------------+-------------------------+---------------+
| 192.168.37.7  | 3306 | 1557470898315003 | 1898                    | NULL          |
| 192.168.37.17 | 3306 | 1557470899044242 | 1950                    | NULL          |
                .
                .
                .

| 192.168.37.7  | 3306 | 1557471439197688 | 4458                    | NULL          |
+---------------+------+------------------+-------------------------+---------------+
20 rows in set (0.01 sec)

查看监控心跳信息 (对ping指标的监控):
MySQL> select from mysql_server_ping_log;
查看read_only和replication_lag的监控日志
MySQL> select
from mysql_server_read_only_log;
MySQL> select * from mysql_server_replication_lag_log;

查询调度记录

MySQL [(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                      |
+----+----------+------------+----------------------------------+
| 20 | 32464    | 5          | select @@server_id               |
| 10 | 15435    | 12         | select @@server_id               |
| 10 | 9941     | 1          | show @@server_id                 |
| 10 | 0        | 1          | select @@version_comment limit ? |
+----+----------+------------+----------------------------------+
4 rows in set (0.00 sec)

MySQL [(none)]> 

原文:https://blog.51cto.com/13749470/2392367

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!