简体   繁体   English

Ubuntu 14上的Hadoop安装2.6.0-Java错误

[英]Hadoop Installation 2.6.0 on Ubuntu 14 - Java Error

EDIT 编辑

I am trying to install Hadoop 2.6.0 on my Ubuntu 14 machine. 我正在尝试在Ubuntu 14计算机上安装Hadoop 2.6.0。 I am coming across an error though. 我遇到了一个错误。

When I am trying to set the HOME variable for Java it does not seem to be doing as expected. 当我尝试为Java设置HOME变量时,它似乎未达到预期的效果。

I am on my machine as hduser setup specifically for running and using Hadoop. 我在计算机上使用的是hduser设置,专门用于运行和使用Hadoop。 This user is a sudoer. 该用户是一个sudoer。

Some information: 一些信息:

java -version' gives the following

java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu0.14.04.2)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)

This is the only version installed on my machine, which can be seen by running the following command: 这是我的机器上安装的唯一版本,可以通过运行以下命令来查看:

update-alternatives --display java

Which gives the following message: 给出以下消息:

java - auto mode
link currently points to /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java - priority 1071
slave java.1.gz: /usr/lib/jvm/java-7-openjdk-amd64/jre/man/man1/java.1.gz
Current 'best' version is '/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java'.

I then go to the following path: 然后,我转到以下路径:

cd /usr/lib/jvm

and the I list out the contents ls 我列出了内容ls

default-java  java-1.7.0-openjdk-amd64  java-7-openjdk-amd64

I then type cd java* and pwd which brings up the following path: 然后,我键入cd java*pwd ,将显示以下路径:

/usr/lib/jvm/java-1.7.0-openjdk-amd64

Ok, so with that information, I then copy that directory into the .bashrc file as follows: 好的,因此,有了这些信息,我就可以将该目录复制到.bashrc文件中,如下所示:

# The java implementation to use.
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64

The hadoop-env.sh file I fill out as follows: 我填写的hadoop-env.sh文件如下:

#Hadoop variables
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64

I then at the terminal type source ~/.bashrc and then restart the terminal in order for it to set to the new Java path. 然后,在终端上键入source ~/.bashrc ,然后重新启动终端,以使其设置为新的Java路径。 When typing Hadoop -version I get the following output: 当输入Hadoop -version时,我得到以下输出:

/usr/bin/hadoop: line 350: /usr/lib/jvm/java-6-sun/bin/java: No such file or directory
/usr/bin/hadoop: line 434: /usr/lib/jvm/java-6-sun/bin/java: No such file or directory

I do not know where to go from here. 我不知道从这里去哪里。

Thank you, 谢谢,

Add JAVA_HOME to point to your openjdk in hadoop-env.sh . hadoop-env.sh添加JAVA_HOME指向您的openjdk Add this line in hadoop-env.sh : hadoop-env.sh添加以下行:

export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64

NOTE: Change JAVA_HOME path in .bashrc too 注意:也在.bashrc中更改JAVA_HOME路径

UPDATE I: 更新一:

Run these commands in terminal. 在终端中运行这些命令。 (This will set java & javac in /bin to use your jdk) (这会将/ bin中的java&javac设置为使用您的jdk)

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/java 1

sudo update-alternatives --config java

sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/javac" 1

sudo update-alternatives --config javac

NOTE: If you dont have java and javac in the specified path, it will be inside /jre folder. 注意:如果在指定的路径中没有javajavac ,它将位于/ jre文件夹中。 Change it respectively. 分别更改。

It seems that you have installed java (I mean JRE/JDK here) 1.6, 1.7 and 1.8 at the same time. 看来您同时安装了Java 1.6、1.7和1.8(在这里我指的是JRE / JDK)。 Which is comlpetelly ok since java installations are usually managed via alternatives subsystem. 完全可以,因为Java安装通常是通过Alternatives子系统进行管理的。

The problem is that (contrary to your expectations) setting JAVA_HOME doesn't select which java is used. 问题是(与您的期望相反)设置JAVA_HOME不会选择使用哪个Java。 This is done via mentioned alternatives subsystem instead. 这是通过提到的替代子系统来完成的。 The JAVA_HOME variable itself is only addtional configuration and doesn't have power to override what is being executed when one asks to start java process. JAVA_HOME变量本身只是附加配置,并且无权覆盖要求启动java进程的执行内容。

Moreover running cd java* isn't really a good idea unless you would like to go into first directory which starts with given string. 此外,除非您要进入以给定字符串开头的第一个目录,否则运行cd java*并不是一个好主意。 Try to run ls java* to see my point. 尝试运行ls java*以了解我的观点。 And again, it's ok to have multiple different versions of java here thanks to alternatives subsystem. 同样,这里还可以有多个不同版本的Java,这要归功于Alternatives子系统。

Another problem is that you are mixing different flavours of java which you probably don't have installed ( java-8-oracle vs java-6-sun vs java-1.6.0-openjdk . 另一个问题是,您混用了可能尚未安装的各种java-8-oracle版本( java-8-oraclejava-6-sunjava-1.6.0-openjdk

To check which java is installed, run: 要检查安装了哪个java,请运行:

alternatives --display java

And then based on the results, swich to one version of java and set JAVA_HOME accordingly. 然后根据结果,切换到Java的一个版本,并相应地设置JAVA_HOME

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM