美文网首页
WebHDFS与HttpFS的使用

WebHDFS与HttpFS的使用

作者: 这个该叫什么呢 | 来源:发表于2018-02-03 16:05 被阅读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自带,不需要额外安装。默认服务未启动,需要手工启动。

    配置

    • httpfs-site.xml
      有配置文件httpfs-site.xml,此配置文件一般保存默认即可,无需修改。

    • hdfs-site.xml
      需要增加如下配置,其他两个参数名称中的root代表的是启动hdfs服务的OS用户,应以实际的用户名称代替。

    <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.

    相关文章

      网友评论

          本文标题:WebHDFS与HttpFS的使用

          本文链接:https://www.haomeiwen.com/subject/uomuzxtx.html