insertinto mysql_replication_hostgroups ( writer_hostgroup, reader_hostgroup, comment) values (10,20,'proxy'); insertinto mysql_servers(hostgroup_id,hostname,port) values (10,'192.168.0.204',3306); insertinto mysql_servers(hostgroup_id,hostname,port) values (20,'192.168.0.64',3306); UPDATE global_variables SET variable_value='monitor'WHERE variable_name='mysql-monitor_username'; UPDATE global_variables SET variable_value='monitorpassword'WHERE variable_name='mysql-monitor_password'; insertinto mysql_users (username,password,default_hostgroup) values ('proxysql','proxypassword',10); insertinto mysql_query_rules(rule_id,active,match_pattern,destination_hostgroup,apply) values (1,1,'^select.*for update$',10,1); insertinto mysql_query_rules(rule_id,active,match_pattern,destination_hostgroup,apply) values (2,1,'^select',20,1); commit; load mysql servers to runtime; save mysql servers to disk; load mysql variablesto runtime; save mysql variables to disk; load mysql usersto runtime; save mysql users to disk; load mysql queryrulesto runtime; save mysql query rules to disk;
用proxysql用户来登陆,注意端口号这次是6033:
mysql -uproxysql -pproxypassword -h 127.0.0.1 -P 6033
select * from monitor.mysql_server_connect_log; select * from mysql_server_ping_log limit10; select * from mysql_server_read_only_log limit10; select hostgroup,schemaname,username,digest_text,count_star from stats_mysql_query_digest;