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.10.8 Hibernate中解决乱码问题---配置一个过滤器

    在web.xml中配置下 <filter> <filter-name>encodeFilter</filter-name> <filter-class> ...

  2. fast、faster中ap值的计算

    def voc_ap(rec, prec, use_07_metric=False): """ ap = voc_ap(rec, prec, [use_07_metric ...

  3. 【洛谷P1265】公路修建

    公路修建 题目链接 分析题意,可以发现,在(1)的条件下,(2)的情况是不会发生的, 于是直接求MST(Min Set Tree) 然而稠密图克鲁斯卡尔会TLE,建图还会爆空间, 所以用prime,用 ...

  4. 【洛谷P3834】(模板)可持久化线段树 1(主席树)

    [模板]可持久化线段树 1(主席树) https://www.luogu.org/problemnew/show/P3834 主席树支持历史查询,空间复杂度为O(nlogn),需要动态开点 本题用一个 ...

  5. JavaScript面向对象编程之创建对象

    参考资料依旧<JavaScript高级程序设计>,不得不说这本书写的太好了,讲的极为清晰凝练,好书! 先给出重点笔记,好好理解下面的三条笔记,每一句话都很重要: 1.实例的指针仅指向原型, ...

  6. Android学习笔记_70_一个应用程序启动另一个应用程序的Activity

    第一种(我自己写的) :之前在网上看来一些,很多不是我要的可以启动另外一个应用程序的主Activity. //这些代码是启动另外的一个应用程序的主Activity,当然也可以启动任意一个Activit ...

  7. 菜鸟笔记 -- Chapter 6.4 面向对象的三大特性

    6.4.1  三大特性概述 面向对象的三大特性是Java中一个很重要的基本理念. 封装是面向对象的核心思想.将对象的属性和行为封装起来,其载体就是类,类通常对客户隐藏其实现细节,这就是封装的意思.采用 ...

  8. Linux修改时区以及同步时间

    Centos7为例:修改时区 timedatectl list-timezones |grep Shanghai #查找中国时区的完整名称 Asia/Shanghai timedatectl set- ...

  9. iOS之UIImagePickerController显示中文界面

    iOS开发中,我们经常遇到获取拍照.相册中图片的功能,就必然少不了UIImagePickerController,但是我们发现当我们使用它的时候,它的页面是英文的,看着很别扭,国人还是比较喜欢看中文界 ...

  10. http返回值含义

    1xx:信息响应类,表示接收到请求并且继续处理2xx:处理成功响应类,表示动作被成功接收.理解和接受 3xx:重定向响应类,为了完成指定的动作,必须接受进一步处理4xx:客户端错误,客户请求包含语法错 ...