amoeba mysql的安装配置实例
Amoeba是一个以MySQL为底层数据存储,并对应用提供MySQL协议接口的proxy,它集中地响应应用的请求,依据用户事先设置的规则,将SQL请求发送到特定的数据库上执行,下面我们来看看amoeba mysql的安装配置教程.
1、配置好mysql的主从环境,服务器如下,代码如下:
master:172.16.206.129
slave:172.16.206.130
amoeba:172.16.206.131
2、amoeba配置好JDK环境
可以去oracle的官网去下载JDK,安装目录一边不是标准的命名,使用如下命令做软连接:
ln -s /usr/java/jdk1.8.0_11/ /usr/java/jdk1.8
配置JDK环境:在/etc/profile文件末尾添加以下环境参数,代码如下:
export JAVA_HOME=/usr/java/jdk1.8
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
PS:下载的JDK需要和平台对应,uname 可以查看平台类型
3、下载amoeba
网上搜索可以去一些开源软件的网站下载
4、安装amoeba
安装路径/usr/local/amoeba
5、修改amoeba配置参数.
/usr/local/amoeba/conf/amoeba.xml 修改如下:
- <?xmlversion=”1.0″encoding=”gbk”?>
- <!DOCTYPEamoeba:configurationSYSTEM“amoeba.dtd”>
- <amoeba:configurationxmlns:amoeba=”http://amoeba.meidusa.com/”>
- <proxy>
- <!–serviceclassmustimplementscom.meidusa.amoeba.service.Service–>
- <servicename=”AmoebaforMysql”class=”com.meidusa.amoeba.mysql.server.MySQLService”>
- <!–portdefault–>
- <propertyname=”port”>8066</property>
- <!–bindipAddress–>
- <!–salley修改绑定IP地址–>
- <propertyname=”ipAddress”>172.16.206.129</property>
- <propertyname=”connectionFactory”>
- <beanclass=”com.meidusa.amoeba.mysql.net.MysqlClientConnectionFactory”>
- <propertyname=”sendBufferSize”>128</property>
- <propertyname=”receiveBufferSize”>64</property>
- </bean>
- </property>
- <propertyname=”authenticateProvider”>
- <beanclass=”com.meidusa.amoeba.mysql.server.MysqlClientAuthenticator”>
- <!–访问amoeba的账户名–>
- <propertyname=”user”>amoeba</property>
- <!–访问amoeba的密码–>
- <propertyname=”password”>123456</property>
- <propertyname=”filter”>
- <beanclass=”com.meidusa.toolkit.net.authenticate.server.IPAccessController”>
- <propertyname=”ipFile”>${amoeba.home}/conf/access_list.conf</property>
- </bean>
- </property>
- </bean>
- </property>
- </service>
- <runtimeclass=”com.meidusa.amoeba.mysql.context.MysqlRuntimeContext”>
- <!–proxyserverclientprocessthreadsize–>
- <propertyname=”executeThreadSize”>128</property>
- <!–perconnectioncachepreparedstatementsize–>
- <propertyname=”statementCacheSize”>500</property>
- <!–defaultcharset–>
- <propertyname=”serverCharset”>utf8</property>
- <!–querytimeout(default:60second,TimeUnit:second)–>
- <propertyname=”queryTimeout”>60</property>
- </runtime>
- </proxy>
- <!–
- EachConnectionManagerwillstartasthread
- managerresponsiblefortheConnectionIOread,DeathDetection
- –>
- <connectionManagerList>
- <connectionManagername=”defaultManager”class=”com.meidusa.toolkit.net.MultiConnectionManagerWrapper”>
- <propertyname=”subManagerClassName”>com.meidusa.toolkit.net.AuthingableConnectionManager</property>
- </connectionManager>
- </connectionManagerList>
- <!–defaultusingfileloader–>
- <dbServerLoaderclass=”com.meidusa.amoeba.context.DBServerConfigFileLoader”>
- <propertyname=”configFile”>${amoeba.home}/conf/dbServers.xml</property>
- </dbServerLoader>
- <queryRouterclass=”com.meidusa.amoeba.mysql.parser.MysqlQueryRouter”>
- <propertyname=”ruleLoader”>
- <beanclass=”com.meidusa.amoeba.route.TableRuleFileLoader”>
- <propertyname=”ruleFile”>${amoeba.home}/conf/rule.xml</property>
- <propertyname=”functionFile”>${amoeba.home}/conf/ruleFunctionMap.xml</property>
- </bean>
- </property>
- <propertyname=”sqlFunctionFile”>${amoeba.home}/conf/functionMap.xml</property>
- <propertyname=”LRUMapSize”>1500</property>
- <propertyname=”defaultPool”>master</property>
- <propertyname=”writePool”>master</property>
- <propertyname=”readPool”>multiPool</property>
- <propertyname=”needParse”>true</property>
- </queryRouter>
- </amoeba:configuration>
/usr/local/amoeba/conf/dbServer.xml修改如下:
- <?xmlversion=”1.0″encoding=”gbk”?>
- <!DOCTYPEamoeba:dbServersSYSTEM“dbserver.dtd”>
- <amoeba:dbServersxmlns:amoeba=”http://amoeba.meidusa.com/”>
- <!–
- EachdbServerneedstobeconfiguredintoaPool,
- IfyouneedtoconfiguremultipledbServerwithloadbalancingthatcanbesimplifiedbythefollowingconfiguration:
- addattributewithnamevirtual=“true”indbServer,buttheconfigurationdoesnotallowtheelementwithnamefactoryConfig
- suchas‘multiPool’dbServer
- –>
- <dbServername=”abstractServer”abstractive=”true”>
- <factoryConfigclass=”com.meidusa.amoeba.mysql.net.MysqlServerConnectionFactory”>
- <propertyname=”connectionManager”>${defaultManager}</property>
- <propertyname=”sendBufferSize”>64</property>
- <propertyname=”receiveBufferSize”>128</property>
- <!–mysqlport访问MySQL的端口号–>
- <propertyname=”port”>3306</property>
- <!–mysqlschema访问MySQL默认的数据库–>
- <propertyname=”schema”>test</property>
- <!–mysqluser访问MySQL的账户名–>
- <propertyname=”user”>amoeba</property>
- <!–mysqlpassword访问MySQL的密码–>
- <propertyname=”password”>123456</property>
- </factoryConfig>
- <poolConfigclass=”com.meidusa.toolkit.common.poolable.PoolableObjectPool”>
- <propertyname=”maxActive”>500</property>
- <propertyname=”maxIdle”>500</property>
- <propertyname=”minIdle”>1</property>
- <propertyname=”minEvictableIdleTimeMillis”>600000</property>
- <propertyname=”timeBetweenEvictionRunsMillis”>600000</property>
- <propertyname=”testOnBorrow”>true</property>
- <propertyname=”testOnReturn”>true</property>
- <propertyname=”testWhileIdle”>true</property>
- </poolConfig>
- </dbServer>
- <dbServername=”master”parent=”abstractServer”>
- <factoryConfig>
- <!–mysqlip–>
- <propertyname=”ipAddress”>172.16.206.129</property>
- </factoryConfig>
- </dbServer>
- <dbServername=”slave”parent=”abstractServer”>
- <factoryConfig>
- <!–mysqlip–>
- <propertyname=”ipAddress”>172.16.206.130</property>
- </factoryConfig>
- </dbServer>
- <dbServername=”multiPool”virtual=”true”>
- <poolConfigclass=”com.meidusa.amoeba.server.MultipleServerPool”>
- <!–Loadbalancingstrategy:1=ROUNDROBIN,2=WEIGHTBASED,3=HA–>
- <propertyname=”loadbalance”>1</property>
- <!–Separatedbycommas,suchas:server1,server2,server1–>
- <propertyname=”poolNames”>master,slave,slave</property>
- //开源代码phpfensi.com
- </poolConfig>
- </dbServer>
- </amoeba:dbServers>
启动amoeba:/usr/local/amoeba/bin/launcher &
关闭amoeba:/usr/local/amoeba/bin/shutdown
amoeba不支持存储过程、不支持大数据量查询,这个比较讨厌,所以我最后还是没有用amoeba.
热门评论