我正在尝试使用 MySQL 设置MaxScale读/写拆分路由。
我的流浪设置如下:
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.define 'maxscale' do |haproxy_instance|
haproxy_instance.vm.provision "shell", path: 'provision_maxscale.sh'
haproxy_instance.vm.network "forwarded_port", guest: 80, host: 9901
haproxy_instance.vm.network "forwarded_port", guest: 3306, host: 9906
haproxy_instance.vm.network 'private_network', ip: '192.168.50.101'
end
config.vm.define 'mysql-primary' do |mysql_primary_instance|
mysql_primary_instance.vm.provision "shell", path: 'provision_mysql_primary.sh'
mysql_primary_instance.vm.network "forwarded_port", guest: 3306, host: 9907
mysql_primary_instance.vm.network 'private_network', ip: '192.168.50.100'
end
config.vm.define 'mysql-slave' do |mysql_slave_instance|
mysql_slave_instance.vm.provision "shell", path: 'provision_mysql_primary.sh'
mysql_slave_instance.vm.network "forwarded_port", guest: 3306, host: 9908
mysql_slave_instance.vm.network 'private_network', ip: '192.168.50.99'
end
end
provision_maxscale.sh :
wget https://downloads.mariadb.com/enterprise/pbc3-8y0m/generate/10.0/mariadb-enterprise-repository.deb
dpkg -i mariadb-enterprise-repository.deb
sudo apt-get update
sudo apt-get --force-yes --yes install maxscale
sudo systemctl start maxscale.service
cp /vagrant/maxscale.cnf /etc/maxscale.cnf
sudo systemctl start maxscale.service
sudo service maxscale stop
sudo service maxscale start
maxscale.cnf:
[maxscale]
threads=4
[qla]
type=filter
module=qlafilter
options=/tmp/QueryLog
[fetch]
type=filter
module=regexfilter
match=fetch
replace=select
[RW]
type=service
localhost_match_wildcard_host=1
router=readwritesplit
servers=server1,server2
user=lorefnon
passwd=password
max_slave_connections=100%
router_options=slave_selection_criteria=LEAST_CURRENT_OPERATIONS
[RR]
type=service
localhost_match_wildcard_host=1
router=readconnroute
router_options=synced
servers=server1,server2
user=lorefnon
passwd=password
[Debug Interface]
type=service
router=debugcli
[CLI]
type=service
router=cli
[RWlistener]
type=listener
service=RW
protocol=MySQLClient
# address=10.69.179.54
port=3307
[RRlistener]
type=listener
service=RR
protocol=MySQLClient
# address=10.69.179.54
port=3308
[Debug Listener]
type=listener
service=Debug Interface
protocol=telnetd
address=127.0.0.1
port=4442
[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
address=127.0.0.1
port=6603
[server1]
type=server
address=192.168.50.100
port=3306
protocol=MySQLBackend
[server2]
type=server
address=192.168.50.99
port=3306
protocol=MySQLBackend
用于设置 mysql 复制的供应商取自这篇文章。而且我已经验证了复制功能正常,并且 maxscale 实例可以连接到两个 mysql 实例中的每一个。
当我尝试连接到拆分路由器时出现以下错误消息:
mysql -u lorefnon -p -P3307 -h 127.0.0.1
-----------------------------------------------------------------------
MariaDB Corporation MaxScale /var/log/maxscale/error1.log Sat Nov 28 11:38:02 2015
-----------------------------------------------------------------------
--- Logging is enabled.
2015-11-28 11:38:13 Error : Couldn't find suitable Master from 2 candidates.
2015-11-28 11:38:13 Error : Failed to create RW session.
任何有关找出问题的帮助,甚至指出我可以在哪里调查为什么没有找到合适的候选人都非常感谢。