环境
- amoeba需要java环境,配置:略。
- MySQL主从配置:略。
基本架构
- MySQL主:192.168.31.140
- MySQL从:192.168.31.150
- MySQL代理:192.168.31.139
MySQL向代理授权(两台MySQL服务器都需要):
(root@localhost) [(none)] grant all on *.* to \'amoeba\'@\'192.168.31.140\' identified by \'amoeba123\';
(root@localhost) [(none)] flush privileges;
代理配置
[root@ ~]# wget http://jaist.dl.sourceforge.net/project/amoeba/Amoeba%20for%20mysql/amoeba-mysql-1.3.1-BETA.zip
[root@ ~]# mkdir /usr/local/amoeba/ -p
[root@ ~]# mv amoeba-mysql-1.3.1-BETA.zip /usr/local/amoeba/
[root@ ~]# cd /usr/local/amoeba/
[root@ amoeba]# unzip amoeba-mysql-1.3.1-BETA.zip
[root@ amoeba]# chomod +x bin/*
[root@ amoeba]# vim conf/amodeba.xml
# 贴关键配置
<amoeba:configuration xmlns:amoeba="http://amoeba.meidusa.com/">
<server>
<property name="port">3306</property>
<property name="ipaddress">192.168.31.139</property>
***
<property name="user">root</property>
<property name="password">mysql123</property>
<property name="queryTimeout">60</property>
</server>
***
<dbServerList>
<dbServer name="server1">
<factoryConfig class="com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory">
<property name="manager">defaultManager</property>
<property name="port">3306</property>
<property name="ipAddress">192.168.31.140</property>
<property name="schema">test</property>
<property name="user">amoeba</property>
<property name="password">amoeba123</property>
</factoryConfig>
<poolConfig class="com.meidusa.amoeba.net.poolable.PoolableObjectPool">
***
</poolConfig>
</dbServer>
<dbServer name="server2">
<factoryConfig class="com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory">
<property name="manager">defaultManager</property>
<property name="port">3306</property>
<property name="ipAddress">192.168.31.130</property>
<property name="schema">test</property>
<property name="user">amoeba</property>
<property name="password">amoeba123</property>
</factoryConfig>
<poolConfig class="com.meidusa.amoeba.net.poolable.PoolableObjectPool">
***
</poolConfig>
</dbServer>
<dbServer name="master" virtual="true">
<poolConfig class="com.meidusa.amoeba.server.MultipleServerPool">
<property name="loadbalance">1</property>
<property name="poolNames">server1</property>
</poolConfig>
</dbServer>
<dbServer name="slave" virtual="true">
<poolConfig class="com.meidusa.amoeba.server.MultipleServerPool">
<property name="loadbalance">1</property>
<property name="poolNames">server1,server2</property>
</poolConfig>
</dbServer>
</dbServerList>
<queryRouter class="com.meidusa.amoeba.mysql.parser.MysqlQueryRouter">
<property name="ruleConfig">${amoeba.home}/conf/rule.xml</property>
<property name="functionConfig">${amoeba.home}/conf/functionMap.xml</property>
<property name="ruleFunctionConfig">${amoeba.home}/conf/ruleFunctionMap.xml</property>
<property name="LRUMapSize">1500</property>
<property name="defaultPool">server1</property>
<property name="writePool">server1</property>
<property name="readPool">server2</property>
<property name="needParse">true</property>
</queryRouter>
</amoeba:configuration>
[root@ amoeba]# nohup bin/amoeba &
[root@ amoeba]# netstat -lntp | grep 3306
tcp 0 0 ::ffff:192.168.31.139:3306 :::* LISTEN 1898/java