Using Maxscale for MySQL read-write separation

Source: Internet
Author: User
Tags sessions

Maxscale is one of MariaDB's products, it is easy to implement read/write separation scheme, and provides load balancing and high availability guarantee for read and write separation.

First, installation configuration

mysql Master and slave, maxscale will Judging by the master-slave Copying of information master and slave

Note: MySQL can not be configured to master from, if mutual master from, both will be considered slave, in this case, the write request is rejected and only the read request is accepted.

1.1. Installation

Download the corresponding RPM package on our website,

wget https://downloads.mariadb.com/MaxScale/2.0.3/centos/6server/x86_64/maxscale-2.0.3-1.centos.6.x86_64.rpmrpm -IVH maxscale-2.0.3-1.centos.6.x86_64.rpm

build configuration file  /etc/ maxscale.conf, the configuration file consists of multiple configuration modules

vi /etc/maxscale.conf# Global configuration: [maxscale]threads=autolog_info=1log_notice=1log_warning=1# backend MySQL definition [server1] type=serveraddress=192.168.10.1port=3306protocol=mysqlbackend[server2]type=serveraddress=192.168.10.2port= 3306protocol=mysqlbackend# Monitoring Configuration [mysql monitor] type=monitormodule=mysqlmon        #监控模块使用mysqlmonservers =server1,server2user=admin            #admin监控后端mysql的复制状况, you must have Replication client permissions       passwd= 123456monitor_interval=10000script=/opt/mysql_monitor.sh     #定义事件触发脚本执行events =master_down              #当master  down, execute the above script [Read-write  service] type=servicerouter=readwritesplit       # Read-Write decoupled routing mode servers=server1,server2user=maxscale     #该用户从后端mysql获取用户信息, authenticates the client, You must have SELECT permissions for mysql.user table    &Nbsp;            passwd=maxscalemax_slave_ connections=100%                    max_slave_replication_lag=3600000    #最大允许slave的数据落后master  3600 seconds, Still available connection_timeout=300                           router_options=master_failure_mode= error_on_write  #允许master  down off, slave still readable #router_options=master_accept_reads=true        #允许master接受读请求 [read-write listener] type=listenerservice=read-write  serviceprotocol=mysqlclientport=3306# Management Service Configuration  [maxadmin service]type=servicerouter=cli# Management Service listener [MaxAdmin  listener]type=listenerservice=maxadmin serviceprotocol=maxscaledsocket=default

Second, management

Maxscale provides the maxadmin command for viewing management

[[Email protected] ~]# maxadmin  list -unknown or missing option  for the list command. Valid sub-commands are:     clients    list all the client connections to maxscale     dcbs       list all the dcbs active  within MaxScale    filters    List all the  filters defined within maxscale    listeners  list all  the listeners defined within maxscale    modules     List all currently loaded modules    monitors    list all monitors    services   list all the  Services defined wiThin maxscale    servers    list all the servers  defined within MaxScale    sessions   List all  the active sessions within maxscale    threads     List the status of the polling threads in maxscale
[[Email protected] ~]# maxadmin list serversservers.-------------------+------------- ----+-------+-------------+--------------------server              | Address         | Port   | Connections | Status               -------------------+-----------------+-------+-------------+--------------------Server1             | 192.168.10.1       |  3306 |           0  | Master, Runningserver2             | 192.168.10.2     |  3306 |          &nbSp; 0 | slave, running-------------------+-----------------+-------+-------------+-------- ------------

Iii. High Availability

Maxscale provides high availability of read and write separations by default, and there are two ways to achieve high availability of writes:

1. Need to use the Multi-mastermonitor monitoring module, different from the Mysqlmon module used above, the module is the READ_ONLY parameters to elect master and slave, combined with the script can be implemented in the master down time, Cancels the slave read_only property so that the slave becomes master

2. Using the highly available software mmm


Using Maxscale for MySQL read-write separation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.