1. 环境说明
软件版本
操作系统:CentOS Linux release 7.3.1611 (Core) (3.10.0-514.el7.x86_64)
MariaDB-server:10.2.30
maxscale:2.3.8
硬件环境
node1 172.16.100.51 maxscale
node2 172.16.100.52 mariadb-server
node3 172.16.100.53 mariadb-server
node3 172.16.100.54 mariadb-server
2. 中间件配置(on node1)
配置文件:/etc/maxscale.cnf
- server定义
[server1]
type=server
address=172.16.100.52
port=3306
protocol=MariaDBBackend
[server2]
type=server
address=172.16.100.53
port=3306
protocol=MariaDBBackend
[server3]
type=server
address=172.16.100.54
port=3306
protocol=MariaDBBackend
- monitor定义
[MariaDB-Monitor]
type=monitor
module=mariadbmon
servers=server1,server2,server3
user=maxscale
password=passwd
monitor_interval=2000
auto_failover = true
auto_rejoin = true
- service定义
[Read-Write-Service]
type=service
router=readwritesplit
servers=server1,server2,server3
user=maxscale
password=passwd
- listener定义
[Read-Write-Listener]
type=listener
service=Read-Write-Service
protocol=MariaDBClient
port=3306
[MaxAdmin-Listener]
type=listener
service=MaxAdmin-Service
protocol=maxscaled
socket=default
3. 主从复制架构配置
mariadb应用系列之(二)基于GTID的主从复制(Replication)
在master节点上添加账号
grant all privileges on *.* to 'maxscale'@'%' identified by 'passwd';
备注:这个账号用于配置maxscale的监听器monitor,服务service;monitor的账号主要用于监控db cluster中各个主机的状态,service中的账号主要用于maxscale与db backend通信时的用户认证。
4. 启动maxscale中间件服务
# systemctl start maxscale.service
# maxctl list servers
┌─────────┬───────────────┬──────┬─────────────┬─────────────────┬───────────┐
│ Server │ Address │ Port │ Connections │ State │ GTID │
├─────────┼───────────────┼──────┼─────────────┼─────────────────┼───────────┤
│ server1 │ 172.16.100.52 │ 3306 │ 0 │ Master, Running │ 0-1000-14 │
├─────────┼───────────────┼──────┼─────────────┼─────────────────┼───────────┤
│ server2 │ 172.16.100.53 │ 3306 │ 0 │ Slave, Running │ 0-1000-14 │
├─────────┼───────────────┼──────┼─────────────┼─────────────────┼───────────┤
│ server3 │ 172.16.100.54 │ 3306 │ 0 │ Slave, Running │ 0-1000-14 │
└─────────┴───────────────┴──────┴─────────────┴─────────────────┴───────────┘
Reference:
1. maxscale安装
2. Monitor配置说明
3. 读写分离配置说明
来源:CSDN
作者:weixin_44260058
链接:https://blog.csdn.net/weixin_44260058/article/details/103782259