Maxscale readwritesplit显示相同数量的连接

Maxscale readwritesplit show the same number of connections

我已经将 Maxscale 设置为 ReadWriteSplit,没有读取到 master(默认)到 Galera 集群(3 个节点)。

#
# Global configuration
#

[maxscale]
threads=auto
local_address=10.1.0.11
query_retries=2

#
# Servers
#

[sql1]
type=server
address=10.1.0.2
port=3306
protocol=MariaDBBackend
persistpoolmax=16
persistmaxtime=300s
priority=1
ssl=required
ssl_ca_cert=/var/lib/maxscale/ssl/ca-cert.pem
ssl_cert=/var/lib/maxscale/ssl/client.pem
ssl_key=/var/lib/maxscale/ssl/client.key

[sql2]
type=server
address=10.1.0.3
port=3306
protocol=MariaDBBackend
persistpoolmax=16
persistmaxtime=300s
priority=2
ssl=required
ssl_ca_cert=/var/lib/maxscale/ssl/ca-cert.pem
ssl_cert=/var/lib/maxscale/ssl/client.pem
ssl_key=/var/lib/maxscale/ssl/client.key

[sql3]
type=server
address=10.1.0.4
port=3306
protocol=MariaDBBackend
persistpoolmax=16
persistmaxtime=300s
priority=3
ssl=required
ssl_ca_cert=/var/lib/maxscale/ssl/ca-cert.pem
ssl_cert=/var/lib/maxscale/ssl/client.pem
ssl_key=/var/lib/maxscale/ssl/client.key

#
# Monitor
#

[monitor]
type=monitor
module=galeramon
servers=sql1,sql2,sql3
user=maxscale
password=324F7B3BE796AD5F4BB2FAD65E1F9052A976701742729400
available_when_donor=true
use_priority=true

#
# Listeners
#

[listener-rw]
type=listener
service=readwritesplit
protocol=MariaDBClient
address=10.1.0.1
port=3306
ssl=required
ssl_ca_cert=/var/lib/maxscale/ssl/ca-cert.pem
ssl_cert=/var/lib/maxscale/ssl/server.pem
ssl_key=/var/lib/maxscale/ssl/server.key

#
# Services
#

[readwritesplit]
type=service
router=readwritesplit
servers=sql1,sql2,sql3
user=maxscale
password=324F74A347291B3BE79956AD5F4BB917701742729400
enable_root_user=1
max_sescmd_history=150

在使用 loader.io 测试一些读取查询时,我总是在所有节点上获得相同数量的连接:

 > maxctrl list servers
┌────────┬───────────┬──────┬─────────────┬─────────────────────────┬───────────────────────────────┐
│ Server │ Address   │ Port │ Connections │ State                   │ GTID                          │
├────────┼───────────┼──────┼─────────────┼─────────────────────────┼───────────────────────────────┤
│ sql1   │ 10.1.0.2  │ 3306 │ 87          │ Master, Synced, Running │ 0-1-12474939,1-1-148225,2-2-2 │
├────────┼───────────┼──────┼─────────────┼─────────────────────────┼───────────────────────────────┤
│ sql2   │ 10.1.0.3  │ 3306 │ 87          │ Slave, Synced, Running  │ 0-2-410,2-2-2                 │
├────────┼───────────┼──────┼─────────────┼─────────────────────────┼───────────────────────────────┤
│ sql3   │ 10.1.0.4  │ 3306 │ 87          │ Slave, Synced, Running  │ 2-2-2                         │
└────────┴───────────┴──────┴─────────────┴─────────────────────────┴───────────────────────────────┘

我不应该期望在节点 2 和 3(从属)上看到大量连接而在节点 1 上看到缓慢的连接数吗?

默认情况下,readwritesplit 创建到所有节点的连接。您需要定义 max_slave_connections=1 以使其仅创建一个从属连接。