gpt4 book ai didi

java - 如何设置 winutils.exe 的确切路径以使用 Java 访问 HDFS?

转载 作者:可可西里 更新时间:2023-11-01 15:56:56 27 4
gpt4 key购买 nike

在我的系统变量中,HADOOP_HOME 设置为 C:\hadoop-2.7.2\bin

我尝试使用以下代码访问 HDFS:

FileSystem hdfs = FileSystem.get(new Configuration());
Path homeDir = hdfs.getHomeDirectory();

运行时错误:

17/03/13 10:49:39 ERROR util.Shell: Failed to locate the winutils binary in the hadoop binary path
java.io.IOException: Could not locate executable C:\hadoop-2.7.2\bin\bin\winutils.exe in the Hadoop binaries.
at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:379)
at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:394)
at org.apache.hadoop.util.Shell.<clinit>(Shell.java:387)
at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:80)
at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2823)
at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:2818)
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2684)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:373)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:172)

如何将我的代码访问的路径 C:\hadoop-2.7.2\bin\bin\winutils.exe 更改为 C:\hadoop-2.7.2\bin\winutils.exe 因为前一个不是有效目录?

最佳答案

更新 Path 变量,如下图所示,并将 winutils.exe 放入 hadoop-2.x/bin/

enter image description here

关于java - 如何设置 winutils.exe 的确切路径以使用 Java 访问 HDFS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42757405/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com