我已设置 Maxscale (v6.2) 并已连接到 Galera 集群(3 个节点 - MariaDB 10.5)。我正在尝试使用缓存过滤器,但它似乎不起作用。我为所有节点启用了通用日志,每当我运行查询时,我都可以看到查询是从节点而不是 Maxscale 缓存中提供的。
我还注意到,当我使用并发 10 的 mysqlslap 时,我发现每个节点中的通用日志文件显示 10 次连接,实际查询命中为 3。当我使用 Haproxy 进行类似操作时,通用日志显示 3 次连接并命中还有 3. 不确定 Maxscale 是否需要正确设置任何内容。
这是我的 maxscale.cnf
# MaxScale documentation:
# https://mariadb.com/kb/en/mariadb-maxscale-25/
# Global parameters
#
# Complete list of configuration options:
# https://mariadb.com/kb/en/mariadb-maxscale-25-mariadb-maxscale-configuration-guide/
[maxscale]
threads=auto
log_info=true
# Server definitions
#
# Set the address of the server to the network
# address of a MariaDB server.
#
[server1]
type=server
address=1.1.1.1
port=3306
protocol=MariaDBBackend
[server2]
type=server
address=1.1.1.2
port=3306
protocol=MariaDBBackend
[server3]
type=server
address=1.1.1.3
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/maxscale-25-monitors/
[Galera-Monitor]
type=monitor
module=galeramon
servers=server1,server2,server3
user=maxscale
password=XXXXXXXX
monitor_interval=2000
#Galera router service
[Galera-Service]
type=service
router=readwritesplit
servers=server1,server2,server3
user=maxscale
password=XXXXXXXX
lazy_connect=true
#Galera cluster listener
[Galera-Listener]
type=listener
service=Galera-Service
protocol=MariaDBClient
address=0.0.0.0
port=3306
#cache
[Cache]
type=filter
module=cache
storage=storage_inmemory
soft_ttl=300s
hard_ttl=600s
cached_data=shared