Mysql router 中间件配置

mysql router 解决高可用,读写分离,负载均衡

1. 下载mysql-router

[root@VM-0-16-centos /]# cd /usr/local/

[root@VM-0-16-centos local]# wget https://dev.mysql.com/get/Downloads/MySQL-Router/mysql-router-8.0.18-linux-glibc2.12-x86_64.tar.xz

[root@VM-0-16-centos local]# tar -xvf mysql-router-8.0.18-linux-glibc2.12-x86_64.tar.xz

[root@VM-0-16-centos local]# mv mysql-router-8.0.18-linux-glibc2.12-x86_64 mysql-router

[root@VM-0-16-centos local]# cd mysql-router/

[root@VM-0-16-centos mysql-router]# vim mysqlrouter.conf

 2.添加配置文件 mysqlrouter.conf

 3.修改配置文件 

[root@VM-0-16-centos mysql-router]# vim mysqlrouter.conf
[logger]
level = INFO

[routing:basic_failover]
bind_address = 0.0.0.0
bind_port = 7001
mode = read-write
destinations = mysql-1:3306,mysql-2:3306,mysql-3:3306
routing_strategy = round-robin

[routing:balancing]
bind_address = 0.0.0.0
bind_port = 7002
mode = read-write
destinations = mysql-1:3306,mysql-2:3306,mysql-3:3306
routing_strategy = first-available

4.启动mysql-router

/usr/local/mysql-router/bin/mysqlrouter -c /usr/local/mysql-router/mysqlrouter.conf &

5.查看是否启动成功

[root@VM-0-16-centos sh]# netstat -tnlp

 

看到刚才配置的端口已经启动, 恭喜你配置成功

现在可以把3306端口改成7001或者7002访问了

 

posted @ 2022-04-26 15:55  Alvin-fan  阅读(803)  评论(0编辑  收藏  举报