Amoeba For MySQL_测试Amoeba的数据切分功能_CentOS6.5下进行
2014-07-19 22:01
507 查看
测试Amoeba的数据分片功能
l 测试Amoeba进行数据切片后进行聚合的情况,是否支持常见的条件查询操作、SQL聚合操作等。
在server1和server2上的MySQL Server上用root登录执行以下授权命令
grant allprivileges on *.* to ‘root’ @ ‘[ip地址]’ identified by ‘[登录密码]’ with grant option;
dbServers.xml
rule.xml
amoeba.xml
service mysqlstart
通过观察Server version确保是通过Amoeba代理服务器连接上的
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/16/247511661a576088fde4fc146ce8f7ed)
进行DML操作
查询插入情况
(1) testClient连接8066端口情况下查询
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/16/694d4117a9b17a821cb395582a63b55b)
(2)Server1连接3306端口情况下查询
(3)Server2 连接3306端口情况下查询
试验结论:
通过以上试验,证明Amoeba确实具有数据分片功能(至少具有数据水平切分功能)。
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/16/030c5e5a4e745abb7ddf40efeebc332c)
测试where语句
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/16/8b6833858645b99030b53ee0712ca798)
测试like语句
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/16/31c7b3760c94fa03b974cb791df16e9f)
测试count语句
![](https://oscdn.geek-share.com/Uploads/Images/Content/202011/16/4b1082a9ab841dd007f690e1079cb827)
测试order排序
试验结论:
通过观察测试结果可以发现,amoeba实现数据水平切分以后,支持常规的where条件查询、模糊匹配查询,但是对于聚合函数不支持,包括count、sum等,那么可以得出对于group by和having同样是不支持的。
1. 测试目的
l 验证Amoeba具有数据分片功能。l 测试Amoeba进行数据切片后进行聚合的情况,是否支持常见的条件查询操作、SQL聚合操作等。
2. 测试环境
2.1 操作系统
操作系统类型 | 配置 |
Windows 7 旗舰版 | 处理器: AMD A8-3500M APU with Radeon(tm) HD Graphic 1.50HZ 内存: 4.00GB ( 3.48G可用 ) 系统类型: 64位操作系统 |
VMWare 10 CentOS6.5 | 处理器数量: 1 内存: 512MB 系统类型: 64位操作系统 |
2.2 服务器配置
服务器名 | 配置 |
server1(同时充当Amoeba代理服务器) | IP: 192.168.52.128 OS: VMWare 10 CentOS6.5 MySQL Version: 5.5.38 x64 Java Version: 1.6 x64 (Amoeba依赖) Amoeba Version: amoeba-mysql-3.0.4-BETA |
server2 | IP: 192.168.52.129 OS: VMWare 10 CentOS6.5 MySQL Version: 5.5.38 x64 |
testClient(模拟客户端应用进行测试) | IP: 192.168.16.125 OS: Windows 7旗舰版 MySQL Version: 5.5.37 x86 |
3. 测试前的配置
3.1 确保testClient可以连接到server1和server2
在server1和server2上分别对来自testClient[192.168.16.125]的远程登录进行授权。在server1和server2上的MySQL Server上用root登录执行以下授权命令
grant allprivileges on *.* to ‘root’ @ ‘[ip地址]’ identified by ‘[登录密码]’ with grant option;
3.2 配置Amoeba代理服务器上的dbServers.xml、rule.xml和amoeba.xml文件
( 需要特别注意红色部分的设定 )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="connectionManager">${defaultManager}</property> <property name="sendBufferSize">64</property> <property name="receiveBufferSize">128</property> <!-- mysql port --> <property name="port">3306</property> <!-- mysql schema --> <property name="schema">test</property> <!-- mysql user --> <property name="user">root</property> <property name="password">root</property> </factoryConfig> <poolConfig class="com.meidusa.toolkit.common.poolable.PoolableObjectPool"> <property name="maxActive">500</property> <property name="maxIdle">500</property> <property name="minIdle">1</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="server1" parent="abstractServer"> <factoryConfig> <!-- mysql ip --> <property name="ipAddress">192.168.52.128</property> </factoryConfig> </dbServer> <dbServer name="server2" parent="abstractServer"> <factoryConfig> <!-- mysql ip --> <property name="ipAddress">192.168.52.129</property> </factoryConfig> </dbServer> <dbServer name="multiPool" 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">server1,server2</property> </poolConfig> </dbServer> </amoeba:dbServers> |
<?xml version="1.0" encoding="gbk"?> <!DOCTYPE amoeba:rule SYSTEM "rule.dtd"> <amoeba:rule xmlns:amoeba="http://amoeba.meidusa.com/"> <tableRule name="staff" schema="test" defaultPools="server1,server2"> <rule name="rule1" ruleResult="POOLNAME"> <parameters>ID</parameters> <expression><![CDATA[ var division = ID % 2; case division when 0 then 'server1'; when 1 then 'server2'; end case; ]]></expression> </rule> </tableRule> </amoeba:rule> |
<?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.mysql.server.MySQLService"> <!-- port --> <property name="port">8066</property> <!-- bind ipAddress --> <!-- <property name="ipAddress">127.0.0.1</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="authenticateProvider"> <bean class="com.meidusa.amoeba.mysql.server.MysqlClientAuthenticator"> <property name="user">root</property> <property name="password">root</property> <property name="filter"> <bean class="com.meidusa.toolkit.net.authenticate.server.IPAccessController"> <property name="ipFile">${amoeba.home}/conf/access_list.conf</property> </bean> </property> </bean> </property> </service> <runtime class="com.meidusa.amoeba.mysql.context.MysqlRuntimeContext"> <!-- proxy server client process thread size --> <property name="executeThreadSize">128</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="defaultManager" class="com.meidusa.toolkit.net.MultiConnectionManagerWrapper"> <property name="subManagerClassName">com.meidusa.toolkit.net.AuthingableConnectionManager</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">multiPool</property> <!-- <property name="writePool">server1</property> <property name="readPool">server2</property> --> <property name="needParse">true</property> </queryRouter> </amoeba:configuration> |
4. 测试
4.1 启动数据库服务
分别启动Server1和Server2上的MySQL数据库服务(默认情况下是开机启动的):service mysqlstart
4.2 启动Amoeba监听程序
# cd /usr/local/amoeba/bin # launcher log4j:WARN log4j config load completed from file:/usr/local/amoeba/conf/log4j.xml 2014-07-08 00:39:06,909 INFO context.MysqlRuntimeContext - Amoeba for Mysql current versoin=5.1.45-mysql-amoeba-proxy-3.0.4-BETA log4j:WARN ip access config load completed from file:/usr/local/amoeba/conf/access_list.conf 2014-07-08 00:39:07,735 INFO net.ServerableConnectionManager - Server listening on 0.0.0.0/0.0.0.0:8066. 2014-07-08 00:40:35 [INFO] Project Name=Amoeba-MySQL, PID=3167 , starting... log4j:WARN log4j config load completed from file:/usr/local/amoeba/conf/log4j.xml 2014-07-08 00:40:36,597 INFO context.MysqlRuntimeContext - Amoeba for Mysql current versoin=5.1.45-mysql-amoeba-proxy-3.0.4-BETA log4j:WARN ip access config load completed from file:/usr/local/amoeba/conf/access_list.conf 2014-07-08 00:40:37,501 INFO net.ServerableConnectionManager - Server listening on 0.0.0.0/0.0.0.0:8066. 2014-07-08 00:41:26 [INFO] ignore signal:HUP 2014-07-08 00:41:56 [INFO] Project Name=Amoeba-MySQL, PID=3211 , starting... log4j:WARN log4j config load completed from file:/usr/local/amoeba/conf/log4j.xml 2014-07-08 00:41:57,745 INFO context.MysqlRuntimeContext - Amoeba for Mysql current versoin=5.1.45-mysql-amoeba-proxy-3.0.4-BETA log4j:WARN ip access config load completed from file:/usr/local/amoeba/conf/access_list.conf 2014-07-08 00:41:58,669 INFO net.ServerableConnectionManager - Server listening on 0.0.0.0/0.0.0.0:8066. |
4.3 在testClient进行测试
通过8066端口连接amoeba代理服务器通过观察Server version确保是通过Amoeba代理服务器连接上的
测试一(数据水平切分)
这里只进行数据水平切分测试进行DML操作
use test; insert into staff(id, name) values(1, ‘AAA’); insert into staff(id, name) values(2, ‘BBB’); insert into staff(id, name) values(3, ‘CCC’); insert into staff(id, name) values(4, ‘DDD’); insert into staff(id, name) values(5, ‘EEE’); |
(1) testClient连接8066端口情况下查询
(2)Server1连接3306端口情况下查询
[root@localhost bin]# mysql -uroot -hlocalhost -P3306 -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 5.5.38-log MySQL Community Server (GPL) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use test; Database changed mysql> select * from staff; +------+------+ | id | name | +------+------+ | 2 | BBB | | 4 | DDD | +------+------+ 2 rows in set (0.01 sec) |
[root@localhost Desktop]# mysql -uroot -hlocalhost -P3306 -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 19 Server version: 5.5.38-log MySQL Community Server (GPL) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use test; Database changed mysql> select * from staff; +------+------+ | id | name | +------+------+ | 1 | AAA | | 3 | CCC | | 5 | EEE | +------+------+ 3 rows in set (0.00 sec) |
通过以上试验,证明Amoeba确实具有数据分片功能(至少具有数据水平切分功能)。
测试二(对查询操作的支持)
确保testClient通过8066端口连接Amoeba代理服务器并执行以下命令测试where语句
测试like语句
测试count语句
测试order排序
试验结论:
通过观察测试结果可以发现,amoeba实现数据水平切分以后,支持常规的where条件查询、模糊匹配查询,但是对于聚合函数不支持,包括count、sum等,那么可以得出对于group by和having同样是不支持的。
相关文章推荐
- Amoeba For MySQL_测试Amoeba在CentOS6.5下配置
- Amoeba for mysql 0.31发布(读写分离、负载均衡、Failover、数据切分)
- 致力于数据切分的Amoeba for mysql 0.12版本发布
- Amoeba for MySQL 测试
- TOAD FOR MYSQL 进行数据插入时乱码的解决办法---MariaDB 5.5
- 测试必备技能系列1 :通过mysql命令进行脚本数据导入
- 发现Navivat for MySQL有一个数据表分组功能,用起来很方便!(图文)
- CentOS6.5下如何正确下载、安装Intellij IDEA、Scala、Scala-intellij-bin插件、Scala IDE for Eclipse助推大数据开发(图文详解)
- 回发或回调参数无效。在配置中使用 或在页面中使用 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEventValidation 方法来注册回发或回调数据以进行验证。
- mysql存储过程对900w数据进行操作测试
- 15、单机运行环境搭建之 --Centos6.4下对mysql进行压力测试
- 转一篇测试 Amoeba For MySQL的文章
- 测试必备技能系列1 :通过mysql命令进行脚本数据导入
- 测试必备技能系列1 :通过mysql命令进行脚本数据导入
- Amoeba For MySQL入门:实现数据库水平切分
- mysql主键设置成auto_increment时,进行并发性能测试出现主键重复Duplicate entry 'xxx' for key 'PRIMARY'
- 使用Amoeba for mysql实现mysql读写分离(测试可行)
- 回发或回调参数无效。在配置中使用 或在页面中使用 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEventValidation 方法来注册回发或回调数据以进行验证。
- 回发或回调参数无效。在配置中使用 或在页面中使用 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEventValidation 方法来注册回发或回调数据以进行验证。
- CentOS-6.5下安装navicat for mysql