hadoop 自带 workcount

1、启动 hdfs 并建立目录,上传文件

#启动 hadoop

start-dfs.sh

#...

#创建一个多层级的目录结构

hadoop fs -mkdir -p /wordcount/input

#将本地文件 a.txt 上传至目录中。也可以上传多个文件

hadoop fs -put a.txt /wordcount/input

2、启动 yarn

start-yarn.sh

#...

3、运行hadoop自带的mapreduce样例

hadoopjarhadoop-mapreduce-examples-2.6.4.jarwordcount/wordcount/input/

    /workcount/output/

#hadoop固定前置关键词

#jar表示运行jar文件

#hadoop-mapreduce-examples-2.6.4.jar需要被运行的jar文件

#wordcountjar文件的中的主类名称(该类的作用是统计某一目录下所有文

    件所包含的字数并输出)

#/wordcount/input/主类需要的第一个参数。hdfs的目录

#/wordcount/output/主类需要的第二个参数。hdfs的目录

4、查看输出结果

hadoop fs -cat /wordcount/output/part-r-00000

猜你喜欢

转载自my.oschina.net/roadom/blog/1800065
今日推荐