简体   繁体   English

Hadoop HDFS,Java客户端无法连接到HDFS

[英]Hadoop hdfs, java client cannot connect to hdfs

I am trying to connect my java client to my hadoop HDFS, but i am stuck when i try to get the fs from my configuration 我试图将我的Java客户端连接到我的hadoop HDFS,但是当我尝试从配置中获取fs时我被卡住了

Configuration conf = new Configuration();
conf.set("fs.default.name", _PATH_);
conf.set("fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem");
FileSystem f = FileSystem.get( conf );

Then I get this exp.. 然后我得到这个经验。

java.lang.RuntimeException: class org.apache.hadoop.security.JniBasedUnixGroupsMappingWithFallback not org.apache.hadoop.security.GroupMappingServiceProvider

I googled it but noting handfull come. 我用谷歌搜索,但注意到一臂之力。 Any advices? 有什么建议吗?

PS: I use the package hadoop-common, hadoop-hdfs from 2.0.0-cdh4.2.0 PS:我使用的包hadoop-common,来自2.0.0-cdh4.2.0的hadoop-hdfs

Thanks Anthony. 谢谢安东尼。

Try below Code: 请尝试以下代码:

Path coreSitePath = new Path("/path/of/HADOOP_HOME", "conf/core-site.xml");
conf.addResource(coreSitePath);
FileSystem fs = FileSystem.get(conf)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM