[root@localhost mysql-proxy]# vim /usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua
......
if not proxy.global.config.rwsplit then
proxy.global.config.rwsplit = {
min_idle_connections = 1,
max_idle_connections = 1,
is_debug = false
}
end
......
启动mysql-proxy
[root@localhost mysql-proxy]# /usr/local/mysql-proxy/bin/mysql-proxy --defaults-file=/etc/mysql-proxy/mysql-proxy.conf
[root@localhost mysql-proxy]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 192.168.91.128:4040 *:*
在192.168.91.35主机上(master),创建管理用户并授权,从服务器同步相应的操作
mysql> grant all on *.* to 'sepa'@'192.168.91.%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
在192.168.91.128主机上使用授权用户登录数据库
[root@localhost mysql-proxy]# yum -y install mariadb
[root@localhost mysql-proxy]# mysql -usepa -p123456 -h192.168.91.128 -P4040
Welcome to the MariaDB monitor. Commands end with ; or \g.
MySQL [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)