Hadoop2.7.1+Hbase1.2.1集群环境搭建(8)雅虎YCSB测试hbase性能测试

(1)hadoop2.7.1源码编译 http://aperise.iteye.com/blog/2246856
(2)hadoop2.7.1安装准备 http://aperise.iteye.com/blog/2253544
(3)1.x和2.x都支持的集群安装 http://aperise.iteye.com/blog/2245547
(4)hbase安装准备 http://aperise.iteye.com/blog/2254451
(5)hbase安装 http://aperise.iteye.com/blog/2254460
(6)snappy安装 http://aperise.iteye.com/blog/2254487
(7)hbase性能优化 http://aperise.iteye.com/blog/2282670
(8)雅虎YCSB测试hbase性能测试 http://aperise.iteye.com/blog/2248863
(9)spring-hadoop实战 http://aperise.iteye.com/blog/2254491
(10)基于ZK的Hadoop HA集群安装  http://aperise.iteye.com/blog/2305809

        很荣幸博客被ITEYE知识库收录,在这里,也不希望本篇内容过于简单,会不断进行更新......

        这里主要借助Yahoo开源的一款通用的性能测试工具YCSB对已经安装的hadoop2.7.1+hbase1.2.1进行性能测试。

        写这篇文章参考了以下三篇文章:

        1.hbase性能测试 http://blog.csdn.net/huoyunshen88/article/details/38299481

        2.Hadoop参考设计的实现及性能:HBase应用性能测试方法 http://www.ithov.com/linux/135879.shtml

        3.Linux环境下Python的安装过程 http://blog.csdn.net/pan_tian/article/details/7684409 

        4.Runing a Workload   https://github.com/brianfrankcooper/YCSB/wiki/Running-a-Workload

1.Yahoo开源测试工具YCSB介绍

    1.1 简单介绍

        英文全称:Yahoo! Cloud Serving Benchmark (YCSB) 。是 Yahoo 公司的一个用来对云服务进行基础测试的工具。目标是促进新一代云数据服务系统的性能比较。为四个广泛使用的系统:Cassandra,、HBase、PNUTS和一个简单的片式MySQL执行,订了套核心基准测试和结果报告。

        目前项目开源地址https://github.com/brianfrankcooper/YCSB

    1.2 可以测试哪些技术?每个的详细测试介绍?

  • accumulo          https://github.com/brianfrankcooper/YCSB/tree/master/accumulo
  • aerospike         https://github.com/brianfrankcooper/YCSB/tree/master/aerospike
  • asynchbase        https://github.com/brianfrankcooper/YCSB/tree/master/asynchbase
  • cassandra         https://github.com/brianfrankcooper/YCSB/tree/master/cassandra
  • cassandra2        https://github.com/brianfrankcooper/YCSB/tree/master/cassandra2
  • couchbase         https://github.com/brianfrankcooper/YCSB/tree/master/couchbase
  • couchbase2        https://github.com/brianfrankcooper/YCSB/tree/master/couchbase2
  • dynamodb          https://github.com/brianfrankcooper/YCSB/tree/master/dynamodb
  • elasticsearch     https://github.com/brianfrankcooper/YCSB/tree/master/elasticsearch
  • geode             https://github.com/brianfrankcooper/YCSB/tree/master/geode
  • googlebigtable    https://github.com/brianfrankcooper/YCSB/tree/master/googlebigtable
  • googledatastore   https://github.com/brianfrankcooper/YCSB/tree/master/googledatastore
  • hbase094          https://github.com/brianfrankcooper/YCSB/tree/master/hbase094
  • hbase098          https://github.com/brianfrankcooper/YCSB/tree/master/hbase098
  • hbase10           https://github.com/brianfrankcooper/YCSB/tree/master/hbase10
  • hypertable        https://github.com/brianfrankcooper/YCSB/tree/master/infinispan
  • jdbc              https://github.com/brianfrankcooper/YCSB/tree/master/jdbc
  • kudu              https://github.com/brianfrankcooper/YCSB/tree/master/kudu
  • mapkeeper         https://github.com/brianfrankcooper/YCSB/tree/master/mapkeeper
  • memcached         https://github.com/brianfrankcooper/YCSB/tree/master/memcached
  • mongodb           https://github.com/brianfrankcooper/YCSB/tree/master/mongodb
  • nosqldb           https://github.com/brianfrankcooper/YCSB/tree/master/nosqldb
  • orientdb          https://github.com/brianfrankcooper/YCSB/tree/master/orientdb
  • rados             https://github.com/brianfrankcooper/YCSB/tree/master/rados
  • redis             https://github.com/brianfrankcooper/YCSB/tree/master/rados
  • riak              https://github.com/brianfrankcooper/YCSB/tree/master/riak
  • s3                https://github.com/brianfrankcooper/YCSB/tree/master/s3
  • solr              https://github.com/brianfrankcooper/YCSB/tree/master/solr
  • tarantool         https://github.com/brianfrankcooper/YCSB/tree/master/tarantool
  • voldemort         https://github.com/brianfrankcooper/YCSB/tree/master/voldemort

2.安装Yahoo开源的性能测试工具YCSB

    2.1 首先安装python2.7.10

        1)在https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz下载Python-2.7.10.tgz

        2)通过tar -xzf Python-2.7.10.tgz解压到/opt/Python-2.7.10

        3)通过cd /opt/Python-2.7.10,依次执行./configue,make,make install这三个命令进行安装

        4)如果不安装或者python版本过老,在后面会报错如下:

          No module named argparse

 

    2.2 安装YCSB

        1)在https://github.com/brianfrankcooper/YCSB/releases/download/0.3.1/ycsb-0.3.1.tar.gz下载ycsb-0.3.1.tar.gz,解压到/opt/ycsb-0.3.1

        2)复制/opt/hbase-1.2.1/conf/hbase-site.xml到/opt/ycsb-0.3.1/hbase-binding/;

           复制/opt/hbase-1.2.1/lib/*到/opt/ycsb-0.3.1/hbase-binding/lib/

           我的hbase安装根目录是 /opt/hbase-1.2.1/

           我的YCSB安装目录是    /opt/ycsb-0.3.1/

           cp /opt/hbase-1.2.1/conf/hbase-site.xml     /opt/ycsb-0.3.1/hbase-binding/

           cp /opt/hbase-1.2.1/lib/*                              /opt/ycsb-0.3.1/hbase-binding/lib/

        3)安装YCSB完成

 

3.YCSB使用介绍

    3.1 YCSB命令

  • load           加载数据
  • run            执行事务
  • shell          交互模式

    3.2 YCSB命令参数

  • -P file        Specify workload file
  • -cp path       Additional Java classpath entries
  • -jvm-args args Additional arguments to the JVM
  • -p key=value   Override workload property
  • -s             Print status to stderr
  • -target n      Target ops/sec (default: unthrottled)
  • -threads n     Number of client threads (default: 1)

    3.3 默认配置介绍

        在YCSB安装完成后,默认在安装目录../ycsb-0.3.1/workloads下有如下默认配置脚本,截图如下:


        这里我以配置文件../ycsb-0.3.1/workloads/workloada为例进行介绍,首先贴出其内容

# Copyright (c) 2010 Yahoo! Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you
# may not use this file except in compliance with the License. You
# may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License. See accompanying
# LICENSE file.


# Yahoo! Cloud System Benchmark
# Workload A: Update heavy workload
# Application example: Session store recording recent actions
#
# Read/update ratio: 50/50
# Default data size: 1 KB records (10 fields, 100 bytes each, plus key)
# Request distribution: zipfian

recordcount=1000
operationcount=1000
workload=com.yahoo.ycsb.workloads.CoreWorkload

readallfields=true

readproportion=0.5
updateproportion=0.5
scanproportion=0
insertproportion=0

requestdistribution=zipfian

    recordcount=1000                                                          默认操作数据总记录数为1000

    operationcount=1000                                 

    workload=com.yahoo.ycsb.workloads.CoreWorkload      

    readallfields=true                                  

    readproportion=0.5                                                        读取操作占比50%

    updateproportion=0.5                                                    更新操作占比50%

    scanproportion=0                                                           hbase scan占比0%

    insertproportion=0                                                          插入操作占比0%

    requestdistribution=zipfian

    上面是YCSB给定的几个默认压测场景之一其上配置不指定的话就使用该默认值,如果指定的话,传入响应参数就行了,例如:

./ycsb load hbase -P ../workloads/workloada -p threads=10 -p columnfamily=f1 -p recordcount=10000 -s

     上述意思是调用ycsb中加载数据命令loadhbase进行测试,配置文件采用../ycsb-0.3.1/workloads/workloada,客户端线程数设置为10,默认插入到hbase的数据表usertable中的列簇f1中,记录数为100000,这里的记录数就是传入进来的,会覆盖../ycsb-0.3.1/workloads/workloada里面的默认值recordcount

4.YCSB测试HBASE性能实战

    测试过程分为两个阶段,首先是加载数据,其次是执行事务。

    4.1 加载数据

cd /opt/ycsb-0.3.1/bin
./ycsb load hbase -P ../workloads/workloada -p threads=10 -p columnfamily=f1 -p recordcount=10000 -s > load.log  

 命令分析:

  • load:表明为加载数据测试。  
  • hbase:表明测试的是hbase性能
  • -P  ../workloads/workloada ,指定配置文件为/opt/ycsb-0.3.1/workloads/workloada
  • -p  threads=10    客户端线程数为10
  • -p columnfamily=f1 指定数据插入到表usertable的列簇f1,所以你得首先在hbase shell中执行create 'usertable','f1','f2','f3'
  • -p recordcount=10000 插入10000行记录         

执行后向HBase Server下的usertable,f1插入10000条数据,并将执行的情况打印到屏幕上。查看load.log,信息如下:

 

    4.2 执行事务

cd /opt/ycsb-0.3.1/bin
./ycsb run hbase -P ../workloads/workloada -threads 10 -p measurementtype=timeseries -p columnfamily=f1 -p timeseries.granularity=2000 > transactions.log

 执行后查看transactions.log,信息如下:


  • 总执行时间为1568毫秒
  • 吞吐量为637.755 ops/s
  • 530个读操作,其中532个读不超过1s,532个更新操作,其中468个更新不超过1s
  • 读操作最小延迟692微秒,最大延迟109651微秒,平均延迟2447微秒
  • 更新操作最小延迟4微秒,最大延迟177337微秒,平均5延迟174微秒

        因为之前我只用两台机器做hbase集群,实际上其中一台作为HMASTER,另一台作为HREGION,所以性能不是很好,后面需要增加HREGION,还需要做的是对Hadoop和hbase进行优化。

 

    4.3 另一个例子

        首先在hbase创建测试需要的数据表,并进行预分区(建表usertable 列簇为cf 分50区)

cd /home/hadoop/hbase-1.2.1/bin/
./hbase shell
n_splits = 49 
create 'usertable', 'cf', {SPLITS => (1..n_splits).map {|i| "user#{1000+i*(9999-1000)/n_splits}"}}
quit

        接着开启测试

cd /home/hadoop/ycsb-0.3.1
bin/ycsb load hbase-10 -P workloads/workloada -p columnfamily=cf -p recordcount=10000000 -jvm-args "-Xms2048m -Xmx2048m -XX:PermSize=128m -XX:MaxPermSize=256m" -p threadcount=100 -s |tee -a hbase_100thread_10000000record.log

        上面参数含义:

  • hbase-10       说明测试的是针对hbase1.x版本
  • -p columnfamily=cf    插入hbase的列簇cf
  • -p recordcount=100000000    总计插入1亿条数据
  • -jvm-args '-Xms2048m -Xmx2048m -XX:PermSize=128m -XX:MaxPermSize=256m'   设置JVM参数
  • -p threadcount=100 客户端线程数为100,并发100
  • -s |tee -a hbase10_test_result.log  记录测试结果到hbase10_test_result.log
  • -P workloads/workloada  采用默认配置workloads/workloada,里面设置了插入占比50%,更新占比50%,默认往cf列簇插入10个列的数据,每个列的数据大小为100bytes,10个列的话总计大约1K大小数据

猜你喜欢

转载自aperise.iteye.com/blog/2248863
今日推荐