91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

ProxySQL

發布時間:2020-07-30 04:04:28 來源:網絡 閱讀:998 作者:Darren_Chen 欄目:MySQL數據庫

proxysql的作用


1.讀寫分離,server可以進行分讀組和寫組

2.動態指定某一個SQL進行cache

3.故障切換,依賴于他的配置動態加載,但是不能自動選主,需要依賴keepalived和MHA

4.配置動態更新

5.一個節點可以跑很多proxysql

6.percona公司的proxy


proxysql端口

監控的端口號:6633

管理端口號:6032


安裝下載

[root@Darren1 tmp]# wget https://github.com/sysown/proxysql/releases/download/v1.4.0/proxysql-1.4.0-1-centos67.x86_64.rpm


[root@Darren1 tmp]# rpm -ivh proxysql-1.4.0-1-centos67.x86_64.rpm

[root@Darren1 tmp]# /etc/init.d/proxysql start

[root@Darren1 tmp]# ps -ef |grep proxy       

root      50769      1  0 05:19 ?        00:00:00 proxysql -c /etc/proxysql.cnf -D /var/lib/proxysql   

root      50770  50769  3 05:19 ?        00:00:00 proxysql -c /etc/proxysql.cnf -D /var/lib/proxysql

root      50798  50261  0 05:20 pts/3    00:00:00 grep proxy


#登陸:

[root@Darren1 proxysql]# mysql -u admin -padmin -h 127.0.0.1 -P6032 --prompt='Admin> '

Admin> show databases;

+-----+---------+-------------------------------+

| seq | name    | file                          |

+-----+---------+-------------------------------+

| 0   | main    |                               |

| 2   | disk    | /var/lib/proxysql/proxysql.db |

| 3   | stats   |                               |

| 4   | monitor |                               |

+-----+---------+-------------------------------+


多層配置系統

(1)允許自動更新配置

(2)大部分配置無需重啟,在運行狀態配置生效

(3)允許回滾錯誤的配置

三層結構圖:

ProxySQL


[1] LOAD MYSQL USERS FROM MEMORY / LOAD MYSQL USERS TO RUNTIME

loads MySQL users from the in-memory database to the runtime data structures

[2] SAVE MYSQL USERS TO MEMORY / SAVE MYSQL USERS FROM RUNTIME

persists the MySQL users from the runtime data structures to the in-memory database

[3] LOAD MYSQL USERS TO MEMORY / LOAD MYSQL USERS FROM DISK

loads MySQL users from the on-disk database to the in-memory database

[4] SAVE MYSQL USERS FROM MEMORY / SAVE MYSQL USERS TO DISK

persists the MySQL users from the in-memory database to the on-disk database

[5] LOAD MYSQL USERS FROM CONFIG

loads from the configuration file the users into the in-memory database

適用于表:

  mysql_users mysql_servers

  mysql_query_rules  

  mysql_variables  

  admin_variables


scheduler計劃任務

scheduler是類似cron的任務調度計劃,允許運行自定義腳本。

主要有兩個表:

admin@127.0.0.1 [main]>SHOW TABLES LIKE '%scheduler%';

+-------------------+

| tables            |

+-------------------+

| scheduler         |

| runtime_scheduler |

+-------------------+

scheduler :可以用來設置調度計劃

runtime_scheduler:只讀,不能配置修改


admin@127.0.0.1 [main]> SHOW CREATE TABLE scheduler\G

*************************** 1. row ***************************

       table: scheduler

Create Table: CREATE TABLE scheduler (

    id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,

    active INT CHECK (active IN (0,1)) NOT NULL DEFAULT 1,

    interval_ms INTEGER CHECK (interval_ms>=100 AND interval_ms<=100000000) NOT NULL,

    filename VARCHAR NOT NULL,

    arg1 VARCHAR,

    arg2 VARCHAR,

    arg3 VARCHAR,

    arg4 VARCHAR,

    arg5 VARCHAR,

    comment VARCHAR NOT NULL DEFAULT '')

In details:

id : unique identifier of the scheduler job

active : if set to 1, the job is active. Otherwise is not

interval_ms : how often (in millisecond) the job will be started. Minimum interval_ms is 100 milliseconds

filename : full path of the executable to be executed

arg1 to arg5 : arguments (maximum 5) that can be passed to the job

comment : an free form text field to annotate the purpose of the job


用戶配置 Users Configuration


定義一個新的用戶:

admin@127.0.0.1 [main]>INSERT INTO mysql_users(username,password) VALUES ('user1','password1');


創建一個由hostgroup,schema的用戶:

admin@127.0.0.1 [main]>INSERT INTO mysql_users(username,password,default_hostgroup,default_schema) VALUES ('user2','password2',10,'sbtest1');


修改user2用戶的最大連接數為100個:

admin@127.0.0.1 [main]>UPDATE mysql_users SET max_connections=100 WHERE username='user2';


修改事務持久化:

admin@127.0.0.1 [main]> UPDATE mysql_users SET transaction_persistent=1 WHERE username='user2';


密碼hash加密:

admin@127.0.0.1 [main]>load mysql users to runtime;

admin@127.0.0.1 [main]>save mysql users from runtime;

admin@127.0.0.1 [main]>save mysql users to disk;


服務配置 (server configuration )

1、往mysql_servers表中添加server時就為其劃分好hostgroup_id(例如0表示寫組,1表示讀組)

2、往mysql_servers表中添加server時不區分hostgroup_id(例如全部設為0),然后通過mysql_replication_hostgroups表中的值,根據proxysql檢測到的各server的read_only變量值來自動為后端server設置hostgroup_id

    強烈推薦用第一種方式: 因為第一種是完全由我們控制的;而第二種假如我們誤將讀server的read_only屬性設置為0,則proxysql會將其重新分配到寫組,這絕對是不期望的。


(1)添加一個新的服務:

admin@127.0.0.1 [main]>insert into mysql_servers(hostgroup_id,hostname,max_connections) values(0,'192.168.91.23',1000);

admin@127.0.0.1 [main]>insert into mysql_servers(hostgroup_id,hostname,max_connections) values(1,'192.168.91.22',1000);

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 |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| 0            | 192.168.91.23 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

| 1            | 192.168.91.22 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+


(2)修改限制連接數max_connections :

admin@127.0.0.1 [main]>UPDATE mysql_servers SET max_connections=10 WHERE hostname='192.168.91.23';


(3)修改權重值weight:

例如:一主兩從的環境,設置不同的權重:

Admin> SELECT hostgroup_id,hostname,weight,max_replication_lag FROM mysql_servers;

+--------------+------------+--------+---------------------+

| hostgroup_id | hostname   | weight | max_replication_lag |

+--------------+------------+--------+---------------------+

| 0            | 172.16.0.1 | 1000   | 30                  |

| 1            | 172.16.0.2 | 1000   | 30                  |

| 1            | 172.16.0.3 | 1000   | 30                  |

| 1            | 172.16.0.1 | 1      | 30                  |

+--------------+------------+--------+---------------------+

上面的情況,如果有讀事物,99.95%將會發送給172.16.0.2和172.16.0.3主機上,0.05%會發送到172.16.0.1主機上,如果172.16.0.2和172.16.0.3變得不可用了,則所有的讀會有172.16.0.1承擔


(4)修改復制延時最大值max_replication_lag :

admin@127.0.0.1 [main]>UPDATE mysql_servers SET max_replication_lag=30 WHERE hostname='192.168.91.23';


(5)打開壓縮,把compression設置為非0

admin@127.0.0.1 [main]>UPDATE mysql_servers SET compression=2 WHERE hostname='192.168.91.23';      

              

(6)優雅的關閉一個服務:

把狀態改變成 status = offline_soft. 

admin@127.0.0.1 [main]>UPDATE mysql_servers SET status='OFFLINE_SOFT' WHERE hostname='192.168.91.23';


(7)刪除一個服務delete即可


在proxysql連接msyql server

[root@Darren1 ~]# mysql -u admin -padmin -h 127.0.0.1 -P6032


#配置DB主機:

admin@127.0.0.1 [main]>insert into mysql_servers(hostgroup_id,hostname) values(0,'192.168.91.23');


admin@127.0.0.1 [main]>insert into mysql_servers(hostgroup_id,hostname) values(1,'192.168.91.22');


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 |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| 0            | 192.168.91.23 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

| 1            | 192.168.91.22 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+


#在mysql主庫上創建監控用戶:

root@localhost [(none)]>create user monitor@'192.168.91.%' identified by 'monitor';

root@localhost [(none)]>grant all on *.* to monitor@'192.168.91.%';


#在proxysql中配置監控用戶和密碼:

admin@127.0.0.1 [(none)]>UPDATE global_variables SET variable_value='monitor' WHERE variable_name='mysql-monitor_username';


admin@127.0.0.1 [(none)]>UPDATE global_variables SET variable_value='monitor' WHERE variable_name='mysql-monitor_password';


#配置監控時間間隔:如mysql-monitor_connect_interval、  mysql-monitor_ping_interval、  mysql-monitor_read_only_interval:


admin@127.0.0.1 [(none)]>UPDATE global_variables SET variable_value='2000' WHERE variable_name IN ('mysql-monitor_connect_interval','mysql-monitor_ping_interval','mysql-monitor_read_only_interval');


admin@127.0.0.1 [(none)]>select * from global_variables where variable_name like 'mysql-monitor_%';

+-----------------------------------------------------+----------------+

| variable_name                                       | variable_value |

+-----------------------------------------------------+----------------+

| mysql-monitor_enabled                               | true           |

| mysql-monitor_connect_timeout                       | 600            |

| mysql-monitor_ping_max_failures                     | 3              |

| mysql-monitor_ping_timeout                          | 1000           |

| mysql-monitor_replication_lag_interval              | 10000          |

| mysql-monitor_replication_lag_timeout               | 1000           |

| mysql-monitor_groupreplication_healthcheck_interval | 5000           |

| mysql-monitor_groupreplication_healthcheck_timeout  | 800            |

| mysql-monitor_username                              | monitor        |

| mysql-monitor_password                              | monitor        |

| mysql-monitor_query_interval                        | 60000          |

| mysql-monitor_query_timeout                         | 100            |

| mysql-monitor_slave_lag_when_null                   | 60             |

| mysql-monitor_wait_timeout                          | true           |

| mysql-monitor_writer_is_also_reader                 | true           |

| mysql-monitor_history                               | 600000         |

| mysql-monitor_connect_interval                      | 2000           |

| mysql-monitor_ping_interval                         | 2000           |

| mysql-monitor_read_only_interval                    | 2000           |

| mysql-monitor_read_only_timeout                     | 500            |

+-----------------------------------------------------+----------------+


admin@127.0.0.1 [(none)]>LOAD MYSQL VARIABLES TO RUNTIME;


admin@127.0.0.1 [(none)]>SAVE MYSQL VARIABLES TO DISK;


admin@127.0.0.1 [(none)]>show tables from monitor;

+------------------------------------+

| tables                             |

+------------------------------------+

| mysql_server_connect               |

| mysql_server_connect_log           |

| mysql_server_group_replication_log |

| mysql_server_ping                  |

| mysql_server_ping_log              |

| mysql_server_read_only_log         |

| mysql_server_replication_lag_log   |

+------------------------------------+


admin@127.0.0.1 [(none)]>SELECT * FROM monitor.mysql_server_connect_log ORDER BY time_start_us DESC LIMIT 10;

+---------------+------+------------------+-------------------------+---------------+

| hostname      | port | time_start_us    | connect_success_time_us | connect_error |

+---------------+------+------------------+-------------------------+---------------+

| 192.168.91.23 | 3306 | 1495445436268761 | 1894                    | NULL          |

| 192.168.91.22 | 3306 | 1495445436267947 | 3301                    | NULL          |

| 192.168.91.23 | 3306 | 1495445434267631 | 601                     | NULL          |

| 192.168.91.22 | 3306 | 1495445434266684 | 1898                    | NULL          |

| 192.168.91.23 | 3306 | 1495445432267286 | 527                     | NULL          |

| 192.168.91.22 | 3306 | 1495445432266457 | 1646                    | NULL          |

+---------------+------+------------------+-------------------------+---------------+


admin@127.0.0.1 [(none)]>SELECT * FROM monitor.mysql_server_ping_log ORDER BY time_start_us DESC LIMIT 10;

+---------------+------+------------------+----------------------+------------+

| hostname      | port | time_start_us    | ping_success_time_us | ping_error |

+---------------+------+------------------+----------------------+------------+

| 192.168.91.23 | 3306 | 1495445542307107 | 147                  | NULL       |

| 192.168.91.22 | 3306 | 1495445542306299 | 504                  | NULL       |

| 192.168.91.23 | 3306 | 1495445540306625 | 173                  | NULL       |

| 192.168.91.22 | 3306 | 1495445540305786 | 596                  | NULL       |

| 192.168.91.23 | 3306 | 1495445538305981 | 165                  | NULL       |

+---------------+------+------------------+----------------------+------------+

admin@127.0.0.1 [(none)]>LOAD MYSQL SERVERS TO RUNTIME;


MySQL replication hostgroups

對應表 mysql_replication_hostgroups

表的作用:配置寫組(比如1)和讀組(比如2),ProxySQL會根據read_only參數把主機分配到對應的讀組合寫組中

如read_only=0 ,分配到hostgroup 1

如read_only=1 , 分配到 hostgroup 2


admin@127.0.0.1 [(none)]>INSERT INTO mysql_replication_hostgroups(writer_hostgroup,reader_hostgroup) VALUES (1,2);


admin@127.0.0.1 [(none)]>select * from  mysql_replication_hostgroups;

+------------------+------------------+---------+

| writer_hostgroup | reader_hostgroup | comment |

+------------------+------------------+---------+

| 1                | 2                | NULL    |

+------------------+------------------+---------+


#現在192.168.91.22是read_only=0,所以hostgroup_id=1:

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 |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| 0            | 192.168.91.23 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

| 1            | 192.168.91.22 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+


admin@127.0.0.1 [(none)]>load mysql servers to runtime;

root@localhost [(none)]>set global read_only=1;


admin@127.0.0.1 [(none)]>SELECT * FROM monitor.mysql_server_read_only_log ORDER BY time_start_us DESC LIMIT 10;

+---------------+------+------------------+-----------------+-----------+-------+

| hostname      | port | time_start_us    | success_time_us | read_only | error |

+---------------+------+------------------+-----------------+-----------+-------+

| 192.168.91.22 | 3306 | 1495449784913364 | 10240           | 1         | NULL  |

| 192.168.91.22 | 3306 | 1495449782913147 | 3161            | 1         | NULL  |

| 192.168.91.22 | 3306 | 1495449780912973 | 5600            | 1         | NULL  |

| 192.168.91.22 | 3306 | 1495449778913003 | 8661            | 1         | NULL  |  |

+---------------+------+------------------+-----------------+-----------+-------+


#現在192.168.91.22是read_only=1,所以被分配到hostgroup_id=2:

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 |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

| 0            | 192.168.91.23 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

| 2            | 192.168.91.22 | 3306 | ONLINE | 1      | 0           | 1000            | 0                   | 0       | 0              |         |

+--------------+---------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+


admin@127.0.0.1 [(none)]>SAVE MYSQL SERVERS TO DISK;


admin@127.0.0.1 [(none)]>save mysql variables to disk;


mysql_users


admin>INSERT INTO mysql_users(username,password,default_hostgroup) VALUES ('user1','147258',0);


admin>INSERT INTO mysql_users(username,password,default_hostgroup) VALUES ('user2','147258',1);


admin>INSERT INTO mysql_users(username,password,default_hostgroup) VALUES ('user3','147258',2);


admin@127.0.0.1 [(none)]>load mysql users to runtime;


admin@127.0.0.1 [(none)]>save mysql users to disk;


#需要在數據庫層面創建對應的用戶名和密碼才能登陸操作數據庫:


root@localhost [(none)]>create user user1@'%' identified by '147258';


root@localhost [(none)]>grant all on *.* to user1@'%';


mysql -u user1 -p147258 -h 127.0.0.1 -P6033


user1@127.0.0.1 [testdb]>select @@hostname;

+------------+

| @@hostname |

+------------+

| Darren1    |

+------------+


#可以用sysbench做測試:

[root@Darren1 ~]# sysbench --time=20 --threads=4  --mysql-host=localhost --mysql-user=user1 --mysql-password='147258' --mysql-port=6033  --mysql-db=sbtest --tables=4 --table_size=1000  /home/mysql/sysbench-1.0.3/src/lua/oltp_read_write.lua prepare


[root@Darren1 ~]# sysbench --time=20 --threads=4  --mysql-host=localhost --mysql-user=user1 --mysql-password='147258' --mysql-port=6033  --mysql-db=sbtest --tables=4 --table_size=1000  /home/mysql/sysbench-1.0.3/src/lua/oltp_read_write.lua run


ProxySQL Statistics

ProxySQL可以通過stats庫收集大量統計信息


admin@127.0.0.1 [(none)]>show tables from stats;

+-----------------------------------+

| tables                            |

+-----------------------------------+

| global_variables                  |

| stats_mysql_commands_counters     |

| stats_mysql_connection_pool       |

| stats_mysql_connection_pool_reset |

| stats_mysql_global                |

| stats_mysql_processlist           |

| stats_mysql_query_digest          |

| stats_mysql_query_digest_reset    |

| stats_mysql_query_rules           |

| stats_mysql_users                 |

+-----------------------------------+


#stats.stats_mysql_connection_pool表:

admin@127.0.0.1 [(none)]>SELECT * FROM stats.stats_mysql_connection_pool;

+-----------+---------------+----------+--------+----------+----------+--------+---------+---------+-----------------+-----------------+------------+

| hostgroup | srv_host      | srv_port | status | ConnUsed | ConnFree | ConnOK | ConnERR | Queries | Bytes_data_sent | Bytes_data_recv | Latency_us |

+-----------+---------------+----------+--------+----------+----------+--------+---------+---------+-----------------+-----------------+------------+

| 0         | 192.168.91.23 | 3306     | ONLINE | 0        | 0        | 0      | 22      | 0       | 0               | 0               | 168        |

| 2         | 192.168.91.22 | 3306     | ONLINE | 0        | 0        | 0      | 0       | 0       | 0               | 0               | 926        |

| 1         | 192.168.91.22 | 3306     | ONLINE | 0        | 0        | 0      | 176     | 0       | 0               | 0               | 926        |

+-----------+---------------+----------+--------+----------+----------+--------+---------+---------+-----------------+-----------------+------------+


#stats_mysql_commands_counters表:

作用:

returns detailed information about the type of statements executed, and the distribution of execution time!


#統計一些sql的操作:

admin@127.0.0.1 [(none)]>select * from stats_mysql_commands_counters;

+-------------------+---------------+-----------+-----------+-----------+---------+---------+----------+----------+-----------+-----------+--------+--------+---------+----------+

| Command           | Total_Time_us | Total_cnt | cnt_100us | cnt_500us | cnt_1ms | cnt_5ms | cnt_10ms | cnt_50ms | cnt_100ms | cnt_500ms | cnt_1s | cnt_5s | cnt_10s | cnt_INFs |

+-------------------+---------------+-----------+-----------+-----------+---------+---------+----------+----------+-----------+-----------+--------+--------+---------+----------+

| ALTER_TABLE       | 0             | 0         | 0         | 0         | 0       | 0       | 0        | 0        | 0         | 0         | 0      | 0      | 0       | 0        |

| ALTER_VIEW        | 0             | 0         | 0         | 0         | 0       | 0       | 0        | 0        | 0         | 0         | 0      | 0      | 0       | 0        |

| ANALYZE_TABLE     | 0             | 0         | 0         | 0         | 0       | 0       | 0        | 0        | 0         | 0         | 0      | 0      | 0       | 0        |

| BEGIN             | 0             | 0         | 0         | 0         | 0       | 0       | 0        | 0        | 0         | 0         | 0      | 0      | 0       | 0        |

| CALL              | 0             | 0         | 0         | 0         | 0       | 0       | 0        | 0        | 0         | 0         | 0      | 0      | 0       | 0        |

| CHANGE_MASTER     | 0             | 0         | 0         | 0         | 0       | 0       | 0        | 0        | 0         | 0         | 0      | 0      | 0       | 0        |

| COMMIT            | 0             | 0         | 0         | 0         | 0       | 0       | 0        | 0        | 0         | 0   

...........


#stats_mysql_query_digest查看執行過的查詢操作

admin@127.0.0.1 [(none)]>SELECT * FROM stats_mysql_query_digest ORDER BY sum_time DESC;

+-----------+--------------------+----------+--------------------+-----------------------------------+------------+------------+------------+----------+----------+----------+

| hostgroup | schemaname         | username | digest             | digest_text                       | count_star | first_seen | last_seen  | sum_time | min_time | max_time |

+-----------+--------------------+----------+--------------------+-----------------------------------+------------+------------+------------+----------+----------+----------+

| 0         | information_schema | user1    | 0x1E092DAEFFBBF262 | select ?                          | 1          | 1495462584 | 1495462584 | 111316   | 111316   | 111316   |

| 0         | testdb             | user1    | 0x3765930C7143F468 | select * from t1                  | 1          | 1495462644 | 1495462644 | 101438   | 101438   | 101438   |

| 0         | information_schema | user1    | 0x99531AEFF718C501 | show tables                       | 2          | 1495462594 | 1495

.......


#查詢表stats_mysql_query_digest_reset的作用就是把表stats_mysql_query_digest清空

admin@127.0.0.1 [(none)]>select * from stats_mysql_query_digest_reset;

admin@127.0.0.1 [(none)]>select * from stats_mysql_query_digest;

Empty set (0.00 sec)


路由規則(MySQL Query Rules)

表: mysql_query_rules

作用:控制讀寫分離

表中:apply=1 means that no further rules are checked if there is a match

#創建一個rule:表示SELECT * FROM t1$開頭的SQL語句會通過hostgroup為0的主機執行:

admin@127.0.0.1 [(none)]>INSERT INTO mysql_query_rules (rule_id,active,username,match_digest,destination_hostgroup,apply) VALUES (10,1,'user1','^SELECT * FROM t1$',0,1);


admin@127.0.0.1 [(none)]>LOAD MYSQL QUERY RULES TO RUNTIME;


[root@Darren1 lua]# mysql -u user1 -p147258 -h 127.0.0.1 -P6033

user1@127.0.0.1 [testdb]>select * from t1;


#可以看到前面的select語句分配到hostgroup為0的服務器上:

admin@127.0.0.1 [(none)]>SELECT hostgroup hg, sum_time, count_star, digest_text FROM stats_mysql_query_digest ORDER BY sum_time DESC;

+----+----------+------------+------------------+

| hg | sum_time | count_star | digest_text      |

+----+----------+------------+------------------+

| 0  | 716      | 1          | select * from t1 |

+----+----------+------------+------------------+


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

承德县| 吉林省| 伊通| 丹寨县| 墨玉县| 崇左市| 阳谷县| 汪清县| 大荔县| 稷山县| 西华县| 同心县| 西丰县| 泰和县| 临朐县| 凯里市| 富顺县| 紫阳县| 达尔| 靖州| 临潭县| 广河县| 封丘县| 婺源县| 女性| 巴青县| 汉源县| 新郑市| 赤城县| 定日县| 绥中县| 保山市| 项城市| 靖州| 乐安县| 武山县| 新蔡县| 昭通市| 北票市| 东宁县| 望城县|