zoukankan      html  css  js  c++  java
  • 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怎么样是不是还挺有趣的)

  • 相关阅读:
    Java 判断日期的方法
    HTTP Session例子
    Unity3D性能优化
    TCP学习之二:客户端与服务端的连接
    TCP学习之一:TCP网络编程概念
    TCP学习之三:客户端、服务端同步传输字符串
    TCP学习之四:传输协议
    Lua与.net的CLR相互调用
    HTC vive开发:关于手柄按键
    JavaSESocket编程之简易聊天系统
  • 原文地址:https://www.cnblogs.com/LionheartCGJ/p/7129209.html
Copyright © 2011-2022 走看看