• RedHat 安装Hadoop并运行wordcount例子


    1.安装 Red Hat 环境

    2.安装JDK

    3.下载hadoop2.8.0 

      http://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/hadoop-2.8.0/hadoop-2.8.0.tar.gz

    4.在用户目录下新建hadoop文件夹,并解压hadoop压缩包

      mkdir Hadoop
    
      tar -zxvf hadoop-2.8.0.tar.gz

    5.为hadoop配置JAVA_HOME

    [xxx@localhost ~]$ cd hadoop/hadoop-2.8.0/etc/hadoop/
    [xxx@localhost hadoop]$ vi hadoop-env.sh 
    

    6.格式化(初始化)HDFS文件系统

    [xxx@localhost ~]$ cd hadoop/hadoop-2.8.0/bin
    [xxx@localhost bin]$ ./hadoop namenode -format
    

      (ps:hadoop namenode -format 已经过时 hdfs namenode -format 最新的需要等待较长时间)

    7.启动haddop

    [xxx@localhost ~]$ cd hadoop/hadoop-2.8.0/sbin/
    [xxx@localhost sbin]$ ./start-all.sh

      (ps:现在推荐使用 ./start-hdfs.sh ./start-yarn.sh)

    8.jps查看hadoop是否成功启动

    9.在hadoop目录里下新建文件夹并新建两个测试文件

    [xxx@localhost ~]$ cd hadoop/
    [xxx@localhost hadoop]$ mkdir test
    [xxx@localhost hadoop]$ cd test/
    [xxx@localhost test]$ echo "hello word" > file1.txt
    [xxx@localhost test]$ echo "hello hadoop" > file2.txt
    

    10.在hdfs文件系统里新建input文件夹并将测试文件上传

    [xxx@localhost ~]$ cd hadoop/hadoop-2.8.0/bin/
    [xxx@localhost bin]$ ./hadoop fs -mkdir input
    [xxx@localhost bin]$ ./hadoop fs -put ~/hadoop/test/file*.txt input
    17/07/06 16:33:34 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    [xxx@localhost bin]$ ./hadoop fs -ls input
    17/07/06 16:33:45 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    Found 2 items
    -rw-r--r--   1 chenguangjin chenguangjin         11 2017-07-06 16:33 input/file1.txt
    -rw-r--r--   1 chenguangjin chenguangjin         13 2017-07-06 16:33 input/file2.txt

      (ps:注意此处由WARN,不需要管它,可以成功上传)

    11.运行wordcount小例子

    [xxx@localhost bin]$ ./hadoop jar ~/hadoop/hadoop-2.8.0/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.8.0.jar  wordcount input output

    12.查看结果

    [xxx@localhost bin]$ ./hadoop fs -text output/part-r-00000
    17/07/06 16:46:02 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
    hadoop    1
    hello    2
    word    1
    [xxx@localhost bin]$ 

    (over怎么样是不是还挺有趣的)

  • 相关阅读:
    python!让人惊讶的python
    由测试中的版本同步联想到敏捷开发中的两个实践
    python中比较两个文件是否相同
    python中根据类名生成类的实例
    使用sqlServer开发应用程序时要注意的10件事
    python版的Hello World
    其他语言的.net实现列表
    Bug管理的流程和几个重点
    IL Reference
    Delphi CreateProcess函数调用示例
  • 原文地址:https://www.cnblogs.com/LionheartCGJ/p/7129209.html
Copyright © 2020-2023  润新知