2017-05-04 50 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」) 已足夠.. –