Implementation of MariaDBProxy read/write splitting _ MySQL

Source: Internet
Author: User
Tags haproxy
MariaDBProxy implementation of read/write splitting MariaDB

Implementation of MariaDB Proxy read/write splitting

1. create an lvm device for storing data directories

Install mysql-proxy-0.8.3

MariaDB details: Click here
MariaDB's: Click here

-------------------------------------- Split line --------------------------------------

Recommended reading:

Install the LAMP (Apache with MariaDB and PHP) http://www.linuxidc.com/Linux/2013-07/86755.htm in CentOS/RHEL/Scientific Linux 6

Haproxy + Keepalived build Weblogic High Availability Load Balancing cluster http://www.linuxidc.com/Linux/2013-09/89732.htm

Keepalived + HAProxy configure high availability load balancing http://www.linuxidc.com/Linux/2012-03/56748.htm

CentOS 6.3 Haproxy + Keepalived + Apache configuration notes http://www.linuxidc.com/Linux/2013-06/85598.htm

Haproxy + KeepAlived WEB cluster on CentOS 6 http://www.linuxidc.com/Linux/2012-03/55672.htm

Haproxy + Keepalived build high availability load balancing http://www.linuxidc.com/Linux/2012-03/55880.htm

-------------------------------------- Split line --------------------------------------

Provide the SysV service script for mysql-proxy. the content is as follows:
#Vim/etc/rc. d/init. d/mysql-proxy

#! /Bin/bash

#

# Mysql-proxy Thisscript starts and stops the mysql-proxy daemon

#

# Chkconfig:-7830

# Processname: mysql-proxy

# Description: mysql-proxy is a proxy daemon for mysql

# Source functionlibrary.

./Etc/rc. d/init. d/functions

Prog = "/usr/local/mysql-proxy/bin/mysql-proxy"

# Sourcenetworking configuration.

If [-f/etc/sysconfig/network]; then

./Etc/sysconfig/network

Fi

# Check thatnetworking is up.

[$ {NETWORKING} = "no"] & exit 0

# Set defaultmysql-proxy configuration.

ADMIN_USER = "admin"

ADMIN_PASSWD = "admin"

ADMIN_LUA_SCRIPT = "/usr/local/mysql-proxy/share/doc/mysql-proxy/admin. lua"

PROXY_OPTIONS = "-- daemon"

PROXY_PID =/var/run/mysql-proxy.pid

PROXY_USER = "mysql-proxy"

# Sourcemysql-proxy configuration.

If [-f/etc/sysconfig/mysql-proxy]; then

./Etc/sysconfig/mysql-proxy

Fi

RETVAL = 0

Start (){

Echo-n $ "Starting $ prog :"

Daemon $ prog $ PROXY_OPTIONS -- pid-file = $ PROXY_PID -- proxy-address = "$ PROXY_ADDRESS" -- user = $ PROXY_USER -- admin-username = "$ ADMIN_USER" -- admin-lua- script = "$ ADMIN_LUA_SCRIPT" -- admin-password = "$ ADMIN_PASSWORD"

RETVAL =$?

Echo

If [$ RETVAL-eq 0]; then

Touch/var/lock/subsys/mysql-proxy

Fi

}

Stop (){

Echo-n $ "Stopping $ prog :"

Killproc-p $ PROXY_PID-d 3 $ prog

RETVAL =$?

Echo

If [$ RETVAL-eq 0]; then

Rm-f/var/lock/subsys/mysql-proxy

Rm-f $ PROXY_PID

Fi

}

# See how we werecalled.

Case "$1" in

Start)

Start

;;

Stop)

Stop

;;

Restart)

Stop

Start

;;

Condrestart | try-restart)

If status-p $ PROXY_PIDFILE $ prog> &/dev/null; then

Stop

Start

Fi

;;

Status)

Status-p $ PROXY_PID $ prog

;;

*)

Echo "Usage: $0 {start | stop | restart | reload | status | condrestart | try-restart }"

RETVAL = 1

;;

Esac

Exit $ RETVAL

Save the preceding content as/etc/rc. d/init. d/mysql-proxy, grant the execution permission, and then add it to the service list.

#Chmod + x/etc/rc. d/init. d/mysql-proxy

#Chkconfig -- add mysql-proxy

For more details, refer to the highlights on the next page.: Http://www.linuxidc.com/Linux/2014-05/101306p2.htm

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.