暂无图片
暂无图片
4
暂无图片
暂无图片
暂无图片

mysql-读写分离之maxscale

原创 游湖 2022-12-08
582

create user maxscale_monitor@'%' identified by "123456";

grant replication slave, replication client on *.* to maxscale_monitor@'%';

create user maxscale_route@'%' identified by "123456";

GRANT SELECT ON mysql.user TO maxscale_route@'%';

GRANT SELECT ON mysql.db TO maxscale_route@'%';

GRANT SELECT ON mysql.tables_priv TO maxscale_route@'%';

GRANT SHOW DATABASES ON *.* TO maxscale_route@'%';

grant select on mysql.* TO maxscale_route@'%';

# MaxScale documentation:

# https://mariadb.com/kb/en/mariadb-maxscale-25/

# Global parameters

#

# Complete list of configuration options:

# https://mariadb.com/kb/en/mariadb-maxscale-25-mariadb-maxscale-configuration-

guide/

[maxscale]

threads=auto

ms_timestamp=1

# 将日志写入到 syslog 中

# 将日志写入到 maxscale 的日志文件中

maxlog=1

# 不将日志写入到共享缓存中,开启 debug 模式时可打开加快速度

# 记录告警信息

log_warning=1

# 记录 notice

log_notice=1

# 记录 info

log_info=1

# 不打开 debug 模式

log_debug=0

# 日志递增

log_augmentation=1

#basedir=/usr/local/maxscale/

logdir=/usr/local/maxscale/logs/trace/

datadir=/usr/local/maxscale/data/

cachedir=/usr/local/maxscale/cache/

piddir=/usr/local/maxscale/tmp/

# Server definitions

#

# Set the address of the server to the network

# address of a MariaDB server.

#

[server1]

type=server

address=10.4.7.251

port=3306

protocol=MariaDBBackend

serv_weight=4

[server2]

type=server

address=10.4.7.252

port=3306

protocol=MariaDBBackend

serv_weight=6

# Monitor for the servers

#

# This will keep MaxScale aware of the state of the servers.

# MariaDB Monitor documentation:

# https://mariadb.com/kb/en/maxscale-25-monitors/

[MariaDB-Monitor]

type=monitor

module=mariadbmon

servers=server1,server2

user=maxscale_monitor

password=123456

monitor_interval=2000

auto_failover=true

#打开自动故障转移

auto_rejoin=true

#打开自动重新加入

failcount=3

failover_timeout=90

switchover_timeout=90

verify_master_failure=true

master_failure_timeout=10

#防止抖动,maxscale 连接主库有问题,会通过从库连接主库

master_failure_timeout=10

# Service definitions

#

# Service Definition for a read-only service and

# a read/write splitting service.

#

# ReadConnRoute documentation:

# https://mariadb.com/kb/en/mariadb-maxscale-25-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-25-readwritesplit/

[Read-Write-Service]

type=service

router=readwritesplit

servers=server1,server2

user=maxscale_route

password=123456

enable_root_user=1

# 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

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论