In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
MaxScale is one of the products of MariaDB, which can easily implement read-write separation scheme, and provides load balancing and high availability guarantee for read-write separation.
I. installation and configuration
Premise: first configure the master and slave of mysql, and Maxscale will automatically judge Master and slave according to the master-slave replication information.
Note: mysql cannot be configured to be the master and slave of each other. If they are master and slave, both of them will be considered as slave. In this case, write requests will be rejected and only read requests will be accepted.
1.1. Installation
Download the corresponding rpm package on the official 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
The configuration file of maxscale is: / etc/maxscale.conf, which is composed 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= MySQL backup [server2] type=serveraddress=192.168.10.2port=3306protocol=MySQLBackend# monitoring configuration [MySQL Monitor] type=monitormodule=mysqlmon # monitoring module uses mysqlmon by default, of course, there are other optional modules servers=server1,server2user=admin # admin to monitor the replication status of backend mysql, which must have REPLICATION CLIENT permission passwd=123456monitor_interval=10000# trigger definition note The upper and lower order of the following two sentences cannot be changed, otherwise the script=/opt/mysql_monitor.sh # definition event trigger script executes events=master_down # event trigger when master down Executing the above script, maxscale has built-in many events# read-write separation service [Read-Write Service] type=servicerouter=readwritesplit # read-write separation route pattern servers=server1,server2user=maxscale # this user obtains user information from the back-end mysql and authenticates the client Must have select permission for mysql.user table passwd=maxscalemax_slave_connections=100% max_slave_replication_lag=3600000 # is still available when slave data lags behind master less than 3600 seconds connection_timeout=300 router_options=master_failure_mode=error_on_write # allows master down to drop Slave is still readable # router_options=master_accept_reads=true # allow master to accept read requests [Read-Write Listener] type=listenerservice=Read-Write Serviceprotocol=MySQLClientport=3306# management service configuration [MaxAdmin Service] type=servicerouter=cli# management service listening [MaxAdmin Listener] type=listenerservice=MaxAdmin Serviceprotocol=maxscaledsocket=default
II. Management
Maxscale provides maxadmin commands for viewing management
[root@server] # 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 [root@server ~] # maxadmin list serversServers.- -+-Server | Address | Port | Connections | Status- +-server1 | 192.168.10.1 | 3306 | 0 | Master Runningserver2 | 192.168.10.2 | 3306 | 0 | Slave, Running-+-
III. High availability
Maxscale only provides high availability for read by default. To achieve high availability for writing, you can use two ways:
1. You need to use the Multi-MasterMonitor monitoring module, which is different from the mysqlmon module used above. This module selects Master and Slave through read_only parameters. Combined with the script, you can cancel the read_only attribute of slave and promote slave to Master when you Master fail.
two。 Use the highly available software MMM
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.