1. 实施环境:

    master(amoeba):192.168.122.201

         安装:java-1.7.0-openjdk.x86_64,mysql-server,amoeba-mysql-3.0.5-RC-distribution.zip

    slave:192.168.122.202

        安装:mysql-server

  2. 配置主从master与slave的主从环境(略过)

  3. master与slave上创建用于amoeba连接数据库的授权用户:

    grant all privileges on *.* to amoeba@'%' identified by 'amoeba';

  4. amoeba的dbServer.xml配置文件修改:

    <dbServer name="abstractServer" abstractive="true">
                      <factoryConfig class="com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory">
                              <property name="connectionManager">${defaultManager}</property>
                             <property name="sendBufferSize">64</property>
                             <property name="receiveBufferSize">128</property>
                             <!-- mysql port -->
                             <property name="port">3306</property>
                             <!-- mysql schema -->
                             <property name="schema">test</property>
                             <!-- mysql user -->
                             <property name="user">amoeba</property>
                             <property name="password">amoeba</property>

                     </factoryConfig>

       #红色部分表示amoeba连接主从mysql的端口,操作的库(这个地方好像只要grant授权足够,可以忽略这块),用户名及密码(即步骤3创建的用户名和密码)

    <dbServer name="master"  parent="abstractServer">
                     <factoryConfig>
                             <!-- mysql ip -->
                             <property name="ipAddress">192.168.122.201</property>
                     </factoryConfig>
             </dbServer>
             <dbServer name="slave"  parent="abstractServer">
                     <factoryConfig>
                             <!-- mysql ip -->
                             <property name="ipAddress">192.168.122.202</property>
                     </factoryConfig>
             </dbServer>

      #定义mysql主机

    <dbServer name="slavePool" virtual="true">
                     <poolConfig class="com.meidusa.amoeba.server.MultipleServerPool">
                             <!-- Load balancing strategy: 1=ROUNDROBIN , 2=WEIGHTBASED , 3=HA-->
                             <property name="loadbalance">1</property>
                             <!-- Separated by commas,such as: server1,server2,server1 -->
                             <property name="poolNames">slave</property>
                     </poolConfig>
             </dbServer>
     #定义负载均衡策略及主机组

  5. amoeba的amoeba.xml配置文件修改:

    <property name="port">8066</property>
    <property name="ipAddress">0.0.0.0</property>

    #定义amoeba代理服务器端口及绑定ip地址

    <property name="user">amoeba</property>
    <property name="password">amoeba</property>

    #定义amoeba代理服务器的用户名和密码

    <property name="defaultPool">slavePool</property>
    <property name="writePool">master</property>
    <property name="readPool">slave</property>

    #定义读写服务器

  6. 创建amoeba日志存放目录,并修改权限

    mkdir -m a=rwx /usr/local/amoeba/logs

  7. 启动amoeba服务
    /usr/local/amoeba/bin/launcher &

  8. 测试