ProxySQL

  Uncategorized

Install

wget https://github.com/sysown/proxysql/releases/download/v2.7.1/proxysql_2.7.1-ubuntu20_amd64.deb
dpkg -i proxysql_2.7.1-ubuntu20_amd64.deb

Config

mysql -h 127.0.0.1 -u admin -padmin -P 6032 --prompt='Admin>'
INSERT INTO mysql_servers(hostgroup_id, hostname, port, weight) VALUES (10, '192.168.0.23', 3306, 1);
INSERT INTO mysql_servers(hostgroup_id, hostname, port, weight) VALUES (20, '192.168.0.254', 3306, 1);
LOAD MYSQL SERVERS TO RUNTIME;
SAVE MYSQL SERVERS TO DISK;
INSERT INTO mysql_users(username, password, default_hostgroup, max_connections) VALUES ('user***', 'pass***', 10, 1000);
LOAD MYSQL USERS TO RUNTIME;
SAVE MYSQL USERS TO DISK;
INSERT INTO mysql_query_rules(rule_id, active, match_pattern, destination_hostgroup, apply) VALUES (1, 1, '^(INSERT|UPDATE|DELETE)', 10, 1);
INSERT INTO mysql_query_rules(rule_id, active, match_pattern, destination_hostgroup, apply) VALUES (2, 1, '^SELECT', 20, 1);
LOAD MYSQL QUERY RULES TO RUNTIME;
SAVE MYSQL QUERY RULES TO DISK;