//amoeba安装配置步骤
server6 IP:192.168.10.132
server7 IP:192.168.10.133
分别在132、133安装和验证jdk。
amoeba框架是基于Java SE 1.5开发的,在安装Amoeba之前需要先安装Java环境。经验证,Amoeba在Java SE1.5和JavaSE 1.6上能正常运行。下面介绍安装Java环境的步骤和方法。
1. 首先,在
http://www.oracle.com/technetwork/java/javase/downloads/index.html下载jdk,
我们下载的文件时:jdk-7u9-linux-x64.rpm (适用于linux系统)
2. 给文件授予可执行权限:
chmod 755 jdk-7u9-linux-x64.rpm
3. 安装jdk-7u9-linux-x64.rpm:
rpm -iev jdk-7u9-linux-x64.rpm
4. 安装完毕后,验证java的安装情况:
java -version
server7 上面安装的报如下错误:
[root@server7 ~]# rpm -iev jdk-7u9-linux-x64.rpm
Preparing packages for installation...
jdk-1.7.0_09-fcs
Unpacking JAR files...
rt.jar...
Error: Could not open input file:/usr/java/jdk1.7.0_09/jre/lib/rt.pack
jsse.jar...
Error: Could not open input file:/usr/java/jdk1.7.0_09/jre/lib/jsse.pack
charsets.jar...
Error: Could not open input file:/usr/java/jdk1.7.0_09/jre/lib/charsets.pack
tools.jar...
Error: Could not open input file:/usr/java/jdk1.7.0_09/lib/tools.pack
localedata.jar...
Error: Could not open input file:/usr/java/jdk1.7.0_09/jre/lib/ext/localedata.pack
但是测试java版本:java -version
[root@server7 ~]# java -version
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02,mixed mode)
配置环境变量:
[root@server7 java]# vi /etc/profile
添加如下:(在文件的末尾添加)
JAVA_HOME=/usr/java/jdk1.7.0_09
PATH=$PATH:JAVA_HOME/bin
exportJAVA_HOME PATH
重新加载:
[root@server7 java]# source /etc/profile
为了避免错误下面我们的server6 就安装如下版本的jdk:
server6 上面下载的是:jdk-6u37-linux-i586-rpm.bin
[root@server6~]#chmod755 jdk-6u37-linux-i586-rpm.bin
[root@server6 ~]#./jdk-6u37-linux-i586-rpm.bin
[root@server6 ~]#rpm -iev jdk-6u37-linux-i586.rpm
提示:
Preparing packages for installation...
package jdk-1.7.0_09-fcs.x86_64 (whichis newer than jdk-1.6.0_37-fcs.i586) is already installed
file /etc/init.d/jexec from install ofjdk-1.6.0_37-fcs.i586 conflicts with file from package jdk-1.7.0_09-fcs.x86_64
卸载1.7版本的
[root@server6 ~]#rpm -e jdk-1.7.0_09-fcs.x86_64
重新安装:
[root@server6 ~]#rpm -iev jdk-6u37-linux-i586.rpm
[root@server6 ~]#java -version
java version "1.6.0_37"
Java(TM) SERuntime Environment (build 1.6.0_37-b06)
Java HotSpot(TM)Client VM (build 20.12-b01, mixed mode, sharing)----安装OK
Amoeba启动时需要调用Java,所以必须设置Java环境变量。设置方法如下:
首先,找到Java的安装路径,,默认一般为/usr/java,在该目录下有一个文件夹jak1.6.0_26
然后,打开[vi /etc/profile] 在末尾添加如下语句:
JAVA_HOME=/usr/java/jdk1.6.0_37
PATH=$PATH:JAVA_HOME/bin
export JAVA_HOME PATH
添加完毕后,关闭该文件,并重新加载[source /etc/profile]或者
[. /etc/profile]。
首先,在http://sourceforge.net/projects/amoeba/files/(Amoeba在SourceForge的主页)下载Amoeba在SourceForge的主页)上下载Amoeba for MySQL的安装包,目前的最新版本为amoeba-mysql-binary-2.1.0-RC5。
解压缩:
[root@server6usr]# cd local
[root@server6local]# mkdir amoeba
[root@server6~]#tar -zxvf amoeba-mysql-binary-2.1.0-RC5.tar.gz -C /usr/local/amoeba
我下载到的文件名为amoeba-mysql-binary-2.1.0-RC5.tar,将该文件解压到需要的位置[tar –zxvf amoeba-mysql-binary-2.1.0-RC5.tar /usr/local/amoeba]即可。
可使用命令[/usr/local/amoeba/bin/amoeba]验证Amoeba是否安装成功。
配置的除了amoeba的监听IP外其他的均采用上面mmm分配的浮动IP,因为当出现故障后,浮动IP会自动分配到正常的server上。amoeba.xml的配置如下:
在这里只修改两个地方:
<propertyname="port">8066</property>
<!-- bind ipAddress-->
<!--
//-- proxy server绑定的IP要设置成0.0.0.0,因为后面还要监听VIP
<propertyname="ipAddress">0.0.0.0</property>
-->
<propertyname="user">root</property>
//mysql的用户名
<propertyname="password">root</property>
//该名称于 dbservers.xml里面的属性字段匹配
<propertyname="readPool">virualslave</property>
然后配置dbServers.xml
[root@server6conf]# vidbServers.xml
<!-- mysql port -->
<propertyname="port">3306</property>
<!-- mysql schema -->
<propertyname="schema">test</property>
<!-- mysql user -->
<propertyname="user">root</property>
<!-- mysql password
<property name="password">root</property>
-->
</dbServer>
<dbServername="server1" parent="abstractServer">
<factoryConfig>
<!--mysql ip -->
<property name="ipAddress">192.168.10.105</property>
</factoryConfig>
</dbServer>
<dbServer name="server2" parent="abstractServer">
<factoryConfig>
<!-- mysql ip-->
<propertyname="ipAddress">192.168.10.101</property>
</factoryConfig>
</dbServer>
<dbServer name="server3" parent="abstractServer">
<factoryConfig>
<!-- mysql ip -->
<propertyname="ipAddress">192.168.10.102</property>
</factoryConfig>
</dbServer>
<dbServer name="server4" parent="abstractServer">
<factoryConfig>
<!-- mysql ip-->
<propertyname="ipAddress">192.168.10.103</property>
</factoryConfig>
</dbServer>
<dbServer name="server5" parent="abstractServer">
<factoryConfig>
<!-- mysql ip -->
<propertyname="ipAddress">192.168.10.104</property>
</factoryConfig>
</dbServer>
<dbServer name="virtualslave" virtual="true">
<poolConfigclass="com.meidusa.amoeba.server.MultipleServerPool">
<!-- Loadbalancing strategy: 1=ROUNDROBIN , 2=WEIGHTBASED , 3=HA-->
<propertyname="loadbalance">1</property>
<!--Separated by commas,such as: server1,server2,server1 -->
<propertyname="poolNames">server1,server2,server3,server4,server5</property>
</poolConfig>
</dbServer>
安装配置好之后先要启动amoeba:
[root@server6 bin]# /usr/local/amoeba/bin/amoeba start
[root@server6 ~]# ps aux|grep amoeba
root 6720 2.4 2.9 674368 30480 pts/2 Sl+ 01:03 0:00 /usr/java/jdk1.6.0_37/bin/java -server -Xms256m -Xmx512m -Xss512k-Damoeba.home=/usr/local/amoeba-Dclassworlds.conf=/usr/local/amoeba/bin/amoeba.classworlds -classpath/usr/local/amoeba/lib/classworlds-1.0.jar org.codehaus.classworlds.Launcherstart
root 6815 0.0 0.0 61232 748 pts/3 R+ 01:03 0:00 grep amoeba
//连接mysql 测试此时主要8066联通的就表示amoeba安装成功。(amoeba主要是监控8066端口)
[root@server6 ~]# mysql -uroot -proot -h192.168.10.132 -P8066
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2719739
Server version: 5.1.45-mysql-amoeba-proxy-2.1.0-RC5
Copyright (c) 2000, 2011, Oracle and/or its affiliates.All rights reserved.
Oracle is a registered trademark of Oracle Corporationand/or its
affiliates. Other names may be trademarks of theirrespective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear thecurrent input statement.
mysql>