龙空技术网

0245-如何使用HiBench进行基准测试

Hadoop实操 188

前言:

此刻咱们对“oracleora31655”大概比较关心,姐妹们都需要学习一些“oracleora31655”的相关资讯。那么小编同时在网摘上搜集了一些有关“oracleora31655””的相关内容,希望各位老铁们能喜欢,看官们一起来了解一下吧!

温馨提示:要看高清无码套图,请使用手机打开并单击图片放大查看。

Fayson的github:

提示:代码块部分可以左右滑动查看噢

1.文档编写目的

HiBench是一个大数据基准套件,可以帮助您评测不同大数据平台的性能、吞吐量和系统资源利用率。它包含一组Hadoop、Spark和Streaming测试模式,包含Sort、WordCount、TeraSort、Sleep、SQL、PageRank、Nutch index、Bayes、Kmeans、NWeight和增强型的DFSIO等。本篇文章主要介绍如何使用HiBench对CDH集群进行基准测试

内容概述

1.编译环境准备

2.HiBench编译、配置说明及数据规模指定

3.HiBench使用

测试环境

1.CM和CDH版本为5.13.1

2.采用root用户操作

3.操作系统RedHat7.2

2.编译环境准备

HiBench编译依赖Java和Maven环境,首先需要配置Java和Maven的环境变量及准备HiBench的源码包,如果为配置环境变量可参考如下配置:

1.JAVA环境检查及配置

检查是否配置JDK环境变量

[root@ip-172-31-30-69 ~]# java -versionjava version "1.8.0_131"Java(TM) SE Runtime Environment (build 1.8.0_131-b11)Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)[root@ip-172-31-30-69 ~]# 

(可左右滑动)

如果未配置则参考参考如下步骤配置JDK,配置java环境变量,在/etc/profile文件末尾添加如下配置:

export JAVA_HOME=/usr/java/jdk1.8.0_131/export PATH=$JAVA_HOME/bin:$PATHexport CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tool.jar:$CLASSPATH

(可左右滑动)

执行如下命令是JAVA环境变量立即生效

[root@ip-172-31-30-69 ~]# source /etc/profile[root@ip-172-31-30-69 ~]# java -version

(可左右滑动)

2.MAVEN环境检查及配置

Maven下载地址:

(可左右滑动)

将下载的Maven安装包解压到/usr/local/maven目录下

tar -zxvf apache-maven-3.5.0-bin.tar.gz -C /usr/local/maven/

(可左右滑动)

配置Maven环境变量,在/etc/profile文件末尾追加如下配置

export MVN_HOME=/usr/local/apache-maven-3.5.2export PATH=$MVN_HOME/bin:$PATH

(可左右滑动)

执行如下命令使其环境变量立即生效

[root@ip-172-31-30-69 ~]# source /etc/profile

(可左右滑动)

验证Maven环境变量是否配置成功

[root@ip-172-31-30-69 ~]# mvn -vApache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T03:58:13-04:00)Maven home: /usr/local/apache-maven-3.5.2Java version: 1.8.0_131, vendor: Oracle CorporationJava home: /usr/java/jdk1.8.0_131/jreDefault locale: en_US, platform encoding: UTF-8OS name: "linux", version: "3.10.0-514.el7.x86_64", arch: "amd64", family: "unix"[root@ip-172-31-30-69 ~]# 

(可左右滑动)

3.下载HiBench源码,此处下载的为最新的版本

[root@ip-172-31-30-69 ~]# git clone 

(可左右滑动)

3.HiBench编译

HiBench编译支持如下几种方式:

Build AllBuild a specific framework benchmarkBuild a single moduleBuild Structured Streaming

在进行Hibench的时候可以指定Spark和Scala的版本,通过如下参数指定

查看集群Spark和Scala使用的版本指定Scala版本

可以通过参数-Dscala=xxx来指定Scala的版本,版本有(2.10或者2.11),默认使用2.11版本进行编译,使用方式如下:

[root@ip-172-31-30-69 ~]# cd HiBench/[root@ip-172-31-30-69 HiBench]# mvn -Dscala=2.10 clean package

(可左右滑动)

指定Spark版本

可以通过参数-Dspark=xxx来指定Spark的版本,版本有(1.6,2.0或者2.1),默认使用2.1版本进行编译,使用方式如下:

[root@ip-172-31-30-69 HiBench]# mvn -Dspark=1.6 clean package

(可左右滑动)

以下构建均是在root用户下操作:

1.进入HiBench-6.0目录进行编译

[root@ip-172-31-30-69 ~]# cd HiBench/[root@ip-172-31-30-69 HiBench]# ll

(可左右滑动)

2.Build All

编译所有框架及模块

[root@ip-172-31-30-69 HiBench]# mvn -Dspark=1.6 -Dscala=2.10 clean package

(可左右滑动)

3.Build a specific framework benchmark

如下指令为之构建一个Hadoop框架的benchmarks

[root@ip-172-31-30-69 HiBench]# mvn -Phadoopbench -Dspark=1.6 -Dscala=2.10 clean package

(可左右滑动)

如下指令构建Spark和Hadoop框架的benchmarks

[root@ip-172-31-30-69 HiBench]# mvn –Phadoopbench -Psparkbench -Dspark=1.6 -Dscala=2.10 clean package

(可左右滑动)

目前支持的框架有:hadoopbench, sparkbench, flinkbench, stormbench,gearpumpbench.

4.Build a single module

编译spark框架的sql模块:

mvn -Psparkbench -Dmodules -Psql -Dspark=1.6 -Dscala=2.10 clean package

(可左右滑动)

支持的模块有:micro, ml(机器学习), sql, websearch, graph, streaming, structuredStreaming(spark 2.0 or2.1).

5.Build Structured Streaming

对于Spark2.0和Spark2.1,HiBench添加了对Structured Streaming的支持,这个新的模块不能在Spark1.6中编译,即使您指定了Spark版本为2.0或者2.1,默认情况下也不会被编译,您必须明确指定如下:

mvn -Psparkbench -Dmodules -PstructuredStreaming clean package

(可左右滑动)

如上介绍了几种编译HiBench的方式,根据自己测试的需求可以选择不同的编译方式。

4.Hibench目录说明

autogen:主要用于生成测试数据的源码目录

bin:测试脚本放置目录

common:公共依赖源码目录

conf:配置文件目录(Hibench/Hadoop/Spark等配置文件存放目录)

docker:

flinkbench:Flink框架源码目录

gearpumpbench:gearpumpbench框架源码目录

hadoopbench:hadoop框架源码目录

sparkbench:spark框架的源码目录

stormbench:storm框架的源码目录

5.HiBench配置

1.配置文件说明

文件名

主要用途

benchmarks.lst

主要用于配置benchmarks的模块

flink.conf.template

Flink测试的配置参数

frameworks.lst

主要用于配置HiBench支持的测试框架

gearpump.conf.template

gearpump测试相关配置文件

hadoop.conf.template

Hadoop测试相关配置文件

hibench.conf

HiBench配置文件

spark.conf.template

Spark配置文件

storm.conf.template

Strom配置文件

2.benchmarks.lst配置文件

主要用于配置benchmarks列表,配置如下,可以对不需要测试的模块进行屏蔽或者删除,在需要屏蔽在前面加“#”如下:

[root@ip-172-31-30-69 conf]# vim benchmarks.lst micro.sleepmicro.sortmicro.terasortmicro.wordcountmicro.dfsioesql.aggregationsql.joinsql.scanwebsearch.nutchindexingwebsearch.pagerankml.bayesml.kmeansml.lrml.alsml.pcaml.gbtml.rfml.svdml.linearml.ldaml.svmgraph.nweight

(可左右滑动)

3.hadoop.conf.template配置文件

该配置文件主要用于配置Hadoop的环境,如果需要对Hadoop做benchmark测试则需要将该文件重命名为hadoop.conf

[root@ip-172-31-30-69 conf]# cp hadoop.conf.template hadoop.conf[root@ip-172-31-30-69 conf]# ll hadoop.conf-rw-r--r-- 1 root root 448 Apr 21 10:58 hadoop.conf[root@ip-172-31-30-69 conf]#

(可左右滑动)

编辑hadoop.conf文件,配置Hadoop环境,此处以CDH的目录配置为例,配置如下:

[root@ip-172-31-30-69 conf]# vim hadoop.conf# Hadoop homehibench.hadoop.home /opt/cloudera/parcels/CDH/lib/hadoop# The path of hadoop executablehibench.hadoop.executable ${hibench.hadoop.home}/bin/hadoop# Hadoop configraution directoryhibench.hadoop.configure.dir ${hibench.hadoop.home}/etc/hadoop# The root HDFS path to store HiBench datahibench.hdfs.master hdfs://nameservice1:8020# Hadoop release provider. Supported value: apache, cdh5, hdphibench.hadoop.release cdh5

(可左右滑动)

以上表中部分则为需要修改的配置。

注意:如果集群启用HA,则hibench.hdfs.master的配置需要修改为如下截图

hibench.hdfs.master hdfs://nameservice1:8020

(可左右滑动)

4.spark.conf.template配置文件

主要用于配置Spark的环境及运行参数,如果需要测试Saprk框架则需要将该配置文件重命名为spark.conf

[root@ip-172-31-30-69 conf]# cp spark.conf.template spark.conf[root@ip-172-31-30-69 conf]# ll spark.conf-rw-r--r-- 1 root root 1655 Apr 21 11:05 spark.conf[root@ip-172-31-30-69 conf]# 

(可左右滑动)

编辑spark.conf文件,配置Spark的环境,此处以CDH的目录配置为例,配置如下:

[root@ip-172-31-30-69 conf]# vim spark.conf# Spark homehibench.spark.home /opt/cloudera/parcels/CDH/lib/spark# Spark master# standalone mode: spark://xxx:7077# YARN mode: yarn-clienthibench.spark.master yarn-client# executor number and cores when running on Yarnhibench.yarn.executor.num 2hibench.yarn.executor.cores 4# executor and driver memory in standalone & YARN modespark.executor.memory 4gspark.driver.memory 4g

(可左右滑动)

根据集群环境调整相应参数。

5.hibench.conf

主要配置HiBench的运行参数及HiBench各个模块的home环境配置,根据需要修改相应的配置参数:

[root@ip-172-31-30-69 conf]# vim hibench.conf # Data scale profile. Available value is tiny, small, large, huge, gigantic and bigdata.# The definition of these profiles can be found in the workload's conf file i.e. conf/workloads/micro/wordcount.confhibench.scale.profile tiny# Mapper number in hadoop, partition number in Sparkhibench.default.map.parallelism 8# Reducer nubmer in hadoop, shuffle partition number in Sparkhibench.default.shuffle.parallelism 8#======================================================# Report files#======================================================# default report formatshibench.report.formats "%-12s %-10s %-8s %-20s %-20s %-20s %-20s\n"# default report dir pathhibench.report.dir ${hibench.home}/report# default report file namehibench.report.name hibench.report# input/output format settings. Available formats: Text, Sequence.sparkbench.inputformat Sequencesparkbench.outputformat Sequence# hibench config folderhibench.configure.dir ${hibench.home}/conf

(可左右滑动)

主要关注参数hibench.scale.profile、hibench.default.map.parallelism和hibench.default.shuffle.parallelism配置:

hibench.scale.profile:主要配置HiBench测试的数据规模;

hibench.default.map.parallelism:主要配置MapReduce的Mapper数量;

hibench.default.shuffle.parallelism:配置Reduce数量;

6.数据规模说明

HiBench的默认数据规模有:tiny, small, large, huge, gigantic andbigdata,在这几种数据规模之外Fayson还介绍如何自己指定数据量。

1.DFSIOE数据规模介绍及自定义

配置文件:${hibench.home}/conf/workloads/micro/dfsioe.conf

数据规模

读文件数

读文件大小(MB)

写文件数

写文件大小(MB)

tiny

16

1

16

1

small

32

10

32

10

large

64

10

64

10

huge

256

100

256

100

gigantic

512

400

512

400

bigdata

2048

1000

2048

1000

DFSIOE测试用例通过定义读或写的文件数和文件的大小来指定测试数据量的规模,如果需要自定义测试规模则修改文件数和文件的大小即可,文件大小以MB为单位。

例如:我需要自定义一个5TB数量级的DFSIOE测试,在hibench.conf文件中hibench.scale.profile配置的是mybigdata,需要在dfsioe.conf配置文件中增加读写文件数为5120,文件大小设置为1024,具体配置如下:

hibench.dfsioe.mybigdata.read.number_of_files 5120hibench.dfsioe.mybigdata.read.file_size 1024hibench.dfsioe.mybigdata.write.number_of_files 5120hibench.dfsioe.mybigdata.write.file_size 1024

(可左右滑动)

读写测试的数据量均为5TB = 5120 * 1024MB

2.WordCount数据规模介绍及自定义

配置文件:${hibench.home}/conf/workloads/micro/wordcount.conf

数据规模

默认配置

数据量说明

tiny

32000

数据量配置以byte为单位

small

320000000

large

3200000000

huge

32000000000

gigantic

320000000000

bigdata

1600000000000

如果需要自定义测试的数据规模,则根据hibench.conf中配置的hibench.scale.profile规模,修改wordcount.conf中对应的参数,数据量以byte为单位。例如我的hibench.conf中hibench.scale.profile配置的是mybigdata,且我想测试5TB的数据,则我需要在wordcount.conf中增加hibench.wordcount.mybigdata.datasize为5*1024*1024*1024*1024,配置如下:

hibench.wordcount.mybigdata.datasize 5497558138880

(可左右滑动)

3.Sort数据规模介绍及自定义

配置文件:${hibench.home}/conf/workloads/micro/sort.conf

数据规模

默认配置

数据量说明

tiny

32000

数据量配置以byte为单位

small

3200000

large

320000000

huge

3200000000

gigantic

32000000000

bigdata

300000000000

如果需要自定义测试的数据规模,请参照6.2章节WordCount配置说明;

4.TeraSort数据规模介绍及自定义

配置文件:${hibench.home}/conf/workloads/micro/terasort.conf

TeraGen源码中数据量说明注释如下:

/** * Generate the official GraySort input data set. * The user specifies the number of rows and the output directory and this * class runs a map/reduce program to generate the data. * The format of the data is: * <ul> * <li>(10 bytes key) (constant 2 bytes) (32 bytes rowid) * (constant 4 bytes) (48 bytes filler) (constant 4 bytes) * <li>The rowid is the right justified row id as a hex number. * </ul> * <p> * To run the program: * <b>bin/hadoop jar hadoop-*-examples.jar teragen 10000000000 in-dir</b> */

(可左右滑动)

数据规模

默认配置

数据量说明

tiny

32000

数据量配置以条数为单位,每条数据约100byte

small

3200000

large

32000000

huge

320000000

gigantic

3200000000

bigdata

6000000000

如果需要自定义测试的数据规模,则根据hibench.conf中配置的hibench.scale.profile规模,修改terasort.conf中对应的参数。例如我的hibench.conf中hibench.scale.profile配置的是mybigdata,且我想测试5TB的数据,则我需要在terasort.conf中增加hibench.terasort.mybigdata.datasize为5*1024*1024*1024*1024/100,配置如下:

hibench.terasort.mybigdata.datasize 54975581389

(可左右滑动)

5.join数据规模介绍及自定义

配置文件:${hibench.home}/conf/workloads/sql/join.conf

数据规模

uservisits

pages

数据说明

tiny

1000

120

每条page大小约60byte,每条uservisit大小约186byte

small

100000

12000

large

1000000

120000

huge

10000000

1200000

gigantic

100000000

12000000

bigdata

5000000000

120000000

如果需要自定义测试的数据规模,则根据hibench.conf中配置的hibench.scale.profile规模,修改terasort.conf中对应的参数。例如我的hibench.conf中hibench.scale.profile配置的是mybigdata,且我想测试3TB的数据,则我需要在terasort.conf中增加hibench.join.mybigdata.uservisits为3*1024*1024*1024*1024/186,

hibench.join.mybigdata.pages为25G*1024*1024*1024/60

配置如下:

hibench.join.bigdata.uservisits 18000000000hibench.join.bigdata.pages 450000000

(可左右滑动)

7.HiBench使用

在试用HiBench进行基准测试时,可以使用批量的方式运行也可以针对单个用例进行测试,可以挑选我们要测试的用例配置在${hibench_home}/conf/benchmarks.lst文件中,也可以运行单个用例的测试脚本进行测试。HiBench的测试分为两个阶段一个数据准备节点一个用例测试阶段,在用例测试阶段会使用MR和Spark的方式分别运行示例。

1.批量运行,在${hibench_home}/bin目录下执行run_all.sh脚本

该脚本运行的事例均是在${hibench_home}/conf/benchmarks.lst文件中配置了的示例。

2.单个实例运行,在运行单个实例的时候我们要先运行数据准备脚本

每个用例对应的脚本在${hibench_home}/bin/workloads/micro/wordcount

脚本目录包含了MR和Spark两种方式执行事例的脚本,prepare目录下的脚本用于生成测试数据。

3.查看运行结果

通过HDFS可以看到/HiBench目录下生成的各个用例生成的测试数据及用例结果

在{hibench_home}/report目录下生成了各个示例的运行结果

查看hibench.report文件可以看到每个用例的测试数据量、运行耗时及吞吐

通过测试结果结合CM的监控数据对集群进行的各项指标进行分析,同时可以在所有的节点启用nmon脚本来监控服务的性能指标进行综合分析。

8.常见问题记录

1.mvn编译时异常,异常信息如下

[INFO] ------------------------------------------------------------------------[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.2.0:compile (scala-compile-first) on project hibench-common: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1][ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.[ERROR] Re-run Maven using the -X switch to enable full debug logging.[ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles:[ERROR] [Help 1] [ERROR] [ERROR] After correcting the problems, you can resume the build with the command[ERROR] mvn <goals> -rf :hibench-common

(可左右滑动)

原因:确认能使用maven正常下载、更新依赖库或编译时所属用户权限不足导致;

此处报错使用了ec2-user用户,切换至root用户后正常编译。

提示:代码块部分可以左右滑动查看噢

为天地立心,为生民立命,为往圣继绝学,为万世开太平。

温馨提示:要看高清无码套图,请使用手机打开并单击图片放大查看。

推荐关注Hadoop实操,第一时间,分享更多Hadoop干货,欢迎转发和分享。

原创文章,欢迎转载,转载请注明:转载自微信公众号Hadoop实操

标签: #oracleora31655