maxscale 安装文档
1. 获取yum源安装maxscale:
yum install -y downloads.mariadb.com/MaxScale/2.…
2. 在主mysql上创建用户:
# 监控账户:
create user scalemon@'%' identified by "123456";
# 路由用户:
create user maxscale@'%' identified by "123456";
grant select on mysql.* to maxscale@'%';
grant show databases on . to maxscale@'%';
3. 按文件中maxscale.cnf修改配置文件:
#我们只用Read-Write-Service,将其他注释。最后开启hink
#maxscale禁用root运行,使用maxscale用户运行
3.01:
#修改文件权限:
chown maxscale /etc/maxscale.*
#启动命令
maxscale -f /etc/maxscale.cnf -U maxscale
4. 异常处理:
#控制台报错一般是用户和目录权限,手动赋权可解
#控制台无报错,去cat /var/log/maxscale/maxscale.log
#以下为服务正常运行日志结尾:
#2022-08-05 02:12:34 notice : Starting a total of 1 services...
#2022-08-05 02:12:34 notice : (Read-Write-Listener) Listening for connections at [::]:4006
#2022-08-05 02:12:34 notice : Service 'Read-Write-Service' started (1/1)
5. 检查服务:
#netstat -tnlp 过滤4006和8989
#4006为服务端口;8989为管理界面,admin/mariadb
#查询节点状态命令:
maxctrl list servers
- 主配如下:
# https://mariadb.com/kb/en/mariadb-maxscale-24/
# Global parameters
#
# Complete list of configuration options:
# https://mariadb.com/kb/en/mariadb-maxscale-24-mariadb-maxscale-configuration-guide/
[maxscale]
threads=auto
admin_secure_gui=false
admin_host=0.0.0.0
# Server definitions
#
# Set the address of the server to the network
# address of a MariaDB server.
#
[server1]
type=server
address=172.16.250.156
port=3306
protocol=MariaDBBackend
[server2]
type=server
address=172.16.250.157
port=3306
protocol=MariaDBBackend
[server3]
type=server
address=172.16.250.158
port=3306
protocol=MariaDBBackend
# Monitor for the servers
#
# This will keep MaxScale aware of the state of the servers.
# MariaDB Monitor documentation:
# https://mariadb.com/kb/en/mariadb-maxscale-24-mariadb-monitor/
[Galera-Monitor]
type=monitor
module=galeramon
servers=server1,server2,server3
user=scalemon
password=123456
monitor_interval=2000
# Service definitions
#
# Service Definition for a read-only service and
# a read/write splitting service.
#
# ReadConnRoute documentation:
# https://mariadb.com/kb/en/mariadb-maxscale-24-readconnroute/
#[Read-Only-Service]
#type=service
#router=readconnroute
#servers=server1
#user=myuser
#password=mypwd
#router_options=slave
# ReadWriteSplit documentation:
# https://mariadb.com/kb/en/mariadb-maxscale-24-readwritesplit/
[Read-Write-Service]
type=service
router=readwritesplit
servers=server1,server2,server3
user=maxscale
password=123456
filters=Hint
# Listener definitions for the services
#
# These listeners represent the ports the
# services will listen on.
#
#[Read-Only-Listener]
#type=listener
#service=Read-Only-Service
#protocol=MariaDBClient
#port=4008
[Read-Write-Listener]
type=listener
service=Read-Write-Service
protocol=MariaDBClient
port=4006
[Hint]
type=filter
module=hintfilter
参考文档:
maxscale安装文档详解_南山深处的技术博客_51CTO博客