Hadoop MapReduce 上的 WordCount

  1. 首先开启hdfs 和 yarn

    sbin/start-dfs.sh 
    sbin/start-yarn.sh
    
  2. 在 hdfs 上创建目录

     hdfs dfs -mkdir -p /wordcount/input
    
  3. 在linux 下创建 a.log b.txt 两个文件,再把两个文件通过put 上传至 hdfs

    hdfs dfs -put a.log /wordcount/input
    hdfs dfs -put b.txt /wordcount/input
    
  4. 寻找到 example 示例

find ./ -name '*example*.jar'
  1. 运行 示例
hadoop jar   ./share/hadoop/mapreduce1/hadoop-examples-2.6.0-mr1-cdh5.7.0.jar wordcount  /wordcount/input /wordcount/output

猜你喜欢

转载自blog.csdn.net/weixin_43517453/article/details/88422473