1. 程式人生 > >Hadoop系列(三):hadoop基本測試

Hadoop系列(三):hadoop基本測試

下面是對hadoop的一些基本測試示例

Hadoop自帶測試類簡單使用

這個測試類名叫做 hadoop-mapreduce-client-jobclient.jar,位置在 hadoop/share/hadoop/mapreduce/ 目錄下

不帶任何引數可以獲取這個jar的幫助資訊

$ yarn jar hadoop-mapreduce-client-jobclient-2.8.5.jar

1. TestDFSIO

用於測試hdfs的IO效能,使用一個mapReduce作業來併發的執行讀寫操作,每個map任務用於讀或寫每個檔案,map輸出用於手機與處理檔案相關的統計資訊,Reduce用於累計和統計資訊,併產生summary。

1) TestDFSIO write

例子:向HDFS中寫入10個1000M檔案

$ yarn jar hadoop-mapreduce-client-jobclient-2.8.5.jar TestDFSIO -write -nrFiles 10 -fileSize 1000 -resFile /home/hadoop/hadoop_test/TestDFSIO_write.log

測試結果如下:
----- TestDFSIO ----- : write
            Date & time: Thu Nov 15 12:04:51 CST 2018
        Number of files: 10
 Total MBytes processed: 10000
      Throughput mb/sec: 6.29
 Average IO rate mb/sec: 6.39
  IO rate std deviation: 0.87
     Test exec time sec: 230.35

引數說明:
  TestDFSIO     表示測試型別
	-write      表示寫測試
	-nrFiles    表示往HDFS 寫入多少個檔案
	-fileSize   表示寫入每個檔案的大小
	-resFile    表示最後的測試結果輸出到的檔案

 2) TestDFSIO read

例子:從HDFS中讀取10個1000M檔案

$ yarn jar hadoop-mapreduce-client-jobclient-2.8.5.jar TestDFSIO -read -nrFiles 10 -fileSize 1000 -resFile /home/hadoop/hadoop_test/TestDFSIO_read.log

測試結果如下:
----- TestDFSIO ----- : read
            Date & time: Thu Nov 15 13:31:10 CST 2018
        Number of files: 10
 Total MBytes processed: 10000
      Throughput mb/sec: 20.23
 Average IO rate mb/sec: 21.09
  IO rate std deviation: 4.26
     Test exec time sec: 97.46

3) 清空測試資料

$ yarn jar hadoop-mapreduce-client-jobclient-2.8.5.jar TestDFSIO -clean

 2.  nnbench測試 

nnbench用於測試NameNode的負載,他會產生很多餘HDFS相關的請求,給NameNode施加較大的壓力。這個測試能在hdfs上模擬建立,讀取,重新命名和刪除檔案等操作。

例子: 使用12個mapper和6個Reduce來建立1000個檔案

$ yarn jar hadoop-mapreduce-client-jobclient-2.8.5.jar nnbench -operation create_write -maps 12 -reduces 6 \
-blockSize 1 -bytesToWrite 0 -numberOfFiles 1000 -replicationFactorPerFile 3 -readFileAfterOpen true \
-baseDir /benchmarks/NNBench-`hostname -s`

3. mrbench測試
mrbench會多次重複一個小作業,用於檢查在叢集上小作業的是否可重複以及執行是否可高效,用法如下:

例子:以下會執行一個小作業一共50次

$ yarn jar hadoop-mapreduce-client-jobclient-2.8.5.jar mrbench -numRuns 50

測試結果:
DataLines       Maps    Reduces AvgTime (milliseconds)
1               2       1       30248

 4. mapreduce 排序測試

生成1G測試資料放到/examples/terasort-input

$ yarn jar hadoop-mapreduce-examples-2.8.5.jar teragen 10000000 /examples/terasort-input

 開始排序

$ yarn jar hadoop-mapreduce-examples-2.8.5.jar terasort /examples/terasort-input /examples/terasort-output
/examples/terasort-input         輸入目錄
/examples/terasort-output	 輸出目錄

檢視校驗資料

/examples/terasort-output/part-r-00000

校驗資料為空,排序功能正常