环境前提:java (负载均衡在主从复制环境下针对从库池,读写分离不需要主从复制,有也需要关掉服务才有测试效果)
amoeba是阿里沿用的mysql中间件,
下载包 amoeba-mysql-3.0.5-RC-distribution.zip
解压到/usr/src/
主要两个配置文件 dbServer.xml 控制代理端和逻辑库池间的关系 amoeba.xml控制amoeba的连接端口和密码
dbServers.xml 多个数据源,多个数据库
amoeba.xml 启动参数,谁负责读,谁负责写,谁负责负载均衡
[root@mycat3 ~]# vim /usr/src/amoeba/conf/dbServers.xml
<?xml version="1.0" encoding="gbk"?>
<!DOCTYPE amoeba:dbServers SYSTEM "dbserver.dtd">
<amoeba:dbServers xmlns:amoeba="http://amoeba.meidusa.com/">
<!--
Each dbServer needs to be configured into a Pool,
If you need to configure multiple dbServer with load balancing that can be simplified by the following configuration:
such as 'multiPool' dbServer
-->
<dbServer name="abstractServer" abstractive="true">
<factoryConfig class="com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory">
<property name="connectionManager">${defaultManager}</property>
<property name="sendBufferSize">64</property>
<!--
Each dbServer needs to be configured into a Pool,
If you need to configure multiple dbServer with load balancing that can be simplified by the following configuration:
such as 'multiPool' dbServer
-->
<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">wkbbs</property>
<!-- mysql user -->
<property name="user">rs</proper