Atlas 安装

centos5.5 64Bit

yum install -y libevent-devel lua-devel openssl-devel flex


升级python至2.6

yum install -y xz gettext-devel

xz -d glib-2.32.4.tar.xz
tar xvf glib-2.32.4.tar
cd glib-2.32.4
./configure
make
make install
for a in `find . -name '*.pc'`; do cp $a /usr/lib64/pkgconfig/; done

设置环境变量

export GLIB_CFLAGS="-I/usr/local/include/glib-2.0"
export GLIB_LIBS="-L/usr/local/lib/glib-2.0"
export GMODULE_CFLAGS="-I/usr/local/include"
export GMODULE_LIBS="-L/usr/local/lib"
export GTHREAD_CFLAGS="-I/usr/local/include"
export GTHREAD_LIBS="-L/usr/local/lib"


yum install -y mysql-server mysql-devel
unzip Atlas-master.zip


vim bootstrap.sh

修改mysql_config路径

修改pkgconfig路径

./configure --with-mysql=/usr/bin/mysql_config --prefix=/usr/local/mysql-proxy CFLAGS="-DHAVE_LUA_H -O2" LDFLAGS="-lm -ldl -lcrypto" LUA_CFLAGS="-I/usr/local/include/" LUA_LIBS="-L/usr/local/lib -llua" GLIB_FLAGS="-I/usr/local/include" GLIB_LIBS="-L/usr/local/lib -lglib-2.0" GMODULE_FLAGS="-I/usr/local/include" GMODULE_LIBS="-L/usr/local/lib -lgmodule-2.0" GTHREAD_FLAGS="-I/usr/local/include" GTHREAD_LIBS="-L/usr/local/lib -lgthread-2.0"


cat instance.cnf

[mysql-proxy]
plugins = admin,proxy
admin-username=zwhset
admin-password=123456
admin-lua-script = /usr/local/mysql-proxy/lib/mysql-proxy/lua/admin.lua
proxy-backend-addresses = 192.168.100.210:3306
proxy-read-only-backend-addresses = 192.168.100.211:3306@2
daemon = true
keepalive = true
event-threads = 4
log-level = message
log-path = /usr/local/mysql-proxy/log
instance = test
proxy-address = 0.0.0.0:3306
admin-address = 0.0.0.0:4401
min-idle-connections = 128
charset = utf8


chmod 0600 instance.cnf


#!/usr/bin/python
#!coding:utf8
import _mysql
db=_mysql.connect(host="192.168.100.100",user="proxy2",passwd="-------",db="test",port=3306)
client=0
#min-idle,Db1+DB2=20,DB1,DB2:max_connection=200;
sum_min_idle=30
try:
    while sum_min_idle >= client:
        db.query("""SELECT id,number FROM 200w""")
        (id,char)=db.store_result()[0]
        print "client:%s,id:%s,char:%s" % (client,id,char)
        client = client+1
except:
    print "------------------------"


你可能感兴趣的:(Atlas)