Amoeba安装说明

2015/01/16 鼎马科技

Ø
复制amoeba目录到linux服务器

一般复制到：/data/amoeba

Ø
JDK安装

因为程序是JAVA开发的所以要求安装JDK，安装步骤：

复制jdk-7u60-linux-x64.rpm文件到/data/softwares文件夹下，需要开权限

chmod 777 –R /data/softwares

然后安装：

rpm -ivh /data/softwares/jdk-7u60-linux-x64.rpm

会默认装在：/usr/java/jdk1.7.0_60

Ø
程序启动

启动命令：

/data/amoeba/bin/amoeba start 或者后台运行/data/amoeba/bin/amoeba start &

Amoeba启动错误：

#amoeba start

The stack size specified is too small,
Specify at least 160k

Error: Could not create the Java Virtual
Machine.

Error: A fatal exception has occurred.
Program will exit.

解决方法：

打开bin目录下
的amoeba启动文件

# vim amoeba

修改58行的Xss参数：

DEFAULT_OPTS="-server -Xms1024m
-Xmx1024m -Xss128k"

修改为：

DEFAULT_OPTS="-server -Xms1024m
-Xmx1024m -Xss256k"

Ø
程序配置

1.
首先需要配置JAVA_HOME和PATH环境变量

推荐方法：直接在bin/amoeba文件中增加环境变量

export JAVA_HOME=/usr/java/jdk1.7.0_60

export
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

如下图所示：

标准方法：修改/etc/profile文件增加环境变量

vi /etc/profile

export JAVA_HOME=/usr/java/jdk1.6.0_25

export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

#立即生效

source /etc/profile

2.
数据库集群文件：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:

add attribute with name virtual =
"true" in dbServer, but the configuration
does not allow the element with name factoryConfig

such as 'multiPool'
dbServer

-->

<dbServer name="abstractServer"
abstractive="true">

<factoryConfig
class="com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory">

<property
name="manager">${defaultManager}</property>

<property
name="sendBufferSize">64</property>

<property
name="receiveBufferSize">128</property>

<!—mysql数据库端口 -->

<property
name="port">2359</property>

<!--
mysql 默认连接数据库 -->

<property
name="schema">test</property>

<!—mysql登录账号 -->

<property
name="user">dbm</property>

<!--  mysql登录密码 -->

<property
name="password">dbm56!!09</property>

</factoryConfig>

<poolConfig class="com.meidusa.amoeba.net.poolable.PoolableObjectPool">

<property
name="maxActive">500</property>

<property
name="maxIdle">500</property>

<property
name="minIdle">10</property>

<property
name="minEvictableIdleTimeMillis">600000</property>

<property
name="timeBetweenEvictionRunsMillis">600000</property>

<property
name="testOnBorrow">true</property>

<property
name="testOnReturn">true</property>

<property
name="testWhileIdle">true</property>

</poolConfig>

</dbServer>

<dbServer
name="master"
parent="abstractServer">

<factoryConfig>

<!—mysql主机IP
-->

<property
name="ipAddress">121.42.10.157</property>

</factoryConfig>

</dbServer>

<dbServer name="slave1"  parent="abstractServer">

<factoryConfig>

<!--
mysql 主机IP
-->

<property
name="ipAddress">115.28.190.68</property>

</factoryConfig>

</dbServer>

<dbServer
name="slave2"
parent="abstractServer">

<factoryConfig>

<!--
mysql 主机IP
-->

<property
name="ipAddress">121.42.10.157</property>

</factoryConfig>

</dbServer>

<dbServer name="multiPool"
virtual="true">

<poolConfig class="com.meidusa.amoeba.server.MultipleServerPool">

<!-- 负载均衡参数
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:dbServers>

3.
Amoeba配置文件:conf/amoeba.xml

<?xml
version="1.0" encoding="gbk"?>

<!DOCTYPE amoeba:configuration SYSTEM
"amoeba.dtd">

<amoeba:configuration xmlns:amoeba="http://amoeba.meidusa.com/">

<proxy>

<!-- service class must implements com.meidusa.amoeba.service.Service -->

<service
name="Amoeba for Mysql" class="com.meidusa.amoeba.net.ServerableConnectionManager">

<!—amoeba对外监听端口 -->

<property
name="port">2399</property>

<!—监听绑定IP地址-->

<!--

<property
name="ipAddress">127.0.0.1</property>

-->

<property
name="manager">${clientConnectioneManager}</property>

<property
name="connectionFactory">

<bean
class="com.meidusa.amoeba.mysql.net.MysqlClientConnectionFactory">

<property
name="sendBufferSize">128</property>

<property
name="receiveBufferSize">64</property>

</bean>

</property>

<property
name="authenticator">

<bean
class="com.meidusa.amoeba.mysql.server.MysqlClientAuthenticator">

<property
name="user">dbm</property>

<property
name="password">dbm56!!09</property>

<property
name="filter">

<bean
class="com.meidusa.amoeba.server.IPAccessController">

<property
name="ipFile">${amoeba.home}/conf/access_list.conf</property>

</bean>

</property>

</bean>

</property>

</service>

<!--
server class must implements com.meidusa.amoeba.service.Service
-->

<service
name="Amoeba Monitor Server" class="com.meidusa.amoeba.monitor.MonitorServer">

<!--
port -->

<!--  default value: random number

<property
name="port">9066</property>

-->

<!--
bind ipAddress -->

<property
name="ipAddress">127.0.0.1</property>

<property
name="daemon">true</property>

<property
name="manager">${clientConnectioneManager}</property>

<property
name="connectionFactory">

<bean
class="com.meidusa.amoeba.monitor.net.MonitorClientConnectionFactory"></bean>

</property>

</service>

<runtime
class="com.meidusa.amoeba.mysql.context.MysqlRuntimeContext">

<!--
proxy server net IO Read thread size -->

<property
name="readThreadPoolSize">20</property>

<!--
proxy server client process thread size -->

<property
name="clientSideThreadPoolSize">30</property>

<!--
mysql server data packet process thread size -->

<property
name="serverSideThreadPoolSize">30</property>

<!--
per connection cache prepared statement size  -->

<property
name="statementCacheSize">500</property>

<!--
query timeout( default: 60 second , TimeUnit:second)
-->

<property
name="queryTimeout">60</property>

</runtime>

</proxy>

<!--

Each
ConnectionManager will start as thread

manager
responsible for the Connection IO read , Death Detection

-->

<connectionManagerList>

<connectionManager name="clientConnectioneManager"
class="com.meidusa.amoeba.net.MultiConnectionManagerWrapper">

<property
name="subManagerClassName">com.meidusa.amoeba.net.ConnectionManager</property>

<!--

default value is avaliable
Processors

<property
name="processors">5</property>

-->

</connectionManager>

<connectionManager name="defaultManager"
class="com.meidusa.amoeba.net.MultiConnectionManagerWrapper">

<property
name="subManagerClassName">com.meidusa.amoeba.net.AuthingableConnectionManager</property>

<!--

default value is avaliable
Processors

<property
name="processors">5</property>

-->

</connectionManager>

</connectionManagerList>

<!--
default using file loader -->

<dbServerLoader class="com.meidusa.amoeba.context.DBServerConfigFileLoader">

<property
name="configFile">${amoeba.home}/conf/dbServers.xml</property>

</dbServerLoader>

<queryRouter class="com.meidusa.amoeba.mysql.parser.MysqlQueryRouter">

<property
name="ruleLoader">

<bean
class="com.meidusa.amoeba.route.TableRuleFileLoader">

<property
name="ruleFile">${amoeba.home}/conf/rule.xml</property>

<property
name="functionFile">${amoeba.home}/conf/ruleFunctionMap.xml</property>

</bean>

</property>

<property
name="sqlFunctionFile">${amoeba.home}/conf/functionMap.xml</property>

<property
name="LRUMapSize">1500</property>

<property
name="defaultPool">master</property>

<property
name="writePool">master</property>

<property
name="readPool">multiPool</property>

<property
name="needParse">true</property>

</queryRouter>

</amoeba:configuration>

4.

Ø
配置文件