我有 2 个 mariadb 实例主实例和一个从属实例。复制是mixed
. SLAVE 滞后为 0Seconds_Behind_Master: 0
我有 maxscale 实例,它必须在主从之间拆分 SELECT 查询,但所有 SELECT 查询都发送到主控。
你能帮我解决这个问题吗?
这是我的maxscale.cnf
[maxscale]
threads=auto
[web1]
type=server
address=1.1.1.1
port=3306
protocol=MariaDBBackend
[web2]
type=server
address=1.1.1.2
port=3306
protocol=MariaDBBackend
[MariaDB-Monitor]
type=monitor
module=mariadbmon
servers=web1,web2
user=maxscale
password=XXXXXXXXX
monitor_interval=2000
[Read-Write-Service]
type=service
router=readwritesplit
max_slave_connections=1
servers=web1,web2
user=maxscale
password=XXXXXXX
[Read-Write-Listener]
type=listener
service=Read-Write-Service
protocol=MariaDBClient
port=4006
[MaxAdmin]
type=service
router=cli
[MaxAdmin-Unix-Listener]
type=listener
service=MaxAdmin
protocol=maxscaled
socket=default
[MaxAdmin-Inet-Listener]
type=listener
service=MaxAdmin
protocol=maxscaled
address=localhost
port=6603
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
web1 | 87.120.207.232 | 3306 | 0 | Slave of External Server, Running
web2 | 87.120.207.229 | 3306 | 2 | Master, Running
-------------------+-----------------+-------+-------------+--------------------
这是maxscale的启动消息
Mar 4 13:56:47 qwe maxscale[12932]: syslog logging is enabled.
Mar 4 13:56:47 qwe maxscale[12932]: maxlog logging is enabled.
Mar 4 13:56:47 qwe maxscale[12932]: Using up to 4.67GiB of memory for query classifier cache
Mar 4 13:56:47 qwe maxscale[12932]: Working directory: /var/log/maxscale
Mar 4 13:56:47 qwe maxscale[12932]: The collection of SQLite memory allocation statistics turned off.
Mar 4 13:56:47 qwe maxscale[12932]: Threading mode of SQLite set to Multi-thread.
Mar 4 13:56:47 qwe maxscale[12932]: MariaDB MaxScale 2.4.7 started (Commit: f576680ed9062222f23ec9e6a3f0b23174ed0535)
Mar 4 13:56:47 qwe maxscale[12932]: MaxScale is running in process 12932
Mar 4 13:56:47 qwe maxscale[12932]: Configuration file: /etc/maxscale.cnf
Mar 4 13:56:47 qwe maxscale[12932]: Log directory: /var/log/maxscale
Mar 4 13:56:47 qwe maxscale[12932]: Data directory: /var/lib/maxscale
Mar 4 13:56:47 qwe maxscale[12932]: Module directory: /usr/lib64/maxscale
Mar 4 13:56:47 qwe maxscale[12932]: Service cache: /var/cache/maxscale
Mar 4 13:56:47 qwe maxscale[12932]: Worker message queue size: 1.00MiB
Mar 4 13:56:47 qwe maxscale[12932]: No query classifier specified, using default 'qc_sqlite'.
Mar 4 13:56:47 qwe maxscale[12932]: Loaded module qc_sqlite: V1.0.0 from /usr/lib64/maxscale/libqc_sqlite.so
Mar 4 13:56:47 qwe maxscale[12932]: Query classification results are cached and reused. Memory used per thread: 299.04MiB
Mar 4 13:56:47 qwe maxscale[12932]: The systemd watchdog is Enabled. Internal timeout = 30s
Mar 4 13:56:47 qwe maxscale[12932]: Loading /etc/maxscale.cnf.
Mar 4 13:56:47 qwe maxscale[12932]: /etc/maxscale.cnf.d does not exist, not reading.
Mar 4 13:56:47 qwe maxscale[12932]: Loaded module maxscaled: V2.0.0 from /usr/lib64/maxscale/libmaxscaled.so
Mar 4 13:56:47 qwe maxscale[12932]: [cli] THE 'cli' MODULE AND 'maxadmin' ARE DEPRECATED: Use 'maxctrl' instead
Mar 4 13:56:47 qwe maxscale[12932]: Loaded module cli: V1.0.0 from /usr/lib64/maxscale/libcli.so
Mar 4 13:56:47 qwe maxscale[12932]: Loaded module MariaDBClient: V1.1.0 from /usr/lib64/maxscale/libmariadbclient.so
Mar 4 13:56:47 qwe maxscale[12932]: [readwritesplit] Initializing statement-based read/write split router module.
Mar 4 13:56:47 qwe maxscale[12932]: Loaded module readwritesplit: V1.1.0 from /usr/lib64/maxscale/libreadwritesplit.so
Mar 4 13:56:47 qwe maxscale[12932]: [mariadbmon] Initialise the MariaDB Monitor module.
Mar 4 13:56:47 qwe maxscale[12932]: Loaded module mariadbmon: V1.5.0 from /usr/lib64/maxscale/libmariadbmon.so
Mar 4 13:56:47 qwe maxscale[12932]: Loaded module MariaDBBackend: V2.0.0 from /usr/lib64/maxscale/libmariadbbackend.so
Mar 4 13:56:47 qwe maxscale[12932]: Loaded module mariadbbackendauth: V1.0.0 from /usr/lib64/maxscale/libmariadbbackendauth.so
Mar 4 13:56:47 qwe maxscale[12932]: Encrypted password file /var/lib/maxscale/.secrets can't be accessed (No such file or directory). Password encryption is not used.
Mar 4 13:56:47 qwe maxscale[12932]: Loaded module MaxAdminAuth: V2.1.0 from /usr/lib64/maxscale/libmaxadminauth.so
Mar 4 13:56:47 qwe maxscale[12932]: Loaded module mariadbauth: V1.1.0 from /usr/lib64/maxscale/libmariadbauth.so
Mar 4 13:56:47 qwe maxscale[12932]: Started REST API on [127.0.0.1]:8989
Mar 4 13:56:47 qwe maxscale[12932]: MaxScale started with 16 worker threads, each with a stack size of 8388608 bytes.
Mar 4 13:56:47 qwe maxscale[12932]: Starting a total of 2 services...
Mar 4 13:56:47 qwe maxscale[12932]: Server 'web1' version: 10.4.12-MariaDB-log
Mar 4 13:56:47 qwe maxscale[12932]: Server 'web2' version: 10.2.31-MariaDB-log
Mar 4 13:56:47 qwe maxscale[12932]: [MariaDBAuth] [Read-Write-Service] Loaded 46 MySQL users for listener 'Read-Write-Listener' from server 'web1' with checksum 0x7605b1f5.
Mar 4 13:56:47 qwe maxscale[12932]: Listening for connections at [::]:4006
Mar 4 13:56:47 qwe maxscale[12932]: Service 'Read-Write-Service' started (1/2)
Mar 4 13:56:47 qwe maxscale[12932]: Listening for connections at [localhost]:6603
Mar 4 13:56:47 qwe maxscale[12932]: Listening for connections at [/var/run/maxscale/maxadmin.sock]:0
Mar 4 13:56:47 qwe maxscale[12932]: Service 'MaxAdmin' started (2/2)
Mar 4 13:56:47 qwe maxscale[12932]: Loaded server states from journal file: /var/lib/maxscale/MariaDB-Monitor/monitor.dat
Mar 4 13:56:47 qwe systemd: Started MariaDB MaxScale Database Proxy.