我在 2 台服务器(srv50/51)上进行了配置,其中一台是主服务器,第二台是从服务器,
这里是我的配置文件 /etc/maxscale.cnf 的配置:
[Read-Only Service]
type=service
router=readconnroute
servers=server50, server51
user=YYYYYYYYYYYYY
passwd=XXXXXXXXXXXXXX
router_options=slave
[Write-Only Service]
type=service
router=readconnroute
servers=server50, server51
user=YYYYYYYYYYYYY
passwd=XXXXXXXXXXXXXX
router_options=master
[Read-Only Listener]
type=listener
service=Read-Only Service
protocol=MySQLClient
port=4008
[Write-Only Listener]
type=listener
service=Write-Only Service
protocol=MySQLClient
port=4009
当我understool时,router_options查看谁是主人并将写作查询发送给主人
Maxscale(通过 maxadmin)似乎发现了 2 个服务器并了解女巫一个是大师:
MaxScale> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
server51 | 192.168.0.51 | 3306 | 0 | Slave, Running
server50 | 192.168.0.50 | 3306 | 0 | Master, Running
-------------------+-----------------+-------+-------------+--------------------
但是,即使我在我的 Maxscale 只写监听器端口(4009)上本地连接到 Mysql,监听器处于停止模式,这是否正常?
MaxScale> list listeners
Listeners.
---------------------+--------------------+-----------------+-------+--------
Service Name | Protocol Module | Address | Port | State
---------------------+--------------------+-----------------+-------+--------
Read-Only Service | MySQLClient | * | 4008 | Stopped
Write-Only Service | MySQLClient | * | 4009 | Stopped
MaxAdmin Service | maxscaled | * | 6603 | Running
---------------------+--------------------+-----------------+-------+--------
我尝试在 srv51(从)中创建一个数据库,它只在 srv51 上创建,而不是在 srv50 中创建。
我的配置有问题吗?这很奇怪,因为它不是我的第一个集群,并且在其他集群上所有写入都转到主服务器(但侦听器正在运行)。我不太了解“router_options=master”的含义吗?如何开始听众?我更喜欢将 51 保留在写入列表中以检测拓扑变化
===== 更新 =====
看完日志文件 /var/log/maxscale/maxscale1.log 我发现我的监控用户没有正确的密码:
[MySQL Monitor]
type=monitor
module=mysqlmon
servers=server50, server51
user=MONITOR
passwd=MONITOR_PASS
monitor_interval=10000
我更正了用户的密码并重新启动了 maxscale,现在一切都在运行:
MaxScale> list listeners
Listeners.
---------------------+--------------------+-----------------+-------+--------
Service Name | Protocol Module | Address | Port | State
---------------------+--------------------+-----------------+-------+--------
Read-Only Service | MySQLClient | * | 4008 | Running
Write-Only Service | MySQLClient | * | 4009 | Running
MaxAdmin Service | maxscaled | * | 6603 | Running
---------------------+--------------------+-----------------+-------+--------
但是写查询仍然在 Slave 而不是 Master 上完成