Home  >  Article  >  Database  >  服务器-mysql5.6读写分离中遇到的问题

服务器-mysql5.6读写分离中遇到的问题

WBOY
WBOYOriginal
2016-06-06 09:34:50773browse

mysql服务器

再做读写分离时,这样做是没问题的
[root@proxy mysql-proxy]# mysql-proxy --daemon --plugins=proxy --log-level=debug --log-file=/var/log/mysql-proxy.log --proxy-read-only-backend-addresses=192.168.85.145:3306 --proxy-backend-addresses=192.168.85.144:3306 --proxy-lua-script=/usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua --plugins=admin --admin-username=admini --admin-password=admini --admin-lua-script=/usr/local/mysql-proxy/share/doc/mysql-proxy/admin.lua

无论是4041端口还是4040端口都能登录上去也添加了后端服务器,日志显示:
[root@proxy mysql-proxy]# tail /var/log/mysql-proxy.log
2015-12-31 10:50:41: (critical) plugin proxy 0.8.5 started
2015-12-31 10:50:41: (critical) plugin admin 0.8.5 started
2015-12-31 10:50:41: (debug) max open file-descriptors = 1024
2015-12-31 10:50:41: (message) proxy listening on port :4040
2015-12-31 10:50:41: (message) added read/write backend: 192.168.85.144:3306
2015-12-31 10:50:41: (message) added read-only backend: 192.168.85.145:3306
2015-12-31 10:50:41: (message) admin-server listening on port :4041

但是这样写不是很麻烦嘛,就想着编写一个配置文件 ,通过读取配置文件中的设置启动mysql-proxy,但是4040端口却无论如何也无法启动

第一次配置文件内容:
[root@proxy ~]# cat /etc/mysql-proxy.conf
[mysql-proxy]
pid-file = /var/run/mysql-proxy.pid
log-file = /var/log/mysql-proxy.log
log-level = debug
plugins = admin
plugins = proxy
#
#Proxy Configuration
user = proxy
proxy-address = 192.168.85.128:4040
proxy-backend-addresses = 192.168.85.144:3306
proxy-read-only-backend-addresses = 192.168.85.145:3306
proxy-lua-script = /usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua
#

Admin Configuration

admin-username = admini
admin-password = admini
admin-lua-script=/usr/local/mysql-proxy/share/doc/mysql-proxy/admin.lua

然后mysql-proxy --daemon --defaults-file=/etc/mysql-proxy.conf

此时的日志:
2016-01-01 16:28:09: (critical) plugin proxy 0.8.5 started
2016-01-01 16:28:09: (debug) max open file-descriptors = 1024
2016-01-01 16:28:09: (message) proxy listening on port 192.168.85.128:4040
2016-01-01 16:28:09: (message) added read/write backend: 192.168.85.144:3306
2016-01-01 16:28:09: (message) added read-only backend: 192.168.85.145:3306
2016-01-01 16:28:09: (debug) now running as user: proxy (496/493)
后端服务器也都加了,4040端口启动了,也能正常登录上去,但是4041端口没有开启;

然后,我改了一下配置文件(其实就是proxy和admin插件的位置换了一下)
第二次配置文件内容:
[mysql-proxy]
pid-file = /var/run/mysql-proxy.pid
log-file = /var/log/mysql-proxy.log
log-level = debug
plugins = proxy
plugins = admin
#
#Proxy Configuration
user = proxy
proxy-address = 192.168.85.128:4040
proxy-backend-addresses = 192.168.85.144:3306
proxy-read-only-backend-addresses = 192.168.85.145:3306
proxy-lua-script = /usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua
#proxy-skip-profiling = true
#

Admin Configuration

#admin-address = 0.0.0.0:4041
admin-username = admini
admin-password = admini
admin-lua-script=/usr/local/mysql-proxy/share/doc/mysql-proxy/admin.lua

再次启动后的日志:
2016-01-01 16:33:35: (critical) plugin admin 0.8.5 started
2016-01-01 16:33:35: (debug) max open file-descriptors = 1024
2016-01-01 16:33:35: (message) admin-server listening on port :4041
2016-01-01 16:33:35: (debug) now running as user: proxy (496/493)
这下子,不仅4040端口未打开,连服务器都未加入,只有4041端口在开着;

以后无论我怎么改配置文件,只要plugins=admin选项在plugins=proxy后都是出现第二种情况也就是只有4041端口打开,只有第一次的配置文件才是4040端口打开,而且怎么都无法做到4040和4041端口同时开启;

怎样才能打开4040和4041端口以及加入后端服务器?还是说配置文件我写错了?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn