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. 2018.9.30 Java中数组的存储与内存分配

    java 数组与集合的区别 集合:长度可变,可以存放不同类型的元素,只能存放引用类型! 数组:长度固定,只可以存放相同的同种类型的元素,可以存放数据类型也可以存放引用类型! 数组定义的三种方式 // ...

  2. Hibernate多表查询连接操作

    SQL多表操作分类; 1.交叉连接:select*from t_customer cross Join t_order; 2.显示内连接: select*from t_customer c inner ...

  3. ThreadLocal 例子

    /** * 一个ThreadLocal代表一个变量,故其中里只能放一个数据,有两个变量都要线程内共享,则要定义两个ThreadLocal. */ public class ThreadLocalTes ...

  4. Zookeep启动异常:Error contacting service. It is probably not running.

    异常提示: [root@hadoop bin]# ./zkServer.sh status JMX enabled by default Using config: /usr/local/zk/bin ...

  5. require,import区别?

    遵循的模块化规范不一样 模块化规范:即为 JavaScript 提供一种模块编写.模块依赖和模块运行的方案.谁让最初的 JavaScript 是那么的裸奔呢——全局变量就是它的模块化规范. requi ...

  6. emmet工具使用和技巧

    介绍 在前端开发的过程中,一大部分的工作是写 HTML.CSS 代码.特别是手动编写 HTML 代码的时候,效率会特别低下,因为需要敲打很多尖括号,而且很多标签都需要闭合标签等.于是,就有了 Emme ...

  7. 【洛谷P1107】 [BJWC2008]雷涛的小猫

    雷涛的小猫 题目链接 n^2DP比较好想, f[i][j]表示第i棵树高度为j的最大收益 直接从上到下转移即可,每次记录下max f[1~n][j] 用于下面的转移 f[i][j]=max(f[i][ ...

  8. 【luogu P1774 最接近神的人_NOI导刊2010提高(02)】 题解

    题目链接:https://www.luogu.org/problemnew/show/P1774 归并排序求逆序对. #include <cstdio> #define livelove ...

  9. 11java基础继承

    一.           继承相关   18.实现如下类之间的继承关系,并编写Music类来测试这些类. package com.hry.test; public class Instrument { ...

  10. o'Reill的SVG精髓(第二版)学习笔记——第三章

    第三章:坐标系统 3.1视口 文档打算使用的画布区域称作视口.我们可以在<svg>元素上使用width和height属性确定视口的大小.属性的值可以是一个数字,该数字会被当作用户坐标下的像 ...