Hadoop 集群测试报告
1.测试环境
硬件环境
软件环境
RHEL6.2
hadoop-1.0.2
hive-0.8.1
hbase-0.92.1
o
o
o
o
o Oracle 11g_r2(64 位)
o KVM
o MySQL-server-5.5.23-1.el6.x86_64
o
o
2.6.32-220.el6.x86_64
jdk-7u3-linux-x64
sqoop-1.4.1-incubating__hadoop-1.0.0.tar.gz
2.集群部署
namenode
Hmaster
JobTracker
hadoop1
datanode
datanode
datanode
datanode
datanode
datanode
datanode
datanode
datanode
regionserver
regionserver
regionserver
regionserver
regionserver
regionserver
regionserver
regionserver
regionserver
taskTracker
taskTracker
taskTracker
taskTracker
taskTracker
taskTracker
taskTracker
taskTracker
taskTracker
hadoop21
hadoop22
hadoop31
hadoop32
hadoop41
hadoop42
hadoop51
hadoop52
secondary namenode
hadoop2
hadoop3
hadoop4
hadoop5
hadoop6
3.Hadoop 集群基准测试
3.1 写测试
写 10 个 1000M 的文件
[root@hadoop1 hadoop]# hadoop jar hadoop-test-1.0.2.jar TestDFSIO -write -nrFiles 10 -fileSize
1000
结果:
----- TestDFSIO ----- : write
Date & time: Tue Jul 10 10:52:56 CST 2012
Number of files: 10
Total MBytes processed: 10000
Throughput mb/sec: 19.991963230781227
Average IO rate mb/sec: 20.200298309326172
IO rate std deviation: 2.094306472547166
Test exec time sec: 104.689
The index 1 ≤ i ≤ N denotes the individual map tasks
3.2 读测试
读 10 个 1000M 的文件
[root@hadoop1 hadoop]# hadoop jar hadoop-test-1.0.2.jar TestDFSIO -read -nrFiles 10 -fileSize
1000
结果:
----- TestDFSIO ----- : read
Date & time: Tue Jul 10 11:03:14 CST 2012
Number of files: 10
Total MBytes processed: 10000
Throughput mb/sec: 41.544111537630656
Average IO rate mb/sec: 44.81391143798828
IO rate std deviation: 13.201496268890057
Test exec time sec: 67.595
清除测试数据
[root@hadoop1 hadoop]#hadoop jar hadoop-test-1.0.2.jar TestDFSIO -clean
3.3 排序测试
1. 在各节点上分别运行 10 个 map 任务,每个节点产生 10GB 大小的随机二进制数据。
# hadoop jar hadoop-examples-1.0.2.jar randomwriter /benchmarks/random-data
MapReduce(map:90 个,reduce:0 个) Finished in: 14mins, 37sec
2. 排序
jar
#hadoop
/benchmarks/sorted-data
MapReduce(map:720 个,reduce:48 个) Finished in: 1hrs, 34mins, 15sec
hadoop-examples-1.0.2.jar
sort
/benchmarks/random-data
3. 检查是否已经排好序
#hadoop jar hadoop-test-1.0.2.jar
testmapredsort
-sortInput
/benchmarks/random-data
-sortOutput /benchmarks/sorted-data
MapReduce(map:138 个,reduce:1 个)Finished in: 14mins, 25sec
结果提示:SUCCESS! Validated the MapReduce framework's 'sort' successfully. 说明都已
排序
3.4MapReduce 连续性测试
每个 JOB 处理 10000 行文本文件,6 个 map,2 个 reduce,只对数据进行收集,总共跑
10 次。
#hadoop jar hadoop-test-1.0.2.jar mrbench -numRuns 10 -maps 6 -reduces 2 -inputLines
10000
DataLines
10000
每个 JOB 平均花费 31 秒。
Maps
6
Reduces AvgTime (milliseconds)
2
31413
4.Hbase 测试
4.1 批量导入测试
HBASE 建表
create 'test','mtim','f';
数据文件说明
15 个字段,第一个字段是 MSISDN+(INTMAXVALUE-时间戳),第二字段是 MSISDN,第
三个字段是时间戳,其余 12 个字段是各自长度为 21B 的随机字符串。
ROWKEY:MSISDN+(Long.MAX_VALUE-System.currentTimeMillis)
MSISDN 1362 开头
生成模拟数据执行命令
参数列表:
在当前目录生成 1000000 行的另外 12 个字段,每个字段 21B 的文件 htestquery1.dat
#hadoop jar hbase1emock.jar 1000000 12 21 ./htestquery1.dat
jar
/home/hbase/hbase-0.92.1-security.jar
向 HBASE 导入数据的命令:
#hadoop
-Dimporttsv.separator=","
-Dimporttsv.columns=HBASE_ROW_KEY,f:c1,f:c2,f:c3,f:c4,f:c5,f:c6,f:c7,f:c8,f:c9,f:c10,f:c11,f:
c12,f:c13,f:c14
有两种方式:1. WriteToWAL(false) (不写 WAL 日志)2. WriteToWAL(true)(写 WAL 日志)
test /test/input
importtsv
生成模拟数据的步骤
当前目录/home/hadoop/test/
1.#hadoop fs –rm /test/input/*
2. #hadoop jar hbase1emock.jar 10000000 12 21 ./htestquery1.dat
3.#hadoop fs –moveFromLocal ./ /htestquery1.dat /test/input
4.#hadoop
-Dimporttsv.separator=","
-Dimporttsv.columns=HBASE_ROW_KEY,f:c1,f:c2,f:c3,f:c4,f:c5,f:c6,f:c7,f:c8,f:c9,f:c10,f:c11,f:
c12,f:c13,f:c14
/home/hbase/hbase-0.92.1-security.jar
test /test/input
importtsv
jar
生成一亿数据
批号 文件(容量*个数) MapReduce 花费时间 毫秒数 插入方式 平均
1
2
10min, 13sec
10min, 3sec
308MB*10
308MB*10
613
603
2
2
5.3MB/s
3
4
5
6
7
8
9
10
308MB*10
308MB*10
308MB*10
3080MB*1
308MB*10
308MB*10
308MB*10
308MB*10
8min, 14sec
11min, 21sec
8min, 32sec
3min, 18sec
3min, 2sec
3min, 29sec
3min, 20sec
4min, 25sec
494
681
512
198
182
209
200
265
2
2
2
1
1
1
1
1
14.5MB/s
分析:
是否写 WAL 日志,对批量入库的效率有明显的体现。但不写 WAL 日志,会降低数据库的
安全性,可靠性,数据库出现故障时,无法恢复,回滚
4.2 查询测试
Hbase 点查询
QueryByCondition1(String tableName,String rowkey)
已知一个 ROWKEY,查询结果
测试结果:
毫秒级
Hbase 范围查询
queryRange(String tableName,byte[] startrow,String msisdn)
测试参数
参数
Test
hadoop21,hadoop22,hadoop31,hadoop32,hado
op41,hadoop42,hadoop51,hadoop52,hadoop6
15476159924
20120710000000
查询该手机号码在某日期时间前发生的记录
备注
表名
Hbase 数据库连接
手机号码
日期时间(YYYYMMDDHH24MISS)
测试结果
顺序访问,手机号码随机
顺序号
1
2
3
4
5
花费时间
1023ms
227ms
252ms
216ms
707ms
命中率
100
100
100
100
100
随机 5 个线程并发访问,手机号码随机
线程序号
1
2
3
4
5
花费时间
1146ms
1260ms
1286ms
1313ms
1343ms
随机 20 个线程并发访问,手机号码随机
线程序号
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
花费时间
5036ms
5122ms
5187ms
5300ms
5336ms
5350ms
5361ms
5420ms
5458ms
5495ms
5521ms
5559ms
5585ms
5621ms
5659ms
5709ms
5799ms
5801ms
5861ms
6018ms
4.3 总结
命中率
100
100
100
100
100
命中率
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
1. 是否写 WAL 日志,对于 Hbase 的批量入库性能有较大影响。是否采用需要多方面的权
衡。
2. 顺序访问时,所费时间是毫秒级。
3. 很显然,并发数越少,访问所费时间越长。并发数为 5 时,所费时间不超过 2 秒。
4. 用 SingleColumnValueFilter 等 Filter 方式进行过滤查询,效率低,海量数据下难以达到
一般业务需求。测试 1000 万以上数据,查询一个号码(如:13621217968)的匹配,需
要 110122 milseconds+。
5.Hive 测试
5.1 测试条件
在 HIVE 库创建测试表 test
create table test (f1 string,f2 string,f3 string,f4 string,f5 string,f6 string,f7 string,f8 string,f9
string,f10 string,f11 string,f12 string,f13 string,f14 string,f15 string,f16 string,f17 string,f18
string,f19 string,f20 string) row format delimited
测试结果表:test_group1
create table test_group1(name string,result int);
fields terminated by ',';
7 个 CSV 数据源文件
每一个文件 20 个字段,每行 4KB,100 万行记录 文件大小 3.8G
测试文件容量总计:3.8*7=26.6G,总计 700 万行
5.2 测试过程
1. 导入数据
通过如下命令依次导入 7 个文件
load data local inpath '/root/Downloads/sqllder100w.dat' into table test;
2. 聚集方法测试
INSERT OVERWRITE TABLE test_group1 select F2,COUNT(*) from test GROUP BY F2;
MapReduce 费时 174.473 seconds
结束后:test_group1 为 100 万行记录
3. 排序测试
INSERT OVERWRITE TABLE test_group2
select F2,RESULT from (
select F2,COUNT(*) AS RESULT from test GROUP BY F2 cluster by F2
) t sort by F2;
MapReduce 两阶段执行,费时 210.968 seconds
4. 外连接测试
做 count,avg 聚集函数,左连接。其中表 TEST_GROUP1 有 100 万行,表 TEST 有 700
万行。
INSERT OVERWRITE TABLE test_group select F2,COUNT(*),avg(f3) from test LEFT
OUTER JOIN TEST_GROUP1 ON (test.f2=test_group1.name) GROUP BY F2;
MapReduce 两阶段执行,费时 180.489 seconds