hadoop运行报错Wrong FS: hdfs:/, expected: file:///
内容源自:https://blog.csdn.net/u014470581/article/details/51480600
报错信息:
Exception in thread "main" java.lang.reflect.InvocationTargetException 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:601) at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58) Caused by: java.lang.IllegalArgumentException: Wrong FS: hdfs:/, expected: file:/// at org.apache.hadoop.fs.FileSystem.checkPath(FileSystem.java:642) at org.apache.hadoop.fs.RawLocalFileSystem.pathToFile(RawLocalFileSystem.java:69) at org.apache.hadoop.fs.RawLocalFileSystem.mkdirs(RawLocalFileSystem.java:419) at org.apache.hadoop.fs.ChecksumFileSystem.mkdirs(ChecksumFileSystem.java:584) at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:437) at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:424) at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:905) at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:886) at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:783) at com.ailk.hadoopdemo.DFSOperator.main(DFSOperator.java:22) ... 5 more
解决方法一:
mapreduce class添加:把core-site.xml的路径添加进去:
conf.addResource(new Path("/home/hadoop/conf/core-site.xml"));
解决方法二:
把hadoop集群上的core-site.xml和hdfs-site.xml放到工程的src目录下/resource下