MySQL read-write separation

Source: Internet
Author: User
Tags lua mysql commands readline

[Email protected] ~]# yum-y install gcc* gcc-c++* autoconf* automake* zlib* libxml* ncurses-devel* libmcrypt* libtool* FL ex* pkgconfig*

libevent* glib* Readline-devel

[Email protected] ~]# mkdir/opt/install/

[Email protected] ~]# cd/opt/install/

[Email protected] install]# wget http://www.lua.org/ftp/lua-5.1.4.tar.gz

[Email protected] install]# tar zxvf lua-5.2.3.tar.gz

[Email protected] install]# CD lua-5.2.3

[[email protected] install]# make Linux



If this occurs

Lua.c:67:31:fatal error:readline/readline.h:no such file or directory

Description Missing Libreadline-dev Dependency Package

[Plain] View plain copy print? On code to see a snippet derived from my Code slice

[[email protected] install]# make install

[Email protected] install]# export lua_cflags= "-i/usr/local/include" lua_libs= "-L/USR/LOCAL/LIB-LLUA-LDL" ldflags= " -lm "



This line of code, I don't know what it's like. Specifies the environment variable.


Start installing Mysql-proxy below

See if your machine is a 64-bit system before installing

View the CentOS kernel version

[Plain] View plain copy print? On code to see a snippet derived from my Code slice

[Email protected] install]# cat/etc/issue



View Linux Versions

[Plain] View plain copy print? On code to see a snippet derived from my Code slice

[Email protected] install]# cat/proc/version

[Email protected] install]# lsb_release-a



Download Address: http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/

[Plain] View plain copy print? On code to see a snippet derived from my Code slice

[Email protected] install]# Cd/opt/install

[Email protected] install]# wget http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/ Mysql-proxy-0.8.4-linux-rhel5-x86-32bit.tar.gz

[Email protected] install]# tar zxvf mysql-proxy-0.8.4-linux-rhel5-x86-32bit.tar.gz

[Email protected] install]# mkdir/opt/mysql-proxy/

[Email protected] install]# cp/opt/install/mysql-proxy-0.8.4-linux-rhel5-x86-32bit/*/opt/mysql-proxy/

[Email protected] install]# cd/opt/mysql-proxy/

[Email protected] install]# export path= $PATH:/opt/mysql-proxy/bin/






mysql-proxy.conf Configuration

[Mysql-proxy]

#[aemon = Tru]

#keepalive = True

Pid-file =/var/run/mysql-proxy.pid

#log-file =/var/log/mysql-proxy.log

#log-level = Debug

#max-open-files = 1024

Plugins = Admin,proxy

#user = Mysql-proxy

#

#Proxy Configuration

#proxy-address = 0.0.0.0:3307

Proxy-backend-addresses = 192.168.1.144:3306 Read and Write permissions MySQL

proxy-read-only-backend-addresses = 192.168.1.106:3306 Read Only MySQL

Proxy-lua-script =/usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua

Proxy-skip-profiling = True

#

# Admin Configuration

Admin-address = 192.168.1.144:4041 This is the Mysql-proxy management port and IP

Admin-lua-script =/usr/local/mysql-proxy/share/doc/mysql-proxy/admin.lua

Admin-username = Porxy1 This is the user password for Mysql-proxy

Admin-password = 123456



Start/usr/local/mysql-proxy/bin/mysql-proxy--defaults-file=/usr/local/mysql-proxy/mysql-proxy.conf


2016-08-19 17:23:18: (critical) plugin admin 0.8.3 started

2016-08-19 17:23:18: (critical) plugin proxy 0.8.3 started

You will see that both of these LUA scripts are started

Test/usr/local/mysql/bin/mysql-uporxy1-p123456-p4041-h192.168.1.144 This is the user password of the proxy that is logged into the Mysql-proxy management port

MySQL commands are not implemented under this

SELECT * FROM backends Use this command to view MySQL connection status



Backend_ndx | Address | State | Type | UUID | connected_clients |

+-------------+--------------------+-------+------+------+-------------------+

| 1 | 192.168.1.144:3306 | Up | RW |                 NULL | 0 |

| 2 | 192.168.1.106:3306 | Up | Ro |                 NULL | 0





/USR/LOCAL/MYSQL/BIN/MYSQL-UPROXY1-P123456-H192.168.1.144-P4040 is the user port this user password must be a user of MySQL


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.