Chinaunix首页 | 论坛 | 博客
  • 博客访问: 35979
  • 博文数量: 3
  • 博客积分: 161
  • 博客等级: 入伍新兵
  • 技术积分: 95
  • 用 户 组: 普通用户
  • 注册时间: 2004-10-03 13:38
文章分类
文章存档

2012年(3)

分类: Mysql/postgreSQL

2012-03-31 16:27:03

        在上篇文章中,主要介绍了cluster的安装部署。Mysql官方给出了每分钟1 Billion的海量查询响应能力,到底是否如传说中的那么强力?首先要强调的一点,任何性能测试,都是与硬件直接关联的。我没有看到官方给出这个1 Billion数据的测试硬件配置和参数配置,所以不敢轻易苟同。我在测试的时候,使用了如下硬件配置

CPU Inter  xeon E1230 3.2G 4核
Mem 32G
一块500G sata硬盘7200
单网卡

        虽然Mysql官方说,我们支持非常廉价的硬件,但是,那个完全是出于商业营销的目的而说的。如果我们的业务大到需要使用Mysql 集群才能搞定,那么我敢断定,你的公司一定不会缺这几个钱(现在硬件已经是非常廉价了)。所以,在配置Mysql集群时,我强烈建议,大家使用能用的最好的硬件资源,特别是数据节点。官方推荐了主频高,cache大的CPU,足够大的内存,4块高速硬盘(15000转)做Raid10,此外,我再加一点,建议采用Inter高质量的网卡,至少1GB,因为我在做基准测试时,发现网卡流量基本跑满。根据木桶理论,你的Cluster的性能,取决于你最差的硬件。由于Cluster在运行起来后,其数据全部载入到内存中,而Cluster数据之间又需要大量的数据交换,性能好的网卡非常重要。

        OK,再来说说基准测试软件,官方推荐有DBT2,flexAsynch等。我采用了flexAsynch,非常好的NDB测试工具。flexAsynch在Mysql cluster7.2的源代码中,如果要使用它,你不能下载官方提供的免编译的二进制包,里面不带flexAsynch。你需要从源代码编译安装。
        从Mysql5.5开始,Mysql就不再使用autoconf编译了,而是采用cmake编译。关于cmake的问题,大家可以问度娘或者谷哥。基于同样的理由,mysql cluster7.2的源代码编译也需要采用cmake方式编译。放出我的编译参数:


  1. cmake . -DCMAKE_INSTALL_PREFIX=/opt/soft/mysql -DMYSQL_DATADIR=/data/db -DINSTALL_LIBDIR=/opt/soft/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_NDBCLUSTER_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DWITH_DEBUG=1 -DWITH_BUNDLED_LIBEVENT=ON -DWITH_BUNDLED_MEMCACHED=ON -DWITH_NDBMTD=ON -DWITH_NDB_TEST=ON

安装完成后,可以看到/opt/soft/mysql/bin/flexAsynch 已经有了。
现在来看下我的测试结果(在管理节点上执行)

/opt/soft/mysql/bin/flexAsynch -ndbrecord -temp -con 2 -t 8 -p 312 -a 2 -l 3 -r 2
insert average: 290814/s min: 251005/s max: 311299/s stddev: 9%
update average: 316229/s min: 313646/s max: 318611/s stddev: 0%
delete average: 349722/s min: 347535/s max: 352542/s stddev: 0%
read   average: 496501/s min: 430493/s max: 508143/s stddev: 3%


可以看出,在4个数据节点的环境中,可以达到300,000/s的写,500,000/s的读操作。这个量级已经非常令人振奋了。如果我们在生产应用中采用更好的硬件,我相信这个测试结果会更令人满意。为了让大家了解这个工具,我从网上抄了一段参数定义说明,大家可以根据自己的实际情况调整参数。

-t Number of threads to start, default 1
-p Number of parallel transactions per thread, default 32
-o Number of transactions per loop, default 500
-l Number of loops to run, default 1, 0=infinite
-load_factor Number Load factor in index in percent (40 -> 99)
-a Number of attributes, default 25
-c Number of operations per transaction
-s Size of each attribute, default 1
(PK is always of size 1, independent of this value)
-simple Use simple read to read from database
-dirty Use dirty read to read from database
-write Use writeTuple in insert and update
-n Use standard table names
-no_table_create Don't create tables in db
-temp Create table(s) without logging
-no_hint Don't give hint on where to execute transaction coordinator
-adaptive Use adaptive send algorithm (default)
-force Force send when communicating
-non_adaptive Send at a 10 millisecond interval
-local Number of part, only use keys in one part out of 16
-ndbrecord Use NDB Record
-r Number of extra loops
-insert Only run inserts on standard table
-read Only run reads on standard table
-update Only run updates on standard table
-delete Only run deletes on standard table
-create_table Only run Create Table of standard table
-drop_table Only run Drop Table on standard table
-warmup_time Warmup Time before measurement starts
-execution_time Execution Time where measurement is done
-cooldown_time Cooldown time after measurement completed
-table Number of standard table, default 0

        测试可能还需要根据你的实际环境调整一些参数,特别是SendBufferMemory,你极有可能遇到一个错误:
ERROR 1297 (HY000) at line 1: Got temporary error 1218 'Send Buffers overloaded in NDB kernel' from NDBCLUSTER

这时把
SendBufferMemory调大就行了(每个参数配置,官方文档都有说明)。还有可能遇到卡住不动的问题,一般是由于没有空闲的连接,你需要在config.ini配置里新增几个空的[API],这个问题在恢复数据的时候也可能遇到。另外强调一下,Mysql cluster的配置更改后,你需要rolling restart(滚动重启)才能让新配置生效。在调整参数后,服务端使用--reload启动,以加载新的配置,否则会一直读取缓存中的旧配置。每个数据节点依次启动就行。如果你的数据量特别大,rolling restart的时间也会很长,如果仅仅是测试,我建议你从管理节点直接shutdown集群后,再依次启动集群会更快。

        后记:Mysql在众多的互联网公司中得到广泛应用,随着业务的不断增长,数据库的集群方案是未来解决大规模数据存储的主流方向。真心希望Mysql的集群方案能在国内率先应用起来。















阅读(3823) | 评论(0) | 转发(3) |
0

上一篇:没有了

下一篇:Mysql cluster (集群)7.2的的日常维护

给主人留下些什么吧!~~