MySQL 路由器innodb 集群不平衡读取

问题描述

我在单主模式下设置了一个具有 3 个节点的 InnoDB 集群,并在我的集群前面放置了多个 MysqL 路由器(每个应用服务器一个)以充当网关/负载平衡器。虽然一般的 sql 操作进展顺利,但我注意到尽管使用循环 (RW) 和循环回退 (R) 作为我的路由策略,但负载根本不平衡。

我的测试包括一个简单的节点应用程序,它的 MysqL 连接池为 50,它一遍又一遍地执行一个带有 SELECT 的循环。我得到了这种结果:

所以看起来我的所有节点都至少收到了一些查询,但主节点几乎收到了所有的负载。我在这里做错了吗?难道我不应该通过循环获得更平衡的读取吗?

编辑:在所有节点上运行 show processlist; 之后似乎只有主节点实际上在处理真正的查询。其他节点仅处理 MysqL Router 用户查询...


更多细节:

路由器是 8.0.21(由于 a major bug 而未使用 22)而服务器是 8.0.22

所有路由器都在启动时自动成功启动:

MysqLrouter --bootstrap "bootstrap_user@bootstrap_host:3306" --name "router1" --report-host "router1" --account "router_user" --account-create never --user=MysqLrouter --directory /tmp/MysqLrouter --force --conf-use-gr-notifications

这是我的路由器配置。 /tmp 用于在容器内运行,并且可能随时停止和重新创建,因此在发生这种情况时它会重新启动。

# File automatically generated during MysqL Router bootstrap
# Some values such as the routing_strategy are edited after the automatic bootstrap
[DEFAULT]
name=router1
user=MysqLrouter
logging_folder=
runtime_folder=/tmp/MysqLrouter/run
data_folder=/tmp/MysqLrouter/data
keyring_path=/tmp/MysqLrouter/data/keyring
master_key_path=/tmp/MysqLrouter/MysqLrouter.key
connect_timeout=15
read_timeout=30
dynamic_state=/tmp/MysqLrouter/data/state.json

[logger]
level = INFO

[Metadata_cache:my_cluster]
cluster_type=gr
router_id=1
user=cluster_router
Metadata_cluster=my_cluster
ttl=0.5
auth_cache_ttl=-1
auth_cache_refresh_interval=2
use_gr_notifications=1

[routing:my_cluster_rw]
bind_address=0.0.0.0
bind_port=3306
destinations=Metadata-cache://my_cluster/?role=PRIMARY
routing_strategy=round-robin
protocol=classic

[routing:my_cluster_ro]
bind_address=0.0.0.0
bind_port=3307
destinations=Metadata-cache://my_cluster/?role=SECONDARY
routing_strategy=round-robin-with-fallback
protocol=classic

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)