部署Amoeba3 for Mysql


推薦閱讀::::http://docs.hexnova.com/amoeba/
前端

   Amoeba for Mysql軟件,致力於MySQL的分佈式數據庫前端代理層,它主要在應用層訪問MySQL的時候充當SQL路由功能,專一於分佈式數據庫代理層(Database Proxy)開發。座落與Client、DB之間,對客戶端透明。具備負載均衡、高可用性、SQL過濾、讀寫分離、可路由相關的到目標數據庫、可併發請求多臺數據庫合併結果。java


Master:192.168.0.1mysql

Slave1:192.168.0.2
linux

Slave2:192.168.0.3sql

Amoeba:192.168.0.4數據庫

均在Amoeba機器上操做bash

安裝JDK,Amoeba for mysq是基於JAVA環境開發的,因此係統要支持JAVA網絡

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

配置JAVA環境多線程

JKD默認安裝到/usr/java/下併發

建立軟連接

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

Amoeba到此就安裝完畢,接下來就是配置讀寫分離,由於Amoeba3.x較2.x有較大改動,因此貼下個人配置項。

首先,設置conf/dbServer.xml中鏈接的庫名及賬號密碼

< 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

在部署Amoeba時,注意下

1:防火牆要開放8066端口

2:給bin目錄執行權限:chmod +x bin/*

優化性能:

1:在amoeba目錄下有個JVM的配置文件,設置其中的JVM_OPTIONS="-server -Xms1024m -Xmx1024m -Xss256k -XX:PermSize=16m -XX:MaxPermSize=96m"可提高JVM性能,具體大小看各位需求;

2:多線程配置:runtime元素;

3:網絡相關(緩衝區等):connectionFactory

參考:http://zhiliang92.blog.51cto.com/3392968/1294384

相關文章
相關標籤/搜索