在 Windows 上安装 Hadoop

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26990243/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:49:34  来源:igfitidea点击:

Hadoop installation on windows

windowshadoop

提问by user3471380

After extracting hadoop in my C drive I tried to execute the hadoop version command and getting below error. JAVA_HOMEis set correctly in my environment variable. Can anybody help on that error ?

在我的 C 驱动器中提取 hadoop 后,我尝试执行 hadoop version 命令并出现以下错误。JAVA_HOME在我的环境变量中正确设置。有人可以帮助解决这个错误吗?

C:\>hadoop version 

The system cannot find the path specified.
Error: JAVA_HOME is incorrectly set.
Please update C:\hadoop-2.5.1\conf\hadoop-env.cmd '-Xmx512m' is not recognized as an internal or external command, ooperable program or batch file.

回答by dmachop

Most of the answers suggest to copy the JDK installation path. However, if you are not comfortable doing it, you can use the Windows short pathto set the path name so that all applications can access the path without any hassles.

大多数答案都建议复制JDK安装路径。但是,如果您不习惯这样做,您可以使用Windows 短路径来设置路径名,以便所有应用程序都可以轻松访问该路径。

Notion to set env variable if it contains white spaces:

如果包含空格,则设置 env 变量的概念:

Progra~1 = 'Program Files'
Progra~2 = 'Program Files(x86)'

回答by Mariusz

Just faced the same issue (Win 8.1 + Hadoop 2.7.0 [build from sources]).

刚刚面临同样的问题(Win 8.1 + Hadoop 2.7.0 [从源代码构建])。

The problem turned out to be (ol' good) space in path name where java is located (under C:\Program Files\ dir). What i did was this:

问题原来是 java 所在的路径名中的(很好)空格(在 C:\Program Files\ dir 下)。我所做的是这样的:

1) Copy JDK dir to C:\Java\jdk1.8.0_40

1) 将JDK目录复制到C:\Java\jdk1.8.0_40

2) edit \etc\hadoop\hadoop-env.cmd and change: set JAVA_HOME=c:\Java\jdk1.8.0_40

2) 编辑 \etc\hadoop\hadoop-env.cmd 并更改:set JAVA_HOME=c:\Java\jdk1.8.0_40

3) run cmd and execute hadoop-env.cmd

3)运行cmd并执行hadoop-env.cmd

4) now check 'hadoop version' whether it's still complaining (my wasn't)

4)现在检查'hadoop version'是否仍在抱怨(我没有)

回答by adin

Install the JDK to a folder with no spaces. Instead of C:\Program Files\Java\jdk1.8.x_xx, try C:\java\jdk1.8.x_xx.

将 JDK 安装到一个没有空格的文件夹中。而不是C:\Program Files\Java\jdk1.8.x_xx,尝试C:\java\jdk1.8.x_xx

回答by Neethu

The reason for you error is the space between the "Program Files". Replace it with PROGRA~1 in all the paths while configuring

您出错的原因是“程序文件”之间的空格。配置时将所有路径中的PROGRA~1替换

回答by Mushu909

To get around having to install another JDK in a path that does not have a space, you can create a symbolic link with the Windows command mklink. Here's how.

要避免在没有空格的路径中安装另一个 JDK,您可以使用 Windows 命令 mklink 创建符号链接。就是这样。

  1. Open a cmd prompt as administrator.
  2. Navigate to C:\ if the cmd prompt does not open there.
  3. Create the symolic link. Here, I'm setting the path that Hadoop complains about (with Program Files) to a simpler path without spaces. The /D argument means you are creating a directory symbolic link.

    mklink /D \java_home "C:\Program Files\Java\jdk1.7.0_65"

  4. In your hadoop-env.cmd, set your JAVA_HOME to the symbolic link you created:

    set JAVA_HOME=\java_home

  1. 以管理员身份打开 cmd 提示符。
  2. 如果 cmd 提示没有在那里打开,请导航到 C:\。
  3. 创建符号链接。在这里,我将 Hadoop 抱怨的路径(使用程序文件)设置为更简单的没有空格的路径。/D 参数表示您正在创建目录符号链接。

    mklink /D \java_home "C:\Program Files\Java\jdk1.7.0_65"

  4. 在您的 hadoop-env.cmd 中,将您的 JAVA_HOME 设置为您创建的符号链接:

    设置 JAVA_HOME=\java_home

This is what worked for me. More information on creating symbolic link in Windows: http://www.windows7home.net/how-to-create-symbolic-link-in-windows-7/

这对我有用。有关在 Windows 中创建符号链接的更多信息:http: //www.windows7home.net/how-to-create-symbolic-link-in-windows-7/

回答by BaBa Somanath

Check your JAVA_HOME.

检查您的JAVA_HOME.

If it is C:\Program Files\Java\jdk1.7.0_65. Then you will encounter such issues. Made it to C:\MyDrive\Java\jdk1.7.0_65 and it worked out. The space in "Program Files" creates issues.

如果是 C:\Program Files\Java\jdk1.7.0_65。那么你就会遇到这样的问题。将其发送到 C:\MyDrive\Java\jdk1.7.0_65 并且成功了。“程序文件”中的空间会产生问题。

PATH is PATH;%JAVA_HOME%\bin

路径是 PATH;%JAVA_HOME%\bin

If you are using windows, then surely You are going to face issues like (due to X64 and X86 issues) :

如果您使用的是 Windows,那么您肯定会遇到以下问题(由于 X64 和 X86 问题):

1 .

1 .

FATAL datanode.DataNode: Exception in secureMain java.lang.NullPointerException and

致命的 datanode.DataNode:secureMain java.lang.NullPointerException 中的异常和

2.

2.

FATAL namenode.NameNode: Failed to start namenode. java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)

致命的 namenode.NameNode:无法启动 namenode。java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)

Solution :

解决方案 :

Copy these files hadoop.dll, hadoop.exp, hadoop.lib, hadoop.pdb, libwinutils.lib, winutils.exe, winutils.pdb from the linkto your bin folder of hadoop installed loaction which looks like this. ..\HadoopInstalled\hadoop\hadoop-2.6.0\hadoop-2.6.0\bin

将这些文件 hadoop.dll、hadoop.exp、hadoop.lib、hadoop.pdb、libwinutils.lib、winutils.exe、winutils.pdb 从链接复制到您的已安装 hadoop 的 loaction 的 bin 文件夹,如下所示。..\HadoopInstalled\hadoop\hadoop-2.6.0\hadoop-2.6.0\bin

回答by Rengasamy

Add your java bin location to your pathenvironment variable. like

将您的 java bin 位置添加到您的path环境变量中。喜欢

path = path;$JAVA_HOME/bin

回答by Shoaib

The solution to this problem is simple

这个问题的解决方法很简单

Most of the folks will be setting the JAVA_HOME as C:\Program Files\Java\jdk1.8.0_121

大多数人会将 JAVA_HOME 设置为 C:\Program Files\Java\jdk1.8.0_121

There problem here is with the spaces and what you need to do is , copy the contentd of jdk1.8.0_121 to a folder in C Drive , say C:\java

这里的问题是空格,您需要做的是,将 jdk1.8.0_121 的内容复制到 C 驱动器中的文件夹中,例如 C:\java

Now use this path as your JAVA_HOME

现在将此路径用作您的 JAVA_HOME

回答by Jabir

Please add following line in hadoop-env.cmd. This should be first line in hadoop-env.cmdafter comments.

请在hadoop-env.cmd. 这应该是hadoop-env.cmd评论后的第一行。

set JAVA_HOME=C:\Progra~1\Java\jdk1.8.0_131\

This shortened Progra~1 name is SFN

这个缩短的 Progra~1 名称是SFN

This sans need for copying java to some other directory as purposed in some other answers and you can have java version which is specific for hadoop.

这不需要将java复制到其他一些答案中的其他目录,并且您可以拥有特定于hadoop的java版本。

回答by Raxit Solanki

I have also faced similar issue, following steps solved error for me.

我也遇到过类似的问题,以下步骤为我解决了错误。

Download& Install Java in c:/java/

下载并安装 Javac:/java/

(make sure the path is this way, if java is installed in program files, then hadoop-env.cmd will not recognize java path )

(确保路径是这样的,如果程序文件中安装了java,那么hadoop-env.cmd将无法识别java路径)

DownloadHadoop binary distribution.

下载Hadoop 二进制分发版。

Set Environment Variables:

设置环境变量:

JAVA_HOME = "c:/Java"
HADOOP_HOME="<your hadoop home>"
Path= "JAVA_HOME/bin"
Path = "HADOOP_HOME/bin" 

Here is a GitHub link, which has winutils of some versions of Hadoop.

这是一个GitHub 链接,其中包含一些 Hadoop 版本的 winutils。

(if the version you are using is not in the list, the follow the conventional method for setting up Hadoop on windows - link)

(如果您使用的版本不在列表中,请按照在 windows 上设置 Hadoop 的常规方法 -链接

If you found your version, then copy paste all content of folder into path: /bin/

如果您找到您的版本,则将文件夹的所有内容复制粘贴到路径:/bin/

Set all the .xml configuration files - Link

设置所有 .xml 配置文件 -链接

And Finally set JAVA_HOME path in hadoop-env.cmd file

最后在 hadoop-env.cmd 文件中设置 JAVA_HOME 路径

Probably it will solve 'JAVA_HOME is incorrectly set.'error

可能它会解决'JAVA_HOME is incorrectly set.'错误

Hope this helps.

希望这可以帮助。