Intellij从hadoop集群访问文件

问题描述 投票:0回答:1

作为我的intellij环境设置的一部分,我需要连接到远程hadoop集群并访问本地spark代码中的文件。

有没有办法连接到hadoop远程环境而无需创建hadoop本地实例?

连接代码段是理想的答案。

hadoop intellij-idea
1个回答
0
投票

如果您有一个keytab文件来验证群集,这是我完成它的一种方法:

val conf: Configuration: = new Configuration()
conf.set("hadoop.security.authentication", "Kerberos")
UserGroupInformation.setConfiguration(conf)
UserGroupInformation.loginUserFromKeytab("user-name", "path/to/keytab/on/local/machine")
FileSystem.get(conf)

我相信这样做,你可能还需要一些配置xml文档。即core-site.xmlhdfs-site.xmlmapred-site.xml。这些通常在/etc/hadoop/conf/下。

您可以将它们放在程序中的目录下,并在IntelliJ中将其标记为Resources目录。

© www.soinside.com 2019 - 2024. All rights reserved.