Ubuntu 上的 Hadoop 安装

Ubuntu 上的 Hadoop 安装

有人能帮我在 ubuntu vm 上安装 Hadoop 吗?我在格式化 namenode 步骤时遇到了困难,我尝试了所有可能的步骤,但我不知道我哪里犯了错误。以下是我在格式化时遇到的错误

用户@ubuntu:/lib/hadoop/hadoop-2.7.1/bin$ hadoop namenode -format

DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

/lib/hadoop/hadoop-2.7.1/bin/hdfs: line 304: /lib/jvm/jdk1.8.0_111/bin/java: Permission denied
/lib/hadoop/hadoop-2.7.1/bin/hdfs: line 304: exec: /lib/jvm/jdk1.8.0_111/bin/java: cannot execute: Permission denied

当我要启动名称节点时,它会告诉我以下错误并反复询问我密码。

用户@ubuntu:/lib/hadoop/hadoop-2.7.1/sbin$ start-all.sh

This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
/lib/hadoop/hadoop-2.7.1/bin/hdfs: line 304: /lib/jvm/jdk1.8.0_111/bin/java: Permission denied
/lib/hadoop/hadoop-2.7.1/bin/hdfs: line 304: exec: /lib/jvm/jdk1.8.0_111/bin/java: cannot execute: Permission denied
Starting namenodes on []
user@localhost's password: 
localhost: starting namenode, logging to /lib/hadoop/hadoop-2.7.1/logs/hadoop-user-namenode-ubuntu.out
localhost: /lib/hadoop/hadoop-2.7.1/bin/hdfs: line 304: /lib/jvm/jdk1.8.0_111/bin/java: Permission denied
localhost: /lib/hadoop/hadoop-2.7.1/bin/hdfs: line 304: exec: /lib/jvm/jdk1.8.0_111/bin/java: cannot execute: Permission denied
user@localhost's password: 
localhost: starting datanode, logging to /lib/hadoop/hadoop-2.7.1/logs/hadoop-user-datanode-ubuntu.out
localhost: /lib/hadoop/hadoop-2.7.1/bin/hdfs: line 304: /lib/jvm/jdk1.8.0_111/bin/java: Permission denied
localhost: /lib/hadoop/hadoop-2.7.1/bin/hdfs: line 304: exec: /lib/jvm/jdk1.8.0_111/bin/java: cannot execute: Permission denied
/lib/hadoop/hadoop-2.7.1/bin/hdfs: line 304: /lib/jvm/jdk1.8.0_111/bin/java: Permission denied
/lib/hadoop/hadoop-2.7.1/bin/hdfs: line 304: exec: /lib/jvm/jdk1.8.0_111/bin/java: cannot execute: Permission denied
starting yarn daemons
starting resourcemanager, logging to /lib/hadoop/hadoop-2.7.1/logs/yarn-user-resourcemanager-ubuntu.out
/lib/hadoop/hadoop-2.7.1/bin/yarn: line 330: /lib/jvm/jdk1.8.0_111/bin/java: Permission denied
/lib/hadoop/hadoop-2.7.1/bin/yarn: line 330: exec: /lib/jvm/jdk1.8.0_111/bin/java: cannot execute: Permission denied
user@localhost's password: 

答案1

我刚刚在装有 Hadoop 版本 2.7.3 的 VM(Kubuntu 16.04)上运行了它。

先决条件:

  1. Ubuntu 操作系统
  2. 具有 sudo 权限的非 root 用户
  3. 已安装 Java

脚步:

  1. 从以下位置下载 Hadoop 版本这里经过

    • 点击压缩包所需版本列
    • 点击下面的链接我们建议您从以下镜像站点进行下载:或右键单击并保存链接

      • 如果链接已保存,则使用以下命令下载:

        wget http://www-us.apache.org/dist/hadoop/common/hadoop-2.7.3/hadoop-2.7.3.tar.gz

        在此处输入图片描述

  2. 检查下载的完整性:

    • .md5从下载处下载文件 在此处输入图片描述 在此处输入图片描述 在此处输入图片描述

    • 运行shasum -a 256 hadoop-2.7.3.tar.gz并将结果与cat hadoop-2.7.3.tar.gz.mds​​此行进行比较

      ...
       hadoop-2.7.3.tar.gz: SHA256 = D489DF38 08244B90 6EB38F4D 081BA49E 50C4603D B03EFD5E 594A1E98 B09259C2
      ...
      
  3. 安装Hadoop:

    • 解压并移动:

      tar -xzvf hadoop-2.7.3.tar.gz && sudo mv hadoop-2.7.3 /usr/local/hadoop
      
    • 使用以下命令在您的系统上找到 java:

      readlink -f /usr/bin/java | sed "s:bin/java::"
      # result
      /usr/lib/jvm/java-8-openjdk-amd64/jre/
      
    • 编辑hadoop-env.sh文件sudo nano /usr/local/hadoop/etc/hadoop/hadoop-env.sh

      • 选项 1(静态值):

        #export JAVA_HOME=${JAVA_HOME}
        export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/
        
      • 选项 2(动态值随着系统上的 Java 的变化而变化):

        #export JAVA_HOME=${JAVA_HOME}
        export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
        
  4. 运行Hadoop:

    • /usr/local/hadoop/bin/hadoop

      • 输出:

        Usage: hadoop [--config confdir] [COMMAND | CLASSNAME]
        CLASSNAME            run the class named CLASSNAME
        or
        where COMMAND is one of:
        fs                   run a generic filesystem user client
        version              print the version
        jar <jar>            run a jar file
                             note: please use "yarn jar" to launch
                                  YARN applications, not this command.
        checknative [-a|-h]  check native hadoop and compression libraries availability
        distcp <srcurl> <desturl> copy file or directories recursively
        archive -archiveName NAME -p <parent path> <src>* <dest> create a hadoop archive
        classpath            prints the class path needed to get the
        credential           interact with credential providers
                             Hadoop jar and the required libraries
        daemonlog            get/set the log level for each daemon
        
  5. 测试:

    mkdir ~/input
    cp /usr/local/hadoop/etc/hadoop/*.xml ~/input
    
    /usr/local/hadoop/bin/hadoop jar /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar grep ~/input ~/grep_example 'principal[.]*';
    
    • 检查结果中的错误:

       File System Counters
              FILE: Number of bytes read=1247674
              FILE: Number of bytes written=2324248
              FILE: Number of read operations=0
              FILE: Number of large read operations=0
              FILE: Number of write operations=0
       Map-Reduce Framework
              Map input records=2
              Map output records=2
              Map output bytes=37
              Map output materialized bytes=47
              Input split bytes=114
              Combine input records=0
              Combine output records=0
              Reduce input groups=2
              Reduce shuffle bytes=47
              Reduce input records=2
              Reduce output records=2
              Spilled Records=4
              Shuffled Maps =1
              Failed Shuffles=0
              Merged Map outputs=1
              GC time elapsed (ms)=61
              Total committed heap usage (bytes)=263520256
        Shuffle Errors
              BAD_ID=0
              CONNECTION=0
              IO_ERROR=0
              WRONG_LENGTH=0
              WRONG_MAP=0
              WRONG_REDUCE=0
       File Input Format Counters
              Bytes Read=151
       File Output Format Counters
              Bytes Written=37
      

来源:

https://www.digitalocean.com/community/tutorials/how-to-install-hadoop-in-stand-alone-mode-on-ubuntu-16-04

添加路径到.bashrc:

# hadoop executable
export PATH="/usr/local/hadoop/bin:$PATH"

答案2

似乎您错过了一些与覆盖 Hadoop 配置中的权限设置相关的步骤。但这应该不是问题。它会要求输入 Hadoop 中每个组件的密码,因此从您的屏幕截图来看,要求输入 3 次密码,一次是针对 namenode,然后是 datanode,然后是资源管理器。它会再要求输入 2 次密码,一次是针对辅助 namenode,另一次是针对节点管理器。完成此操作后,其余操作应该会顺利进行。

请参考以下链接:

在 Ubuntu 上安装 Hadoop 的详细分步说明,附有详细的屏幕截图和说明:

https://drive.google.com/file/d/0B0YcHWv8cfAjdzAxbjlReUNLWUU/view

本文档是我在多个版本的 Ubuntu 上安装了多个版本的 Hadoop 后创建的。因此,上述文档讨论了在 Ubuntu 上安装 Hadoop 时遇到的大多数常见问题/错误/疑问。

相关内容