Preface
 
    I've implemented ProxySQL on PXC yesterday but got some errors when configured query rules.I'm gonna do it again in my master-slave environment again.Let's see the procedure.
 
Procedure
 
Start ProxySQL.
 [root@zlm1 :: /var/lib]
#service proxysql start
Starting ProxySQL: ProxySQL is already running. [root@zlm1 :: /var/lib]
#ps aux|grep proxysql
root 0.0 0.5 ? S : : proxysql -c /etc/proxysql.cnf -D /var/lib/proxysql
root 0.0 2.0 ? Sl : : proxysql -c /etc/proxysql.cnf -D /var/lib/proxysql
root 0.0 0.0 pts/ R+ : : grep --color=auto proxysql
Login ProxySQL configure the hostgroups.
 [root@zlm1 :: ~]
#mysql -uadmin -padmin -h127.0.0. -P6032
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.5. (ProxySQL Admin Module) Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. admin@127.0.0.1: [(none)]>select * from mysql_replication_hostgroups;
Empty set (0.00 sec) admin@127.0.0.1: [(none)]>insert into mysql_replication_hostgroups(writer_hostgroup,reader_hostgroup) values(,);
Query OK, row affected (0.00 sec) admin@127.0.0.1: [(none)]>select * from mysql_replication_hostgroups;
+------------------+------------------+---------+
| writer_hostgroup | reader_hostgroup | comment |
+------------------+------------------+---------+
| | | |
+------------------+------------------+---------+
row in set (0.00 sec) admin@127.0.0.1: [(none)]>select * from runtime_mysql_replication_hostgroups;
Empty set (0.00 sec) admin@127.0.0.1: [(none)]>select * from disk.mysql_replication_hostgroups;
Empty set (0.00 sec) admin@127.0.0.1: [(none)]>load mysql servers to runtime;save mysql servers to disk;
Query OK, rows affected (0.00 sec) admin@127.0.0.1: [(none)]>select * from runtime_mysql_replication_hostgroups;
+------------------+------------------+---------+
| writer_hostgroup | reader_hostgroup | comment |
+------------------+------------------+---------+
| | | |
+------------------+------------------+---------+
row in set (0.00 sec) admin@127.0.0.1: [(none)]>select * from disk.mysql_replication_hostgroups;
+------------------+------------------+---------+
| writer_hostgroup | reader_hostgroup | comment |
+------------------+------------------+---------+
| | | |
+------------------+------------------+---------+
row in set (0.00 sec)
Configure the mysql servers.
 admin@127.0.0.1: [(none)]>select * from mysql_servers;
Empty set (0.00 sec) admin@127.0.0.1: [(none)]>insert into mysql_servers(hostgroup_id,hostname,max_connections,max_replication_lag) values(,'192.168.56.100',,);
Query OK, row affected (0.00 sec) admin@127.0.0.1: [(none)]>insert into mysql_servers(hostgroup_id,hostname,max_connections,max_replication_lag) values(,'192.168.56.101',,);
Query OK, row affected (0.00 sec) admin@127.0.0.1: [(none)]>select * from mysql_servers;
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| | 192.168.56.100 | | ONLINE | | | | | | | |
| | 192.168.56.101 | | ONLINE | | | | | | | |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
rows in set (0.00 sec) admin@127.0.0.1: [(none)]>select * from runtime_mysql_servers;
Empty set (0.00 sec) admin@127.0.0.1: [(none)]>select * from disk.mysql_servers;
Empty set (0.00 sec) admin@127.0.0.1: [(none)]>load mysql servers to runtime;save mysql servers to disk;
Query OK, rows affected (0.00 sec) Query OK, rows affected (0.05 sec) admin@127.0.0.1: [(none)]>select * from runtime_mysql_servers;
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| | 192.168.56.101 | | ONLINE | | | | | | | |
| | 192.168.56.100 | | ONLINE | | | | | | | |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
rows in set (0.00 sec) //Why does the hostgroup_id in table "runtime_mysql_servers" still "20"? admin@127.0.0.1: [(none)]>select * from disk.mysql_servers;
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| | 192.168.56.100 | | ONLINE | | | | | | | |
| | 192.168.56.101 | | ONLINE | | | | | | | |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
rows in set (0.00 sec) //The hostgroup_id in table "disk.mysql_servers" has taken effect. //Check the variables of "read_only" and "super_read_only".
zlm@192.168.56.100: [(none)]>show variables like '%read_only%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| innodb_read_only | OFF |
| read_only | OFF |
| super_read_only | OFF |
| transaction_read_only | OFF |
| tx_read_only | OFF |
+-----------------------+-------+
rows in set (0.00 sec) admin@127.0.0.1: [(none)]>load mysql servers to runtime;
Query OK, rows affected (0.00 sec) admin@127.0.0.1: [(none)]>select * from runtime_mysql_servers;
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| | 192.168.56.101 | | ONLINE | | | | | | | |
| | 192.168.56.100 | | ONLINE | | | | | | | |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
rows in set (0.00 sec) //It's still "20". admin@127.0.0.1: [(none)]>select * from mysql_servers;
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| | 192.168.56.100 | | ONLINE | | | | | | | |
| | 192.168.56.101 | | ONLINE | | | | | | | |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
rows in set (0.00 sec) //The "hostgroup_id" in mysql_serves also turned to be "20".Why does it happen?It's the reason why my query rule did not take effect yesterday. admin@127.0.0.1: [(none)]>SELECT * FROM monitor.mysql_server_connect_log ORDER BY time_start_us DESC LIMIT ;
+----------------+------+------------------+-------------------------+---------------------------------------------------------------+
| hostname | port | time_start_us | connect_success_time_us | connect_error |
+----------------+------+------------------+-------------------------+---------------------------------------------------------------+
| 192.168.56.100 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
| 192.168.56.101 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
| 192.168.56.101 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
| 192.168.56.100 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
| 192.168.56.101 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
| 192.168.56.100 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
| 192.168.56.100 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
| 192.168.56.101 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
| 192.168.56.100 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
| 192.168.56.101 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
+----------------+------+------------------+-------------------------+---------------------------------------------------------------+
rows in set (0.00 sec) //It seems the privileges was configurated abnormally. zlm@192.168.56.100: [(none)]>select user,host from mysql.user;
+---------------+--------------+
| user | host |
+---------------+--------------+
| repl | 192.168..% |
| zlm | 192.168..% |
| bkuser | localhost |
| monitor | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+--------------+
rows in set (0.00 sec) zlm@192.168.56.100: [(none)]>drop user monitor@localhost;
Query OK, rows affected (0.00 sec) zlm@192.168.56.100: [(none)]>grant all privileges on *.* to monitor@'%' identified by 'monitor';
ERROR (): Access denied for user 'zlm'@'192.168.56.%' (using password: YES)
zlm@192.168.56.100: [(none)]>exit
Bye [root@zlm1 :: /data/backup]
#mysql -uroot -pPassw0rd -hlocalhost -S /tmp/mysql3306.sock
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7.-log MySQL Community Server (GPL) Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. root@localhost:mysql3306.sock [(none)]>grant all privileges on *.* to monitor@'%' identified by 'monitor';
Query OK, rows affected, warning (0.00 sec) root@localhost:mysql3306.sock [(none)]>select user,host from mysql.user;
+---------------+--------------+
| user | host |
+---------------+--------------+
| monitor | % |
| repl | 192.168..% |
| zlm | 192.168..% |
| bkuser | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+--------------+
rows in set (0.00 sec) admin@127.0.0.1: [(none)]>SELECT * FROM monitor.mysql_server_connect_log ORDER BY time_start_us DESC LIMIT ;
+----------------+------+------------------+-------------------------+---------------------------------------------------------------+
| hostname | port | time_start_us | connect_success_time_us | connect_error |
+----------------+------+------------------+-------------------------+---------------------------------------------------------------+
| 192.168.56.101 | | | | NULL |
| 192.168.56.100 | | | | NULL |
| 192.168.56.100 | | | | NULL |
| 192.168.56.101 | | | | NULL |
| 192.168.56.100 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
| 192.168.56.101 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
| 192.168.56.101 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
| 192.168.56.100 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
| 192.168.56.101 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
| 192.168.56.100 | | | | Access denied for user 'monitor'@'zlm1' (using password: YES) |
+----------------+------+------------------+-------------------------+---------------------------------------------------------------+
rows in set (0.00 sec) //The monitor became normal. admin@127.0.0.1: [(none)]>select * from mysql_servers;
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| | 192.168.56.100 | | ONLINE | | | | | | | |
| | 192.168.56.100 | | ONLINE | | | | | | | |
| | 192.168.56.101 | | ONLINE | | | | | | | |
| | 192.168.56.101 | | ONLINE | | | | | | | |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
rows in set (0.00 sec) admin@127.0.0.1: [(none)]>delete from mysql_servers;
Query OK, rows affected (0.00 sec) admin@127.0.0.1: [(none)]>insert into mysql_servers(hostgroup_id,hostname,max_connections,max_replication_lag) values(,'192.168.56.100',,),(,'192.168.56.101',,);
Query OK, rows affected (0.00 sec) admin@127.0.0.1: [(none)]>select * from mysql_servers;
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| | 192.168.56.100 | | ONLINE | | | | | | | |
| | 192.168.56.101 | | ONLINE | | | | | | | |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
rows in set (0.00 sec) admin@127.0.0.1: [(none)]>load mysql servers to runtime;save mysql servers to disk;
Query OK, rows affected (0.00 sec) Query OK, rows affected (0.02 sec) admin@127.0.0.1: [(none)]>select * from mysql_servers;
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| | 192.168.56.100 | | ONLINE | | | | | | | |
| | 192.168.56.101 | | ONLINE | | | | | | | |
| | 192.168.56.101 | | ONLINE | | | | | | | |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
rows in set (0.00 sec) //Why there're three records in table "mysql_servers"? admin@127.0.0.1: [(none)]>select * from runtime_mysql_servers;
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| | 192.168.56.100 | | ONLINE | | | | | | | |
| | 192.168.56.101 | | ONLINE | | | | | | | |
| | 192.168.56.101 | | ONLINE | | | | | | | |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
rows in set (0.00 sec) admin@127.0.0.1: [(none)]>select * from disk.mysql_servers;
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| | 192.168.56.100 | | ONLINE | | | | | | | |
| | 192.168.56.101 | | ONLINE | | | | | | | |
+--------------+----------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
rows in set (0.00 sec) admin@127.0.0.1: [(none)]>show variables like '%also%';
+-------------------------------------+-------+
| Variable_name | Value |
+-------------------------------------+-------+
| mysql-monitor_writer_is_also_reader | true |
+-------------------------------------+-------+
row in set (0.00 sec) admin@127.0.0.1: [(none)]>SELECT * FROM monitor.mysql_server_connect_log ORDER BY time_start_us DESC LIMIT ;
+----------------+------+------------------+-------------------------+---------------+
| hostname | port | time_start_us | connect_success_time_us | connect_error |
+----------------+------+------------------+-------------------------+---------------+
| 192.168.56.100 | | | | NULL |
| 192.168.56.101 | | | | NULL |
| 192.168.56.101 | | | | NULL |
| 192.168.56.100 | | | | NULL |
| 192.168.56.101 | | | | NULL |
| 192.168.56.100 | | | | NULL |
| 192.168.56.100 | | | | NULL |
| 192.168.56.101 | | | | NULL |
| 192.168.56.101 | | | | NULL |
| 192.168.56.100 | | | | NULL |
+----------------+------+------------------+-------------------------+---------------+
rows in set (0.00 sec)
Configure the mysql users.
 admin@127.0.0.1: [(none)]>select * from mysql_users;
Empty set (0.00 sec) admin@127.0.0.1: [(none)]>insert into mysql_users(username,password,active,default_hostgroup,default_schema) values('zlm','zlmzlm',,,'zlm');
Query OK, row affected (0.00 sec) admin@127.0.0.1: [(none)]>select * from mysql_users;
+----------+----------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+
| username | password | active | use_ssl | default_hostgroup | default_schema | schema_locked | transaction_persistent | fast_forward | backend | frontend | max_connections |
+----------+----------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+
| zlm | zlmzlm | | | | zlm | | | | | | |
+----------+----------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+
row in set (0.00 sec) admin@127.0.0.1: [(none)]>select * from runtime_mysql_users;
Empty set (0.00 sec) admin@127.0.0.1: [(none)]>select * from disk.mysql_users;
Empty set (0.00 sec) admin@127.0.0.1: [(none)]>load mysql users to runtime;save mysql users to disk;
Query OK, rows affected (0.00 sec) Query OK, rows affected (0.01 sec) admin@127.0.0.1: [(none)]>select * from runtime_mysql_users;
+----------+-------------------------------------------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+
| username | password | active | use_ssl | default_hostgroup | default_schema | schema_locked | transaction_persistent | fast_forward | backend | frontend | max_connections |
+----------+-------------------------------------------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+
| zlm | *512FB3FAA6F522E351929CAC70AD8EBB0F5901B6 | | | | zlm | | | | | | |
| zlm | *512FB3FAA6F522E351929CAC70AD8EBB0F5901B6 | | | | zlm | | | | | | |
+----------+-------------------------------------------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+
rows in set (0.00 sec) admin@127.0.0.1: [(none)]>select * from disk.mysql_users;
+----------+----------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+
| username | password | active | use_ssl | default_hostgroup | default_schema | schema_locked | transaction_persistent | fast_forward | backend | frontend | max_connections |
+----------+----------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+
| zlm | zlmzlm | | | | zlm | | | | | | |
+----------+----------+--------+---------+-------------------+----------------+---------------+------------------------+--------------+---------+----------+-----------------+
row in set (0.00 sec)
Configure the query rules.
 admin@127.0.0.1: [(none)]>select * from mysql_query_rules;
Empty set (0.00 sec) admin@127.0.0.1: [(none)]>insert into mysql_query_rules(active,username,match_pattern,schemaname,destination_hostgroup,apply) values(,'zlm','^select','zlm',,);
Query OK, row affected (0.00 sec) admin@127.0.0.1: [(none)]>select active,username,match_pattern,schemaname,destination_hostgroup,apply from mysql_query_rules;
+--------+----------+---------------+------------+-----------------------+-------+
| active | username | match_pattern | schemaname | destination_hostgroup | apply |
+--------+----------+---------------+------------+-----------------------+-------+
| | zlm | ^select | zlm | | |
+--------+----------+---------------+------------+-----------------------+-------+
row in set (0.00 sec) admin@127.0.0.1: [(none)]>select * from runtime_mysql_query_rules;
Empty set (0.00 sec) admin@127.0.0.1: [(none)]>select * from disk.mysql_query_rules;
Empty set (0.00 sec) admin@127.0.0.1: [(none)]>load mysql query rules to runtime;save mysql query rules to disk;
Query OK, rows affected (0.00 sec) admin@127.0.0.1: [(none)]>select active,username,match_pattern,schemaname,destination_hostgroup,apply from runtime_mysql_query_rules;
+--------+----------+---------------+------------+-----------------------+-------+
| active | username | match_pattern | schemaname | destination_hostgroup | apply |
+--------+----------+---------------+------------+-----------------------+-------+
| | zlm | ^select | zlm | | |
+--------+----------+---------------+------------+-----------------------+-------+
row in set (0.00 sec) admin@127.0.0.1: [(none)]>select active,username,match_pattern,schemaname,destination_hostgroup,apply from disk.mysql_query_rules;
+--------+----------+---------------+------------+-----------------------+-------+
| active | username | match_pattern | schemaname | destination_hostgroup | apply |
+--------+----------+---------------+------------+-----------------------+-------+
| | zlm | ^select | zlm | | |
+--------+----------+---------------+------------+-----------------------+-------+
row in set (0.00 sec)
Test whether proxy can seperate writing and reading operations.
 admin@127.0.0.1: [(none)]>show create table stats.stats_mysql_query_digest\G
*************************** . row ***************************
table: stats_mysql_query_digest
Create Table: CREATE TABLE stats_mysql_query_digest (
hostgroup INT,
schemaname VARCHAR NOT NULL,
username VARCHAR NOT NULL,
digest VARCHAR NOT NULL,
digest_text VARCHAR NOT NULL,
count_star INTEGER NOT NULL,
first_seen INTEGER NOT NULL,
last_seen INTEGER NOT NULL,
sum_time INTEGER NOT NULL,
min_time INTEGER NOT NULL,
max_time INTEGER NOT NULL,
PRIMARY KEY(hostgroup, schemaname, username, digest))
row in set (0.00 sec) admin@127.0.0.1: [(none)]>select hostgroup,schemaname,username,substr(digest_text,,-),count_star from stats_mysql_query_digest_reset;
Empty set (0.00 sec) [root@zlm1 :: /data/backup]
#mysql -uzlm -pzlmzlm -h192.168.56. -P6033
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.5. (ProxySQL) Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. zlm@192.168.56.100: [(none)]>show tables;
+---------------+
| Tables_in_zlm |
+---------------+
| test |
+---------------+
row in set (0.00 sec) zlm@192.168.56.100: [(none)]>select * from test;
+------+------+
| id | name |
+------+------+
| | aaa |
| | bbb |
| | ccc |
+------+------+
rows in set (0.00 sec) zlm@192.168.56.100: [(none)]>insert into test values(,'eee');
Query OK, row affected (0.00 sec) zlm@192.168.56.100: [(none)]>update test set name='ddd' where id=;
Query OK, row affected (0.00 sec)
Rows matched: Changed: Warnings: zlm@192.168.56.100: [(none)]>select * from test;
+------+------+
| id | name |
+------+------+
| | aaa |
| | bbb |
| | ccc |
| | ddd |
+------+------+
rows in set (0.00 sec) admin@127.0.0.1: [(none)]>select hostgroup,schemaname,username,substr(digest_text,,-),count_star from stats_mysql_query_digest;
+-----------+------------+----------+-----------------------------------+------------+
| hostgroup | schemaname | username | substr(digest_text,,-) | count_star |
+-----------+------------+----------+-----------------------------------+------------+
| | zlm | zlm | update test set name=? where id=? | |
| | zlm | zlm | select * from test | |
| | zlm | zlm | show tables | |
| | zlm | zlm | select USER() | |
| | zlm | zlm | insert into test values(?,?) | |
| | zlm | zlm | select @@version_comment limit ? | |
+-----------+------------+----------+-----------------------------------+------------+
rows in set (0.00 sec) //What baffled me is that why the "select USER()" and "select @@version_comment limit ?" were not in the hostgroup "20"? zlm@192.168.56.100: [(none)]>select @@hostname;
+------------+
| @@hostname |
+------------+
| zlm2 |
+------------+
row in set (0.00 sec) //The select operation has been executed on slave zlm2. admin@127.0.0.1: [(none)]>select hostgroup,schemaname,username,substr(digest_text,,-),count_star from stats_mysql_query_digest;
+-----------+------------+----------+-----------------------------------+------------+
| hostgroup | schemaname | username | substr(digest_text,,-) | count_star |
+-----------+------------+----------+-----------------------------------+------------+
| | zlm | zlm | update test set name=? where id=? | |
| | zlm | zlm | select * from test | |
| | zlm | zlm | show tables | |
| | zlm | zlm | select USER() | |
| | zlm | zlm | select @@hostname | |
| | zlm | zlm | insert into test values(?,?) | |
| | zlm | zlm | select @@version_comment limit ? | |
+-----------+------------+----------+-----------------------------------+------------+
rows in set (0.00 sec) //The new statement of "select @@hostname" was put into hostgroup "20" correctly.
 

ProxySQL读写分离测试(续)的更多相关文章

  1. MySQL ProxySQL读写分离实践

    目的 在上一篇文章MySQL ProxySQL读写分离使用初探里初步介绍了ProxySQL的使用,本文继续介绍它的一些特点和DBProxy的性能差异.深入一些去了解ProxySQL,通过测试来说明Pr ...

  2. ProxySQL读写分离

    我们首先看一下自己的环境: MHA已经搭建: master: slave: slave: MHA manager在172.16.16.34,配置文件如下: [root@localhost bin]# ...

  3. mysqlfailover高可用与proxysql读写分离配置

    proxysql官方推荐两种高可用方案: 1.MHA+proxysql 2.mysqlrpladmin+proxysql MySQLfailover工具包含在mysqlrpladmin工具中,所以两者 ...

  4. MHA+ProxySQL 读写分离高可用

    文档结构如下: 1.ProxySQL说明 ProxySQL是mysql的一款中间件的产品,是灵活的mysql代理层,可以实现读写分离,支持query路由器的功能,支持动态指定sql进行缓存,支持动态加 ...

  5. MySQL ProxySQL读写分离使用初探

    目的 在美团点评DBProxy读写分离使用说明文章中已经说明了使用目的,本文介绍ProxySQL的使用方法以及和DBProxy的性能差异.具体的介绍可以看官网的相关说明,并且这个中间件也是percon ...

  6. ProxySQL 读写分离实践

    前言 ProxySQL是一个高性能的MySQL中间件,拥有强大的规则引擎.具有以下特性: 连接池,而且是 multiplexing 主机和用户的最大连接数限制 自动下线后端DB 延迟超过阀值 ping ...

  7. Proxysql读写分离配置

    ProxySQL是Percona主推的读写分离中间件,下载地址为: https://www.percona.com/downloads/proxysql/ 一.安装 1:下载 wget https:/ ...

  8. ProxySQL读写分离代理

    实现ProxySQL反向代理Mysql读写分离 简介 ProxySQL相当于小型的数据库,在磁盘上有存放数据库的目录:ProxySQL用法和mysql相似 启动ProxySQL后会有两个监听端口: 6 ...

  9. ProxySQL 读写分离方法

    转载自:https://www.jianshu.com/p/597b840bf70c (使用正则表达式实现基本的读/写分离) 在这一部分,我将通过一个示例来演示如何通过正则表达式来实现读/写分离. 首 ...

随机推荐

  1. 【遥感专题系列】微波遥感(二、合成孔径雷达SAR基础)

    目前使用最广的成像雷达系统就是合成孔径雷达(Synthetic Aperture Radar:SAR),SAR几乎成为了雷达的代名词.本文从应用角度介绍SAR系统的基本知识. 本文主要包括: SAR基 ...

  2. sudo: Sorry, you must have a tty to run

    The requiretty option in sudoers file The requiretty if set in sudo config file sudoers, sudo will o ...

  3. UnitySendMessage

    SendMessage查找的方法是在自身当中去查找 SendMessageUpwards查找的方法是在自身和父类中去查找,如果父类还有父类,继续查找,知道找到根节点为止. BroadcastMessa ...

  4. 【luogu P1113 杂务】 题解

    题目链接:https://www.luogu.org/problemnew/show/P1113 菜 #include <queue> #include <cstdio> #i ...

  5. Java并发程序基础

    Thread.stop() 直接终止线程,并且会立即释放这个线程所持有的锁. Thread.interrupt() 并不会是线程立即退出,而是给线程发送一个通知,告知目标线程,有人希望你退出啦,至于目 ...

  6. webapi2返回 已拒绝为此请求授权。

    开始用的webapi2中是没有问题的,后来再项目中加了个过滤器并继承了AuthorizeAttribute 然后在全球文件中注册你的过滤器,让每次执行的时候都会进来 我项目中只重写了OnAuthori ...

  7. SpringBoot学习16:springboot整合junit单元测试

    1.创建maven项目,修改pom.xml文件 <!--springboot项目依赖的父项目--> <parent> <groupId>org.springfram ...

  8. CF294C Shaass and Lights(排列组合)

    题目描述 There are n n n lights aligned in a row. These lights are numbered 1 1 1 to n n n from left to ...

  9. 青蛙的约会(exgcd/扩展欧几里得)

    题目描述 两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面.它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止.可是它们出发之前忘记了一件很重要的事情,既没有问清 ...

  10. 关于J2EE里面getContextPath()和getRealPath()的区别

    一直老搞不清楚这两个方法的区别,只知道他们都是拿来获取地址的.今天特意写了个小demo试了一下,代码如下: @Override protected void service(HttpServletRe ...