栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

No FileSystem for scheme:hdfs and Class org.apache.hadoop.DistributedFileSystem not found

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

No FileSystem for scheme:hdfs and Class org.apache.hadoop.DistributedFileSystem not found

在获取 Hadoop 文件系统对象时,如下所示

FileSystem fs = FileSystem.get(hdfsUrl,configuration);

错误一

如果收到以下错误:

"No FileSystem for scheme:hdfs"

可以通过在配置中设置以下 2 个属性来解决它

configuration.set("fs.hdfs.impl","org.apache.hadoop.hdfs.DistributedFileSystem");
configuration.set("fs.file.impl", "org.apache.hadoop.fs.LocalFileSystem");
错误二

现在,您可能会收到如下新错误:

java.lang.ClassNotFoundException: Class org.apache.hadoop.hdfs.DistributedFileSystem not found

解决方案一

Hadoop-common.jar 使用 Thread.currentThread.getContextClassLoader() 和 configuration.getClassLoader 来加载类。因此,如果您使用

Thread.currentThread.setContextClassLoader(yourClassLoader); 
configuration.setClassLoader(yourClassLoader);

就能够从其他 hadoop jar 加载所需的类(例如 hadoop-hdfs)

解决方案二

校验下,是否是jar包的问题:

双击 shift,输入  DistributedFileSystem。如下图,则说明包没问题

如果下拉框中是  空白 

 

说明需要加对应的jar包了:

        
			org.apache.hadoop
			hadoop-hdfs
			2.6.0
		

 如果还报错,说明 集群使用的默认库里的相关的依赖包 与 hadoop-hdfs中依赖的包  存在有冲突!需要把包的版本保持一致(确保远程不会有maven依赖的conflicts)。注意这个坑!

比如我司默认的是 2.6.0-cdhmdzz5.12.1版本

如果您需要更多帮助,请告诉我。如果你觉得这有点用,别忘了点赞。

部分参考

java - No FileSystem for scheme:hdfs and Class org.apache.hadoop.DistributedFileSystem not found - Stack Overflow

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/826855.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号