在mysql主库、从库执行:
grant all on mxyc.* to 'mxycuser'@'192.168.12.71' identified by '123456' with grant option;
Amoeba安装
1、安装jdk环境
./jdk-6u29-linux-x64-rpm.bin
ln -s /usr/java/jdk1.6.0_29/ /usr/java/jdk1.6
vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.6
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
source /etc/profile
2、安装Amoeba
unzip amoeba-mysql-3.0.5-RC-distribution.zip
mv amoeba-mysql-3.0.5-RC /usr/local/amoeba
cd /usr/local/amoeba/conf
vi amoeba.xml
<property name="ipAddress">192.168.12.71</property>
设置登陆amoeba的帐号密码
设置登陆amoeba的帐号密码
<property name="user">root</property>
<property name="password">123qwe</property>
设置读写(这个两行是注释掉的,记得把<!--去掉)
<property name="writePool">server1</property>
<property name="readPool">server2</property>
vi dbServers.xml
修改dbServers.xml,设置数据库端口、登陆MySQL的帐号和密码。
<!-- mysql port -->
<property name="port">3306</property>
<!-- mysql schema -->
<property name="schema">mxyc</property>
<!-- mysql user -->
<property name="user">mxycuser</property>
<property name="password">123456</property>
修改dbServers.xml,设置数据库服务器的别名和服务器IP
<dbServer name="server1" parent="abstractServer">
<factoryConfig>
<!-- mysql ip -->
<property name="ipAddress">192.168.12.28</property>
</factoryConfig>
</dbServer>
<dbServer name="server2" parent="abstractServer">
<factoryConfig>
<!-- mysql ip -->
<property name="ipAddress">192.168.12.29</property>
</factoryConfig>
</dbServer>
修改dbServers.xml,设置ROUNDROBIN(轮询策略):
<dbServer name="multiPool" 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">server1,server2</property>
</poolConfig>
</dbServer>
启动amoeba
/usr/local/amoeba/bin/launcher &
测试登陆:
mysql -uroot -p123456 -h 192.168.12.71 --port 8066