下面的hadoop-examples.jar是建立的软链接:hadoop-examples.jar -> /opt/cloudera/parcels/CDH-5.12.01.cdh5.12.0.p0.29/share/doc/hadoop-0.20-mapreduce/examples/hadoop-examples.jar
CDH安装的hadoop在这里: /opt/cloudera/parcels/CDH-5.12.01.cdh5.12.0.p0.29/share/doc/hadoop-0.20mapreduce/examples/hadoop-examples.jar
手动安装的在这里:$YARN_HOME/share/hadoop/mapreduce/hadoop-mapreduce-examples-xxxx.jar
运行pi实例
yarn jar hadoop-examples.jar pi 6 2000
运行terasort测试
1、使用teragen产生数据
yarn jar hadoop-examples.jar teragen 参数1 参数2
参数1:行数(一行的长度为100B,要写100GB数据需要使用1 000 000 000行)
参数2:数据输出目录(hdfs文件系统中的目录)
例子:
yarn jar hadoop-examples.jar teragen 100000 /workspace/test_teragen
或
hadoop jar hadoop-*-examples.jar teragen -Dmapred.map.tasks=100 10000000 /workspace/test_teragen
yarn jar hadoop-examples.jar teragen -Dmapred.map.tasks=100 10000000 /workspace/test_teragen
其中-Dmapred.map.tasks=100指定map的数量,默认是两个map
hadoop里也是调用的yarn所以都一样
2、运行terasort对数据进行排序
hadoop jar hadoop-examples.jar terasort 参数1 参数2
参数1:输入目录
参数2:输出目录
例子:
hadoop jar hadoop-examples.jar terasort -Dmapred.reduce.task=5 /workspace/test_teragen /workspace/test_terasort
yarn jar hadoop-examples.jar terasort -Dmapred.reduce.task=5 /workspace/test_teragen /workspace/test_terasort
-Dmapred.reduce.task=5设置reduce个数,默认为1
3、运行terabalidate验证排序过的terasort
hadoop jar hadoop-examples.jar teravalidate 参数1 参数2
参数1:输入目录
参数2:输出目录
例子:
hadoop jar hadoop-examples.jar teravalidate /workspace/test_terasort /workspace/test_validate
yarn jar hadoop-examples.jar teravalidate /workspace/test_terasort /workspace/test_validate
运行grep测试
grep示例程序的帮助
[superahua@a1 workspace]$ hadoop jar hadoop-examples.jar grep
Grep <inDir> <outDir> <regex> [<group>]
Generic options supported are
-conf <configuration file> specify an application configuration file
-D <property=value> use value for given property
-fs <local|namenode:port> specify a namenode
-jt <local|resourcemanager:port> specify a ResourceManager
-files <comma separated list of files> specify comma separated files to be copied to the map reduce cluster
-libjars <comma separated list of jars> specify comma separated jar files to include in the classpath.
-archives <comma separated list of archives> specify comma separated archives to be unarchived on the compute machines.
The general command line syntax is
bin/hadoop command [genericOptions] [commandOptions]
$ hdfs dfs -mkdir /workspace/test_grep //创建输入目录
$ hdfs dfs -put /mnt/hgfs/a_share/hdfs-default.xml /workspace/test_grep/ //放入输入文件
$ hadoop jar hadoop-examples.jar grep /workspace/test_grep/hdfs-default.xml /workspace/test_grep/test_out/ 'dfs[a-z.]+'
$ hdfs dfs -cat /workspace/test_grep/test_out/* //查看输出文件
hadoop jar hadoop-examples.jar grep 输入文件 输出目录 正则表达式
运行workcount测试
$ hdfs dfs -mkdir /workspace/test_wordcount //建立测试文件夹
$ hdfs dfs -put /mnt/hgfs/a_share/aa.txt /workspace/test_wordcount/ //方入测试文件
$ hadoop jar hadoop-examples.jar wordcount /workspace/test_wordcount/aa.txt /workspace/test_wordcount/test_out //运行测试程序
$ hdfs dfs -cat /workspace/test_wordcount/test_out/part-r-0000* //查看结果
命令: hadoop jar hadoop-examples.jar wordcount 输入文件 输出文件夹
hadoop的基准评测程序
hadoop自带若干基准评测程序,上面已经测试过。
还有一个TestDFSIO,通过cdh安装的hadoop可能没有,主要用于测试HDFS的I/O性能。
其他的基准评测程序:
MRBench(使用mrbench)会多次运行一个小型作业。与sort基准不同,该基准的主要目的是检验小型作业能否快速响应。
NNBench(使用nnbench)测试namenode硬件的加载过程。
Gridmix而是一个基准平测程序套装。通过模拟一些真实常见的数据访问模式,Gridmix能逼真地为一个集群的负载建模。
SWIM(StatisticaI WorkIoad lnjector for MapReduce),是一个真实的MapReduce工作负载库,可以用来为被测系统生成代表性的测试负载。https://github.com/SWIMProjectUCB/SWIM/wiki
想对测试的例子配置的话可以参考这个https://blog.csdn.net/Ahuuua/article/details/90767723