Mysql-proxy Configuration

Source: Internet
Author: User
Tags lua

On the main library, on the basis of the existing master-slave synchronization configuration, add log configuration items and open the "full-day Log" feature. vim /etc/my.cnflog=mysqlfull.logservice mysqld restartcat /var/lib/mysql/ Mysqlfull.log give Mysqlproxy machine authorization:grant all on *.* to  ' root ' @ '% '  identified by   ' 123123 '; "from the library" on the basis of the existing master-slave synchronization configuration to increase the log configuration items, open the "full-time Log" feature. vim /etc/my.cnflog=mysqlfull.logservice mysqld restartcat /var/lib/mysql/ Mysqlfull.log give Mysqlproxy machine authorization:grant all on *.* to  ' root ' @ '% '  identified by   ' 123123 ';--------------------------------------------------------------------"Build Mysqlproxy" tar zxf  mysql-proxy-0.8.3-linux-rhel5-x86-32bit.tar.gzmv  mysql-proxy-0.8.3-linux-rhel5-x86-32bit    /usr/local/mysql-proxy "Configuration" (1) Modify master configuration cd /usr/local/mysql-proxy/create conf log directory mkdir  conf logvim Create mysql-proxy.conf, add the following content Vim ./conf/mysql-proxy.conf[mysql-proxy] #本机   listening address   and   open ports, default port 4040proxy-address=0.0.0.0:4040# backend MySQL username and password Admin-username=roOtadmin-password=123123#mysql Management commands for   health checks for each host in the backend MySQL cluster  admin-lua-script=/usr/local/mysql-proxy/ share/doc/mysql-proxy/admin-sql.lua# Configuring the main library IP and Port proxy-backend-addresses=192.168.20.181:3306# configuration   from   Library IP and Ports , how many rows you need to configure from the library proxy-read-only-backend-addresses=192.168.20.23:3306proxy-read-only-backend-addresses= 192.168.20.24:3306proxy-read-only-backend-addresses=192.168.20.25:3306# read-write separate LUA script proxy-lua-script=/usr/local/ mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua# Log Path  log-file=/usr/local/mysql-proxy/log/ mysql-proxy.log# Log level log-level=debug# startup parameter, start keepalive with daemon method startup daemon=true#, if the mysql-proxy process terminates abnormally, The mysql-proxy will automatically start. Keepalive=true (2) Modify the Read and write sub-configuration to facilitate testing, because the number of client connections over to Min_idle_connections to let read away from the library,  or read the main library. vim /usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua                 min_idle_connections = 1,                 max_idle_connections = 2,  "Start Mysqlproxy" cd /etc/init.d/vim  Mysqlproxy#!/bin/bash#chkconfig: - 99 23#description: mysql_proxymysql_proxy_home= '/usr/ Local/mysql-proxy ' case  "$"  in start) $mysql _proxy_home/bin/mysql-proxy --defaults-file=$ mysql_proxy_home/conf/mysql-proxy.conf        ;; Stop)         killall -9 mysql-proxy &>/dev/null         ;; Restart)         killall -9 mysql-proxy &>/dev/ null         $mysql _proxy_home/bin/mysql-proxy --defaults-file=$ mysql_proxy_home/conf/mysql-proxy.conf        ;; *)         echo  "Usage: $0 {start|stop|restart}"      &Nbsp;   exit 1esacexit 0 Save after exiting: Chmod +x /etc/init.d/mysqlproxychkconfig  --add mysqlproxy chmod 660 /usr/local/mysql-proxy/conf/mysql-proxy.conf service  mysqlproxy start or under cd /usr/local/mysql-proxy/Direct:   sh mysqlproxy start| stop|restart  can also do start-and-Stop operations [[Email protected] mysql-proxy]# netstat -nlp | grep  4040tcp        0      0  0.0.0.0:4040                 0.0.0.0:*                    listen      23096/mysql-proxy "Test" on the main library: tail -f /var/ Lib/mysql/mysqlfull.log from the Library: Tail -f /var/lib/mysql/mysqlfull.log open several connections to Mysqlproxy 4040 port to do the test, the number of connections is greater than min _idle_connections value, which should be greater than 2. Mysql -u root -h192.168.6.106 -p 4040 -p123123mysql -u root - h192.168.6.106 -p 4040 -p123123mysql -u root -h192.168.6.106 -p 4040  -p123123**** 192.168.6.106 is the IP address of the master library, which is written as the IP address of its main library, which cannot be written as 127.0.0.1 or localhost **** Test the SELECT statement and the Create,insert statement, if only the query (select) is on the library, only write (Create,update,insert) on the main library indicates that the experiment is normal.

This article from "The river, Laugh and Laugh" blog, declined reproduced!

Mysql-proxy Configuration

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.