MySQL5.7 MHA+MaxScale2.0构建高可用环境(3)

MaxScale2.0
Part1:写在最前
maxscale是mariadb公司开发的一套数据库中间件,可以很方便的实现读写分离方案;并且提供了读写分离的负载均衡和高可用性保障。另外maxscale对于前端应用而言是透明的,我们可以很方便的将应用迁移到maxscale中实现读写分离方案,来分担主库的压力。maxscale也提供了sql语句的解析过滤功能。这里我们主要讲解maxscale的安装、配置以及注意事项。

MySQL5.7 MHA+MaxScale2.0构建高可用环境

Part2:整体架构

MySQL5.7 MHA+MaxScale2.0构建高可用环境

Part3:安装
Maxscale配置很简单
[root@HE3 MHA]# yum -y install maxscale-2.0.1-2.CentOS.6.x86_64.rpm (只在Maxscale上执行)
[root@HE3 ~]# cat /etc/maxscale.cnf
# MaxScale documentation on GitHub:
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Documentation-Contents.md
 
# Global parameters
#
# Number of threads is autodetected, uncomment for manual configuration
# Complete list of configuration options:
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Getting-Started/Configuration-Guide.md
 
[maxscale]
threads=auto
 
# Server definitions
#
# Set the address of the server to the network
# address of a MySQL server.
#
 
[server1]
type=server
address=192.168.1.248
port=3306
protocol=MySQLBackend
myweight=5
 
[server2]
type=server
address=192.168.1.249
port=3306
protocol=MySQLBackend
myweight=5
 
[server3]
type=server
address=192.168.1.100
port=3306
protocol=MySQLBackend
 
# Monitor for the servers
#
# This will keep MaxScale aware of the state of the servers.
# MySQL Monitor documentation:
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Monitors/MySQL-Monitor.md
 
[MySQL Monitor]
type=monitor
module=mysqlmon
servers=server1,server2,server3
user=mysync
passwd=MANAGER
monitor_interval=10000
 
# Service definitions
#
# Service Definition for a read-only service and
# a read/write splitting service.
#
 
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Routers/ReadConnRoute.md
 
#[Read-Only Service]                      ###只读服务
#type=service
#router=readconnroute
#servers=server1,server2,server3
#user=sys_admin
#passwd=MANAGER
#router_options=slave
 
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Routers/ReadWriteSplit.md 
 
[Read-Write Service]                      ####写服务
type=service
router=readwritesplit
enable_root_user=1
servers=server1,server2,server3
user=sys_admin
passwd=MANAGER
weightby=myweight
router_options=slave_selection_criteria=LEAST_GLOBAL_CONNECTIONS
max_slave_connections=1
 
 
# https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Reference/MaxAdmin.md
 
[MaxAdmin Service]
type=service
router=cli
 
 
#[Read-Only Listener]
#type=listener
#service=Read-Only Service
#protocol=MySQLClient
#port=4008                                  ##读服务启动监听 端口4008
 
[Read-Write Listener]
type=listener
service=Read-Write Service
protocol=MySQLClient
port=4006                                  ####写服务启动监听 端口
 
[MaxAdmin Listener]
type=listener
service=MaxAdmin Service
protocol=maxscaled
port=6603                                  ###管理端口

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/b359578e79f9490f04c16ee61984b2a0.html