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

vmjh9lq9  于 2021-06-02  发布在  Hadoop
关注(0)|答案(1)|浏览(365)

在我的系统变量中, 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.exeC:\hadoop-2.7.2\bin\winutils.exe 因为前一个不是有效的目录?

1bqhqjot

1bqhqjot1#

更新 Path variable 如下面的截图和地点 winutils.exehadoop-2.x/bin/

相关问题