当前位置: 首页 > 工具软件 > Amoeba > 使用案例 >

amoeba-mysql安装

梁丘威
2023-12-01

(一)、安装文件

按照顺序安装文件

jdk-7u25-linux-i586.tar.gz;

amoeba-mysql-binary-2.2.0.tar.gz;

                  

 

(二)、安装jdk1.7

1.打开创建目录

#cd /usr

#mkdir java

#cd java

2.上传文件jdk-7u25-linux-i586.tar.gz到目录

#rz(如果使用的是CRT,不是则使用其他方式)

3.解压jdk-7u25-linux-i586.tar.gz并编译

#tar zxvf jdk-7u25-linux-i586.tar.gz

 

 

(三)、安装amoeba-mysql-binary-2.2.0.tar.gz

       1.打开目录

    #mkdir /usr/local/amoeba

    #cd /usr/local/amoeba

  2.上传文件amoeba-mysql-binary-2.2.0.tar.gz到目录

        #rz(如果使用的是CRT,不是则使用其他方式)

  3.解压amoeba-mysql-binary-2.2.0.tar.gz并编译

        #tar zxvf amoeba-mysql-binary-2.2.0.tar.gz

 

 

(四)、配置用户环境变量

#vi ~/.bash_profile

 

设置为:

 

PATH=$PATH:$HOME/bin:/usr/local/amoeba/bin

JAVA_HOME=/usr/java/jdk1.6.0_32

 

export JAVA_HOME

export PATH

 

立即生效:

 

#source  ~/.bash_profile

 

 

(五)Amoeba for mysql配置

配置Amoeba for mysql的读写分离主要涉及两个文件:

1、/usr/local/amoeba/conf/dbServers.xml

此文件定义由Amoeba代理的数据库如何连接,比如最基础的:主机IP、端口、Amoeba使用的用户名和密码等等。

2、/usr/local/amoeba/conf/amoeba.xml

此文件定义了Amoeba代理的相关配置。

 

dbServers.xml文件配置

abstractServer配置:

 

<dbServername="abstractServer" abstractive="true">

                <factoryConfigclass="com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory">

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

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

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

 

                        <!-- mysql port -->

                        <propertyname="port">3306</property>

 

                        <!-- mysql schema-->

                        <propertyname="schema">dbname</property>

 

                        <!-- mysql user-->

                        <propertyname="user">root</property>

 

                        <!--  mysql password -->

                        <propertyname="password">root</property>

 

                </factoryConfig>

 

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

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

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

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

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

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

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

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

                </poolConfig>

       </dbServer>

 

此部分定义真实mysql服务器的端口,数据库名称,mysql用户及密码。

主从数据库定义:

 

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

                <factoryConfig>

                        <!-- mysql ip -->

                        <propertyname="ipAddress">192.168.0.1</property>

                </factoryConfig>

       </dbServer>

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

                <factoryConfig>

                        <!-- mysql ip -->

                        <propertyname="ipAddress">192.168.0.2</property>

                </factoryConfig>

       </dbServer>

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

                <factoryConfig>

                        <!-- mysql ip -->

                        <propertyname="ipAddress">192.168.0.3</property>

                </factoryConfig>

       </dbServer>

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

                <poolConfigclass="com.meidusa.amoeba.server.MultipleServerPool">

                        <!-- Load balancingstrategy: 1=ROUNDROBIN , 2=WEIGHTBASED , 3=HA-->

                        <propertyname="loadbalance">1</property>

 

                        <!-- Separated bycommas,such as: server1,server2,server1 -->

                        <propertyname="poolNames">Slave1,Slave2</property>

                </poolConfig>

       </dbServer>

 

此部分定义主服务器,从服务器,及从服务器连接池。这里只定义数据库地址,它们的用户及密码就是上面的abstractServer里的设置。注意用来连接真实mysql服务器的用户必须拥有远程连接权限。

 

amoeba.xml配置

amoeba连接验证配置:

 

<propertyname="authenticator">

                                <beanclass="com.meidusa.amoeba.mysql.server.MysqlClientAuthenticator">

 

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

                                        

                                       <property name="password">root</property>

 

                                       <property name="filter">

                                                <beanclass="com.meidusa.amoeba.server.IPAccessController">

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

                                               </bean>

                                       </property>

                                </bean>

                        </property>

 

这里定义连接amoeba时用来验证的用户及密码。

读写分离配置:

 

<propertyname="defaultPool">Master</property>

                <propertyname="writePool">Master</property>

                <propertyname="readPool">virtualSlave</property>

 

defaultPool:配置了默认的数据库节点,一些除了SELECTUPDATEINSERTDELETE的语句都会在defaultPool执行。

writePool :配置了数据库写库,通常配为Master,如这里就配置为之前定义的Master数据库。

readPool :配置了数据库读库,通常配为Slave或者Slave组成的数据库池,如这里就配置之前的virtualSlave数据库池。

 

amoeba启动

启动命令:

 

amoeba start

 

此命令以前台的方式启动,会输出启动时的信息,检查没有错误信息后,中断,并后台运行:

 

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"

 类似资料: