一:部署mysql-proxy代理服务器
1)安装mariadb官方提供的maxscale软件包
# rpm -ivh maxscale-2.1.2-1.rhel.7.x86_64.rpm # vim /etc/maxscale.cnf
1)分别在主、从数据库服务器上添加授权用户(只在主服务器授权即可 从服务器会自动同步):
mysql> grant replication slave, replication client on *.* to scalemon@'%' identified by “111111”; //创建监控用户
mysql> grant select on mysql.* to maxscale@'%' identified by “111111”; //创建路由用户
mysql> grant all on *.* to student@'%' identified by “111111”; //创建客户端访问用户
2)启动maxscale服务
# maxscale --config=/etc/maxscale.cnf # netstat -utnalp | grep maxscale # kill -9 进程id //通过杀进程的方式停止服务
二:测试配置
1)在客户端192.168.4.120上使用上边授权用户student 连接代理服务器192.168.4.100:
# mysql -h192.168.4.100 -P4006 -ustudent -p111111 MySQL [(none)]> select @@hostname; //显示当前访问的主机
MySQL [(none)]> insert into bbsdb.a values(111);//插入新纪录
2)在主从数据库分别查看
...
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有