1. 程式人生 > >Eclipse操作HDFS時常見錯誤

Eclipse操作HDFS時常見錯誤

在Windows環境下,Eclipse操作hdfs時,出現

 ERROR Shell: Failed to locate the winutils binary in the hadoop binary path java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries. at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:356) at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:
371) at org.apache.hadoop.util.Shell.<clinit>(Shell.java:364) at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:80) at org.apache.hadoop.security.SecurityUtil.getAuthenticationMethod(SecurityUtil.java:611) at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:
272) at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:260) at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:790) at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:760) at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:
633) at org.apache.spark.util.Utils$$anonfun$getCurrentUserName$1.apply(Utils.scala:2001) at org.apache.spark.util.Utils$$anonfun$getCurrentUserName$1.apply(Utils.scala:2001) at scala.Option.getOrElse(Option.scala:120) at org.apache.spark.util.Utils$.getCurrentUserName(Utils.scala:2001) at org.apache.spark.SecurityManager.<init>(SecurityManager.scala:207) at org.apache.spark.SparkEnv$.create(SparkEnv.scala:218) at org.apache.spark.SparkEnv$.createDriverEnv(SparkEnv.scala:163) at org.apache.spark.SparkContext.createSparkEnv(SparkContext.scala:269) at org.apache.spark.SparkContext.<init>(SparkContext.scala:272) at org.apache.spark.SparkContext.<init>(SparkContext.scala:154) at SparkFromHbase$.main(SparkFromHbase.scala:15) at SparkFromHbase.main(SparkFromHbase.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) 解決方法:先檢視你的hadoop解壓路徑下hadoop/bin有沒有檔案winutils.exe,如果存在,在程式里加上System.setProperty("hadoop.home.dir",hadoop解壓路徑);

如果不存在檔案winutils.exe,則需要下載該檔案,然後放入hadoop解壓後的bin下

下載路徑:http://download.csdn.net/detail/luoyepiaoxin/8860033