<body>

kenshou

天空没有飞过的痕迹,但我已经努力飞过……

« Home | Next » | Next » | Next » | Next » | Next » | Next » | Next » | Next » | Next » | Next »

MySQL Proxy 安装与读写分离体验(主要为转载内容)

转载内容http://blog.csdn.net/yueliangdao0608/archive/2008/05/06/2398655.aspx
-------------------
一、必备软件:
1、LUA
可以去LUA的官方下载:www.lua.org
2、MySQL Proxy
这里有好多二进制版本。
http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/
或者去MYSQL官方下载源代码。
二、软件安装
1、LUA
[[email protected] ~]#tar zxvf lua-5.1.2.tar.gz -C /usr/local
[[email protected] ~]# cd /usr/local/
[[email protected] local]# mv lua-5.1 lua
[[email protected] lua]# cd lua
[[email protected] lua]#make local;make install;
导出环境变量:
[[email protected] lua]#export LUA_CFLAGS="-I/usr/local/include" LUA_LIBS="-L/usr/local/lib -llua -ldl" LDFLAGS="-lm"
2、MySQL Proxy 安装
[[email protected] ~]#tar -zxvf mysql-proxy-0.6.1-linux-rhel4-x86-32bit.tar.gz -C /usr/local/mysql/
[[email protected] ~]#cd /usr/local/mysql
[[email protected] mysql]#mv mysql-proxy-0.6.1-linux-rhel4-x86-32bit/ mysql-proxy
[[email protected] sbin]# export PATH=$PATH:/usr/local/mysql/mysql-proxy/sbin/

3、启动MySQL-Proxy(测试读写分离)
[[email protected]]# mysql-proxy--proxy-read-only-backend-addresses=192.168.0.236:3306--proxy-backend-addresses=192.168.0.235:3306 --proxy-lua-script=/usr/local/mysql/mysql-proxy/share/mysql-proxy/rw-splitting.lua&
[1] 32554
让MYSQL PROXY自动启动的简单脚本
#!/bin/sh
# export PATH=$PATH:/usr/local/mysql-proxy
cd /usr/local/mysql-proxy
./mysql-proxy--proxy-read-only-backend-addresses=192.168.0.236:3306--proxy-backend-addresses=192.168.0.235:3306--proxy-lua-script=rw-splitting.lua >> /tmp/log
------------------------------
注意:在启动的时候把LUA_PATH加入进去,不然会出现找不lua脚本的问题。测试的时候要多启动几个客服端才能测试出来
LUA_PATH="/usr/local/mysql/mysql-proxy/share/mysql-proxy/?.lua" /usr/local/mysql/mysql-proxy/sbin/mysql-proxy --proxy-read-only-backend-addresses=192.168.1.10:3306 --proxy-backend-addresses=192.168.1.9:3306 --proxy-lua-script=/usr/local/mysql/mysql-proxy/share/mysql-proxy/rw-splitting.lua


参考url地址:
1:http://blog.csdn.net/yueliangdao0608/archive/2008/05/06/2398655.aspx
2:http://bbs.chinaunix.net/archiver/tid-1066681.html

标签:

leave a response