orchestrator+maxscale+mysql5.7GTID主从切换测试过程
admin
2023-04-15 19:21:55
0

1、orchestrator环境请看上一篇:https://blog.51cto.com/860143/2429558

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


相关内容

热门资讯

科学家预测:“哥斯拉级”厄尔尼... 科学家近日发出警告,太平洋上空正在形成一种被称为“哥斯拉”级的罕见厄尔尼诺气候模式。有科学家预测,这...
200亿美金估值的可灵,值母公... 文 | 影子备忘录 要说今年科技圈最火的赛道,AI短剧绝对排得上号。一部AI仿真人短剧,3人团队、...
多名中国公民在越南乘机遗失财物... 近日,多名中国公民反映在越乘机过程中财物遗失,中国驻胡志明市总领馆提醒中国公民注意:一、强化防范意识...
电视机尺寸一览表70寸长宽 电视机尺寸一览表70寸长宽:一般液晶电视显示屏都是16比9,70寸就是说客它对角线长70寸是106....
东莞一社区推出生育奖励方案,二... 极目新闻记者 柳之萌近日,广东东莞万江街道谷涌社区出台生育奖励方案,对符合条件的二孩家庭一次性奖励1...
80寸液晶电视尺寸长宽多少厘米 80寸液晶电视尺寸长宽多少厘米:80寸的液晶电视大概为181x111厘米,即长度大概在181厘米,宽...
石膏线一般用多久会掉 大家在装修客厅吊顶的时候,一般都会用石膏线来装。石膏线的施工非常方便,而且装修价格也比较便宜,所以很...
10公分石膏线下挂尺寸 10公分石膏线下挂,大概在8公分左右,这样排出来的石膏线才会比较好看,而且边缘也会比较整齐一些,如果...
地漏怎么防臭呢,有专门的防臭地... 地漏下方的排水管要装S型储水湾,也有专门的防臭地漏 非常芯地漏就是防臭地漏,非常芯地漏原理:重...
12名农民工遭遇“车位抵薪”:... 极目新闻记者 舒隆焕陕西西安12名农民工遭遇“车位抵薪”一事有了最新进展。5月12日,极目新闻记者从...