WebHDFS与HttpFS的使用

2018-02-03  本文已影响0人  这个该叫什么呢

WebHDFS与HttpFS的使用

WebHDFS

介绍

提供HDFS的RESTful接口,可通过此接口进行HDFS文件操作。

安装

WebHDFS服务内置在HDFS中,不需额外安装、启动。

配置

需要在hdfs-site.xml打开WebHDFS开关,此开关默认打开。

<property>
    <name>dfs.webhdfs.enabled</name>
    <value>true</value>
</property>

使用

连接NameNode的50070端口进行文件操作。

比如:curl "http://ctrl:50070/webhdfs/v1/?op=liststatus&user.name=root" | python -mjson.tool

更多操作

参考文档:官方WebHDFS REST API

HttpFS(Hadoop HDFS over HTTP)

介绍

HttpFS is a server that provides a REST HTTP gateway supporting all HDFS File System operations (read and write). And it is inteoperable with the webhdfs REST HTTP API.

安装

Hadoop自带,不需要额外安装。默认服务未启动,需要手工启动。

配置

<property>  
    <name>hadoop.proxyuser.root.hosts</name>  
    <value>*</value>  
</property>  
<property>  
<name>hadoop.proxyuser.root.groups</name>  
    <value>*</value>  
</property>

启动

sbin/httpfs.sh start
sbin/httpfs.sh stop

启动后,默认监听14000端口:

[root@ctrl sbin]# netstat -antp | grep 14000
tcp        0      0 :::14000   :::*       LISTEN      7415/java
[root@ctrl sbin]#

使用

curl "http://ctrl:14000/webhdfs/v1/?op=liststatus&user.name=root" | python -mjson.tool

更多操作

参考文档

更多操作:
官方WebHDFS REST API
HttpFS官方文档

WebHDFS与HttpFS的关系

WebHDFS vs HttpFs Major difference between WebHDFS and HttpFs: WebHDFS needs access to all nodes of the cluster and when some data is read it is transmitted from that node directly, whereas in HttpFs, a singe node will act similar to a “gateway” and will be a single point of data transfer to the client node. So, HttpFs could be choked during a large file transfer but the good thing is that we are minimizing the footprint required to access HDFS.

上一篇下一篇

猜你喜欢

热点阅读