码迷,mamicode.com
首页 > 其他好文 > 详细

Hadoop fs.copyToLocalFile错误

时间:2019-01-11 23:10:46      阅读:377      评论:0      收藏:0      [点我收藏+]

标签:fileutil   miss   get   inner   new   1.2   lan   leo   except   

fs.copyToLocalFile(new Path("/study1/1.txt"), new Path("C:/Users/Administrator/Desktop/d2.txt"));

   报错

 

log4j:WARN No appenders could be found for logger (org.apache.hadoop.util.Shell).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: java.io.FileNotFoundException: HADOOP_HOME and hadoop.home.dir are unset. -see https://wiki.apache.org/hadoop/WindowsProblems
at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:722)
at org.apache.hadoop.util.Shell.getSetPermissionCommand(Shell.java:256)
at org.apache.hadoop.util.Shell.getSetPermissionCommand(Shell.java:273)
at org.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:767)
at org.apache.hadoop.fs.RawLocalFileSystem$LocalFSFileOutputStream.<init>(RawLocalFileSystem.java:235)
at org.apache.hadoop.fs.RawLocalFileSystem$LocalFSFileOutputStream.<init>(RawLocalFileSystem.java:219)
at org.apache.hadoop.fs.RawLocalFileSystem.createOutputStreamWithMode(RawLocalFileSystem.java:314)
at org.apache.hadoop.fs.RawLocalFileSystem.create(RawLocalFileSystem.java:302)
at org.apache.hadoop.fs.RawLocalFileSystem.create(RawLocalFileSystem.java:334)
at org.apache.hadoop.fs.ChecksumFileSystem$ChecksumFSOutputSummer.<init>(ChecksumFileSystem.java:399)
at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:462)
at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:441)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:1067)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:1048)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:937)
at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:391)
at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:364)
at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:314)
at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:2375)
at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:2344)
at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:2320)
at hadoop290.hdfs.HdfsClient.main(HdfsClient.java:27)
Caused by: java.io.FileNotFoundException: java.io.FileNotFoundException: HADOOP_HOME and hadoop.home.dir are unset. -see https://wiki.apache.org/hadoop/WindowsProblems
at org.apache.hadoop.util.Shell.fileNotFoundException(Shell.java:534)
at org.apache.hadoop.util.Shell.getHadoopHomeDir(Shell.java:555)
at org.apache.hadoop.util.Shell.getQualifiedBin(Shell.java:578)
at org.apache.hadoop.util.Shell.<clinit>(Shell.java:675)
at org.apache.hadoop.util.StringUtils.<clinit>(StringUtils.java:78)
at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:3420)
at org.apache.hadoop.fs.FileSystem$Cache$Key.<init>(FileSystem.java:3416)
at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:3258)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:470)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:223)
at hadoop290.hdfs.HdfsClient.main(HdfsClient.java:21)
Caused by: java.io.FileNotFoundException: HADOOP_HOME and hadoop.home.dir are unset.
at org.apache.hadoop.util.Shell.checkHadoopHomeInner(Shell.java:454)
at org.apache.hadoop.util.Shell.checkHadoopHome(Shell.java:425)
at org.apache.hadoop.util.Shell.<clinit>(Shell.java:502)
... 7 more

 

     解决方法

 fs.copyToLocalFile(false,new Path("/study1/1.txt"), new Path("C:/Users/Administrator/Desktop/d2.txt"),true);

   加一个false 和true 就好了!!

 

Hadoop fs.copyToLocalFile错误

标签:fileutil   miss   get   inner   new   1.2   lan   leo   except   

原文地址:https://www.cnblogs.com/tongxupeng/p/10257556.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!