maxscale mysql 主从_orchestrator+maxscale+mysql5.7GTID主从切换测试过程

本文档详细记录了使用Maxscale 2.3进行MySQL 5.7 GTID主从切换的测试过程。首先通过yum安装Maxscale,配置包括读写分离和故障转移的maxscale.cnf文件,然后通过maxadmin工具监控服务器状态。在测试过程中,关闭原主节点并以从节点方式重启,Maxscale能自动发现新的主节点并调整服务路由。
摘要由CSDN通过智能技术生成

2、maxscale安装curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup |     sudo bash -s -- --mariadb-maxscale-version="2.3"

yum search maxscale

sudo yum install maxscale

maxkeys /var/lib/maxscale/

maxpasswd /var/lib/maxscale/ 123456

chown maxscale.maxscale /var/lib/maxscale/.secrets

vim /etc/maxscale.cnf

systemctl start maxscale

systemctl status maxscale.service

cd /var/log/maxscale/

vim maxscale.log

systemctl start maxscale

3、maxscale配置文件[root@mgr1 maxscale]# cat /etc/maxscale.cnf

# MaxScale documentation:

# https://mariadb.com/kb/en/mariadb-enterprise/mariadb-maxscale-23/

# Global parameters

#

# Complete list of configuration options:

# https://mariadb.com/kb/en/mariadb-maxscale-23-mariadb-maxscale-configuration-usage-scenarios/

[maxscale]

threads=auto

# Server definitions

#

# Set the address of the server to the network

# address of a MariaDB server.

#

[server1]

type=server

address=192.168.56.14

port=3306

protocol=MariaDBBackend

[server2]

type=server

address=192.168.56.15

port=3306

protocol=MariaDBBackend

[server3]

type=server

address=192.168.56.16

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-23-mariadb-monitor/

[MariaDB-Monitor]

type=monitor

module=mariadbmon

servers=server1,server2,server3

user=orchestrator

password=0FFC28BC3A8F402F10B0B798E347FD9B

monitor_interval=2000

# 当复制slave全部断掉时,maxscale仍然可用,将所有的访问指向master节点

detect_stale_master=true

# Service definitions

#

# Service Definition for a read-only service and

# a read/write splitting service.

#

# ReadConnRoute documentation:

# https://mariadb.com/kb/en/mariadb-maxscale-23-readconnroute/

[Read-Only-Service]

type=service

router=readconnroute

servers=server1,server2,server3

user=orchestrator

password=0FFC28BC3A8F402F10B0B798E347FD9B

router_options=slave

# ReadWriteSplit documentation:

# https://mariadb.com/kb/en/mariadb-maxscale-23-readwritesplit/

[Read-Write-Service]

type=service

router=readwritesplit

servers=server1,server2,server3

user=orchestrator

password=0FFC28BC3A8F402F10B0B798E347FD9B

# This service enables the use of the MaxAdmin interface

# MaxScale administration guide:

# https://mariadb.com/kb/en/mariadb-maxscale-23-maxadmin-admin-interface/

[MaxAdmin-Service]

type=service

router=cli

# 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

[MaxAdmin-Listener]

type=listener

service=MaxAdmin-Service

protocol=maxscaled

socket=default

[root@mgr1 maxscale]#

4、测试过程,把原来的主关闭,并以从库的方式重启,下面是maxscale自动发现的过程状态展示[root@mgr1 maxscale]# maxadmin

MaxScale> list servers

Servers.

-------------------+-----------------+-------+-------------+--------------------

Server             | Address         | Port  | Connections | Status

-------------------+-----------------+-------+-------------+--------------------

server1            | 192.168.56.14   |  3306 |           0 | Slave of External Server, Running

server2            | 192.168.56.15   |  3306 |           0 | Slave of External Server, Running

server3            | 192.168.56.16   |  3306 |           0 | Master, Running

-------------------+-----------------+-------+-------------+--------------------

MaxScale> list servers

Servers.

-------------------+-----------------+-------+-------------+--------------------

Server             | Address         | Port  | Connections | Status

-------------------+-----------------+-------+-------------+--------------------

server1            | 192.168.56.14   |  3306 |           0 | Master, Running

server2            | 192.168.56.15   |  3306 |           0 | Slave of External Server, Running

server3            | 192.168.56.16   |  3306 |           0 | Down

-------------------+-----------------+-------+-------------+--------------------

MaxScale> list servers

Servers.

-------------------+-----------------+-------+-------------+--------------------

Server             | Address         | Port  | Connections | Status

-------------------+-----------------+-------+-------------+--------------------

server1            | 192.168.56.14   |  3306 |           0 | Master, Running

server2            | 192.168.56.15   |  3306 |           0 | Slave of External Server, Running

server3            | 192.168.56.16   |  3306 |           0 | Down

-------------------+-----------------+-------+-------------+--------------------

MaxScale> list servers

Servers.

-------------------+-----------------+-------+-------------+--------------------

Server             | Address         | Port  | Connections | Status

-------------------+-----------------+-------+-------------+--------------------

server1            | 192.168.56.14   |  3306 |           0 | Master, Running

server2            | 192.168.56.15   |  3306 |           0 | Slave of External Server, Running

server3            | 192.168.56.16   |  3306 |           0 | Down

-------------------+-----------------+-------+-------------+--------------------

MaxScale> list servers

Servers.

-------------------+-----------------+-------+-------------+--------------------

Server             | Address         | Port  | Connections | Status

-------------------+-----------------+-------+-------------+--------------------

server1            | 192.168.56.14   |  3306 |           0 | Master, Running

server2            | 192.168.56.15   |  3306 |           0 | Slave of External Server, Running

server3            | 192.168.56.16   |  3306 |           0 | Slave of External Server, Running

-------------------+-----------------+-------+-------------+--------------------

MaxScale> list servers

Servers.

-------------------+-----------------+-------+-------------+--------------------

Server             | Address         | Port  | Connections | Status

-------------------+-----------------+-------+-------------+--------------------

server1            | 192.168.56.14   |  3306 |           0 | Master, Running

server2            | 192.168.56.15   |  3306 |           0 | Slave of External Server, Running

server3            | 192.168.56.16   |  3306 |           0 | Slave of External Server, Running

-------------------+-----------------+-------+-------------+--------------------

MaxScale> list servers

Servers.

-------------------+-----------------+-------+-------------+--------------------

Server             | Address         | Port  | Connections | Status

-------------------+-----------------+-------+-------------+--------------------

server1            | 192.168.56.14   |  3306 |           0 | Master, Running

server2            | 192.168.56.15   |  3306 |           0 | Slave of External Server, Running

server3            | 192.168.56.16   |  3306 |           0 | Slave of External Server, Running

-------------------+-----------------+-------+-------------+--------------------

MaxScale> list servers

Servers.

-------------------+-----------------+-------+-------------+--------------------

Server             | Address         | Port  | Connections | Status

-------------------+-----------------+-------+-------------+--------------------

server1            | 192.168.56.14   |  3306 |           0 | Master, Running

server2            | 192.168.56.15   |  3306 |           0 | Slave of External Server, Running

server3            | 192.168.56.16   |  3306 |           0 | Slave of External Server, Running

-------------------+-----------------+-------+-------------+--------------------

MaxScale> list servers

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值