wget http:
//download
.oracle.com
/otn/java/jdk/6u45-b06/jdk-6u45-linux-x64-rpm
.bin
chmod
+x jdk-6u45-linux-x64-rpm.bin
.
/jdk-6u45-linux-x64-rpm
.bin
ln
-s
/usr/java/jdk1
.6.0_45
/usr/java/jdk
編輯~/.bash_profile,添加如下內容
JAVA_HOME=/usr/java/jdk
export JAVA_HOME
export CLASSPATH=.:JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export PATH
安裝Amoeba for mysql
wget http:
//jaist
.dl.sourceforge.net
/project/amoeba/Amoeba
%20for%20mysql
/3
.x
/amoeba-mysql-3
.0.5-RC-distribution.zip
unzip amoeba-mysql-3.0.5-RC-distribution.zip
mv
amoeba-mysql-3.0.5-RC
/usr/local/amoeba
<
dbServer
name
=
"abstractServer"
abstractive
=
"true"
>
- - - - - 省略 - - - - - -
<!-- mysql port -->
<
property
name
=
"port"
>3306</
property
>
<!-- mysql schema -->
<
property
name
=
"schema"
>數據庫名</
property
>
<!-- mysql user -->
<
property
name
=
"user"
>帳號</
property
>
<
property
name
=
"password"
>密碼</
property
>
- - - - - - - - - 省略 - - - - - - -
</
dbServer
>
設置數據庫池,其中Slave1,Slave2做輪詢
<
dbServer
name
=
"Master"
parent
=
"abstractServer"
>
<
factoryConfig
>
<!-- mysql ip -->
<
property
name
=
"ipAddress"
>192.168.0.1</
property
>
</
factoryConfig
>
</
dbServer
>
<
dbServer
name
=
"Slave1"
parent
=
"abstractServer"
>
<
factoryConfig
>
<!-- mysql ip -->
<
property
name
=
"ipAddress"
>192.168.0.2</
property
>
</
factoryConfig
>
</
dbServer
>
<
dbServer
name
=
"Slave2"
parent
=
"abstractServer"
>
<
factoryConfig
>
<!-- mysql ip -->
<
property
name
=
"ipAddress"
>192.168.0.3</
property
>
</
factoryConfig
>
</
dbServer
>
<
dbServer
name
=
"VirtualPool"
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"
>Slave1,Slave2</
property
>
</
poolConfig
>
</
dbServer
>
接下來配置amoeba.xml
<
property
name
=
"authenticateProvider"
>
- - - - - - 省略 - - -
<
property
name
=
"user"
>帳號</
property
>
<
property
name
=
"password"
>密碼</
property
>
<
property
name
=
"filter"
>
- - - - - - 省略 - - -
</
property
>
<
queryRouter
class
=
"com.meidusa.amoeba.mysql.parser.MysqlQueryRouter"
>
- - - - - - 省略 - - - - -
<
property
name
=
"defaultPool"
>Master</
property
>
<
property
name
=
"writePool"
>Master</
property
>
<
property
name
=
"readPool"
>VirtualPool</
property
>
- - - - - - 省略 - - - - -
</
queryRouter
>
讀寫分離到此配置完成,接着啓動amoebe
/usr/local/amoeba2/bin/launcher