标题: mysql+proxysql+replication-manager的主从半同步复制+高可用+读写分离 [打印本页] 作者: 勿忘初心做自己 时间: 2023-4-23 16:52 标题: mysql+proxysql+replication-manager的主从半同步复制+高可用+读写分离 环境:
AlmaLinux release 9.1
MySQL Community Server Ver 8.0.33
Replication Manager v2.2.40 for MariaDB 10.x and MySQL 5.7 Series
ProxySQL version 2.5.1-90-gbedaa6c
主机分配情况:
mysql> create user appbox@'%' identified by 'Appbox@123';
Query OK, 0 rows affected (0.01 sec)
mysql> create database appboxdb character set utf8mb4;
Query OK, 1 row affected (0.01 sec)
mysql> grant all privileges on appboxdb.* to appbox@'%';
Query OK, 0 rows affected (0.01 sec)
mysql>
复制代码
用Navicat连proxysql
在proxysql中插入读写规则
insert into mysql_query_rules(rule_id,active,match_digest,destination_hostgroup,apply)values(1,1,'^SELECT.*FOR UPDATE$',100,1);
insert into mysql_query_rules(rule_id,active,match_digest,destination_hostgroup,apply)values(2,1,'^SELECT',1000,1);<br>load mysql query rules to runtime;<br>save mysql query rules to disk;
复制代码
bash下进行读写测试
for i in {1..100}; do mysql -uappbox -pAppbox@123 -h server00.mshome.net -P6033 -e 'select * from mysql.user LIMIT 2;' ; sleep 0.5; done