3.(MySQL Router+MGR)MySQL Router安装与配置

本文详细介绍了如何配置和使用MySQL Router与InnoDB Cluster进行高可用性和读写分离。主要内容包括生成MySQL Router配置文件,关注端口设置如6446和6447用于经典协议,64460和64470用于X协议。在测试高可用性时,通过模拟故障验证了failover功能。此外,讨论了单主和多主模式下的读写分离,并提到了压测和解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

5. Using MySQL Router with InnoDB Cluster

--bootstrap

5.1 生成MySQL Router配置文件

[root@wn19testcdb1001 ~]# mysqlrouter --bootstrap root@192.168.136.128:13306 --directory /root/mysqlrouter --user=root --conf-use-sockets --force
Please enter MySQL password for root: 
WARNING: The MySQL server does not have SSL configured and metadata used by the router may be transmitted unencrypted.

Bootstrapping MySQL Router instance at '/root/mysqlrouter'...
Checking for old Router accounts
Creating account mysql_router10_zdwlsgpzi879@'%'
MySQL Router  has now been configured for the InnoDB cluster 'testCluster'.

The following connection information can be used to connect to the cluster after MySQL Router has been started with generated configuration..

Classic MySQL protocol connections to cluster 'testCluster':
- Read/Write Connections: localhost:6446
- Read/Write Connections: /root/mysqlrouter/mysql.sock
- Read/Only Connections: localhost:6447
- Read/Only Connections: /root/mysqlrouter/mysqlro.sock

X protocol connections to cluster 'testCluster':
- Read/Write Connections: localhost:64460
- Read/Write Connections: /root/mysqlrouter/mysqlx.sock
- Read/Only Connections: localhost:64470
- Read/Only Connections: /root/mysqlrouter/mysqlxro.sock

查看mysqlrouter配置文件:/etc/mysqlrouter/mysqlrouter.conf

[root@wn19testcdb1001 mysqlrouter]# cat mysqlrouter.conf 
# File automatically generated during MySQL Router bootstrap
[DEFAULT]
user=root
logging_folder=/root/mysqlrouter/log
runtime_folder=/root/mysqlrouter/run
data_folder=/root/mysqlrouter/data
keyring_path=/root/mysqlrouter/data/keyring
master_key_path=/root/mysqlrouter/mysqlrouter.key
connect_timeout=30
read_timeout=30

[logger]
level = INFO

[metadata_cache:testCluster]
router_id=10
bootstrap_server_addresses=mysql://wn19testcdb1001:13306,mysql://wn19testcdb1002:13306,mysql://wn19testcdb1003:13306
user=mysql_router10_zdwlsgpzi879
metadata_cluster=testCluster
ttl=0.5

[routing:testCluster_default_rw]
bind_address=0.0.0.0
bind_port=6446
socket=/root/mysqlrouter/mysql.sock
destinations=metadata-cache://testCluster/default?role=PRIMARY
routing_strategy=round-robin
protocol=classic

[routing:testCluster_default_ro]
bind_address=0.0.0.0
bind_port=6447
socket=/root/mysqlrouter/mysqlro.sock
destinations=metadata-cache://testCluster/default?role=SECONDARY
routing_strategy=round-rob
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值