2017-05-04 47 views
0

作为我的intellij环境设置的一部分,我需要连接到远程hadoop集群并使用本地spark代码中的文件。有没有办法在不创建hadoop本地实例的情况下连接到hadoop远程环境?一个连接的代码片段是我要寻找Intellij从hadoop集群访问文件

回答

0

如果你有一个密钥表文件验证到集群理想的答案,这是一个办法,我已经做到了:

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.xml,hdfs-site.xmlmapred-site.xml。这些地方通常在/etc/hadoop/conf/之下。

你会把这些放在你的程序目录下,并将其标记为IntelliJ中的资源目录。

+0

感谢它的工作..intellij有权访问所有的XML文件...所以conf.set(“hadoop.security.authentication”,“Kerberos”) 已足够.. –