如何连接到远程HDFS

编程入门 行业动态 更新时间:2024-10-25 04:24:55
本文介绍了如何连接到远程HDFS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在Windows机器上运行eclipse,并且HDFS在Unix机器上运行。

我试图连接到运行在远程机器上的HDFS实例。 。这是我已经尝试过的。

Configuration conf = new Configuration(); conf.set(fs.defaultFS,hdfs:// remoteHostName:portNumber); DFSClient client = null; System.out.println(try); 尝试 { System.out.println(trying); client = new DFSClient(conf); System.out.println(client); catch(IOException e){ e.printStackTrace(); } finally { if(client!= null) try { client.close(); } catch(IOException e){ e.printStackTrace(); } }

我有以下例外:

线程main中的异常java.lang.NoSuchMethodError:org.apache.hadoop.ipc.RPC。 getProxy(Ljava /郎/类; JLjava /净/的InetSocketAddress; Lorg /阿帕奇/ hadoop的/安全/ UserGroupInformation; Lorg /阿帕奇/ hadoop的/ CONF /配置; Ljavax /净/的SocketFactory; ILorg /阿帕奇/ hadoop的/ IO /重试/ RetryPolicy; Z)Lorg /阿帕奇/ hadoop的/ IPC / VersionedProtocol; at org.apache.hadoop.hdfs.DFSClient.createRPCNamenode(DFSClient.java:135) at org.apache.hadoop.hdfs.DFSClient。< init>(DFSClient.java:280) at org.apache.hadoop.hdfs.DFSClient。< init>(DFSClient.java:245) at org.apache.hadoop.hdfs.DFSClient。< init>(DFSClient.java:235 ) at org.apache.hadoop.hdfs.DFSClient。< init>(DFSClient.java:226)

顺便说一下,我从远程机器上的hdfs-site.xml获得了portNumber。

这种方法是否正确?

另外,在Python中执行此操作会更容易吗?

编辑

请注意,我的窗口上解压缩了Hadoop二进制文件,并且相应地设置了HADOOP_HOME环境变量。这可能是导致问题的原因吗?

解决方案

请参阅: Hadoop 2.6.0 Browsing filesystem Java for your specific problem。

除此之外,您可能需要考虑使用REST进行远程交互。 Apache Knox可以为您提供对远程集群的访问,并防止您的代码不必知道集群内部组件,例如host:port,kerberos或不等等。这些事情可能会从您的远程客户端下改变。

i am trying to connect to an HDFS instance running on a remote machine.

I am running eclipse on a windows machine and the HDFS is running on a Unix box. Here is what i have tried

Configuration conf = new Configuration(); conf.set("fs.defaultFS", "hdfs://remoteHostName:portNumber"); DFSClient client = null; System.out.println("try"); try { System.out.println("trying"); client = new DFSClient(conf); System.out.println(client); } catch (IOException e) { e.printStackTrace(); } finally { if(client!=null) try { client.close(); } catch (IOException e) { e.printStackTrace(); } }

but this gives me the following exception

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.ipc.RPC.getProxy(Ljava/lang/Class;JLjava/net/InetSocketAddress;Lorg/apache/hadoop/security/UserGroupInformation;Lorg/apache/hadoop/conf/Configuration;Ljavax/net/SocketFactory;ILorg/apache/hadoop/io/retry/RetryPolicy;Z)Lorg/apache/hadoop/ipc/VersionedProtocol; at org.apache.hadoop.hdfs.DFSClient.createRPCNamenode(DFSClient.java:135) at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:280) at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:245) at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:235) at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:226)

by the way, i got the portNumber from the hdfs-site.xml on the remote machine

Is this approach correct?

Also, would it be easier to do this in Python?

EDIT

Note that i do have the Hadoop binaries unzipped on my windows and i have set the HADOOP_HOME environment variable accordingly. Could this be causing a problem?

解决方案

See: Hadoop 2.6.0 Browsing filesystem Java for your specific problem.

Beyond that, you might want to consider using REST for remote interactions. Apache Knox can provide you with access to the remote cluster and shield your code from having to know cluster internals such as host:port, kerberos or not, etc. These things can change out from under your remote clients.

更多推荐

如何连接到远程HDFS

本文发布于:2023-11-23 21:08:18,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   HDFS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!