MySQL中间件之ProxySQL(6):管理后端节点 (7)

下面,将添加后端节点、监控后端节点、添加MySQL用户的操作过程抽取出来,算是个步骤总结:

######### 1.添加后端节点 # # insert into mysql_servers(hostgroup_id,hostname,port) values (10,'192.168.100.22',3306), (10,'192.168.100.23',3306), (10,'192.168.100.24',3306); load mysql servers to runtime; save mysql servers to disk; # 查看下各节点是否都是 ONLINE select * from mysql_servers\G ######### 2.在后端MySQL上创建监控用户和处理SQL语句的用户 # # 在后端master节点上执行以下语句 # create user monitor@'192.168.100.%' identified by 'P@ssword1!'; grant replication client on *.* to monitor@'192.168.100.%'; grant all on *.* to root@'192.168.100.%' identified by 'P@ssword1!'; ######### 3.在ProxySQL中配置监控用户 # # set mysql-monitor_username='monitor'; set mysql-monitor_password='P@ssword1!'; # 以上两个set语句等价于下面两个update: update global_variables set variable_value='monitor' where variable_name='mysql-monitor_username'; update global_variables set variable_value='P@ssword1!' where variable_name='mysql-monitor_password'; load mysql variables to runtime; save mysql variables to disk; # 查看下connect和ping的监控是否正常 select * from mysql_server_connect_log order by time_start_us desc limit 6; select * from mysql_server_ping_log order by time_start_us desc limit 6; ######### 4.配置读、写组 # # insert into mysql_replication_hostgroups values(10,20); load mysql servers to runtime; save mysql servers to disk; ######### 5.在ProxySQL中配置MySQL用户 # # insert into mysql_users(username,password,default_hostgroup) values ('root','P@ssword1!',10); load mysql users to runtime; save mysql users to memory; save mysql users to disk; update mysql_users set transaction_persistent=1 where username='root'; load mysql users to runtime; save mysql users to disk;

在后面的文章中,我会介绍以下percona版本的ProxySQL,percona ProxySQL提供了一个管理工具,它能通过额外的配置文件自动化配置上面一大堆的操作,大大简化了初始搭建使用ProxySQL的过程。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzzwpy.html