文章目录
1.环境说明
| ip | 主机 | 服务 |
|---|---|---|
| 192.168.69.134 | 读写分离解析主机 | proxysql |
| 192.168.69.130 | mysql-master | mysql |
| 192.168.69.132 | mysql-master2 | mysql |
| 192.168.69.5 | mysql-slave | mysql |
| 192.168.69.6 | mysql-slave2 | mysql |

把所有主机关闭防火墙和setLinux
[root@proxysql ~]# setenforce 0
[root@proxysql ~]# systemctl stop firewalld
2.安装proxysql和安装mysql和配置主从
安装流程图

2.1给四台mysql安装mariadb
[root@mysql-master ~]# yum -y install mariadb mariadb-server
[root@mysql-master ~]# systemctl start mariadb
[root@mysql-master ~]# systemctl enable mariadb
[root@mysql-master ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 50 *:3306 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
2.2安装proxysql
[root@proxysql ~]# cat <<EOF | tee /etc/yum.repos.d/proxysql.repo
[proxysql_repo]
name= ProxySQL
baseurl=http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/centos/7
gpgcheck=1
gpgkey=http://repo.proxysql.com/ProxySQL/repo_pub_key
EOF
[proxysql_repo]
name= ProxySQL
baseurl=http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/centos/7
gpgcheck=1
gpgkey=http://repo.proxysql.com/ProxySQL/repo_pub_key
[root@proxysql ~]# yum -y install proxysql
[root@proxysql ~]# vi /etc/yum.repos.d/proxysql.repo
[proxysql_repo]
name= ProxySQL
baseurl=http://repo.proxysql.com/ProxySQL/proxysql-1.4.x/centos/7
gpgcheck=1
enabled=1 \\设置开机启动
gpgkey=http://repo.proxysql.com/ProxySQL/repo_pub_key
[root@proxysql ~]# yum -y install mariadb-5.5.60-1.el7_5.x86_64
[root@proxysql ~]# service proxysql start
Starting ProxySQL: 2019-03-14 15:23:54 [INFO] Using config file /etc/proxysql.cnf
DONE!
[root@proxysql ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:6032 *:*
LISTEN 0 128 *:6033 *:*
LISTEN 0 128 *:6033 *:*
LISTEN 0 128 *:6033 *:*
LIS

本文详细介绍了在四台MySQL服务器上通过ProxySQL实现双主双从的读写分离部署过程,包括环境准备、ProxySQL与MySQL安装、主从配置、健康检查账号设置以及读写分离路由规则的设定。最后通过验证确保了读写操作的正确分离。
最低0.47元/天 解锁文章
1843

被折叠的 条评论
为什么被折叠?



