Hadoop Webhdfs Setup and usage instructions

Source: Internet
Author: User
Tags curl

1. Configuration

Namenode Hdfs-site.xml is the Dfs.webhdfs.enabled property must be set to true, otherwise you will not be able to use Webhdfs liststatus, listfilestatus, etc. need to list files, The folder Status command, because this information is saved by Namenode.

Add attributes to/etc/hadoop/conf/hdfs-site.xml in Namenode and one datanode:

Double-click code Select All
1 2 3 4 < property > < name >dfs.webhdfs.enabled</name > < value >true</value > </property >


2. Instructions for use

Access Namenode HDFs using port 50070, Access Datanode Webhdfs using 50075 ports. Access files, folder information using Namenode IP and 50070 ports, access to file content or open, upload, modify, download and other operations using Datanode IP and 50075 ports. To do all of the WEBHDFS operations using Namenode's IP and port without differentiating the ports, you need to set dfs.webhdfs.enabled in Hefs-site.xml to true on all datanode.


3.curl Operation Webhdfs

Create and write a file
Curl-i-X PUT "Http://localhost:50070/webhdfs/v1/<PATH>?op=CREATE
[&overwrite=<true|false>] [&blocksize=<long>] [&replication=<short>]
[&permission=<octal>] [&buffersize=<int>] "
Curl-i-X put-t <LOCAL_FILE> "HTTP://<DATANODE>:<PORT>/WEBHDFS/V1/<PATH>?
Op=create ... "
Note that this place is filled with datanode information.


Append content within a file
Curl-i-X POST "HTTP://<HOST>:<PORT>/WEBHDFS/V1/<PATH>?OP=APPEND[&BUFFERSIZE=<INT>]"
Curl-i-X post-t <LOCAL_FILE> "HTTP://<DATANODE>:<PORT>/WEBHDFS/V1/<PATH>?
Op=append ... "
Note that the command obtains the Datanode information.


Open and read a file
Curl-i-L "Http://<HOST>:<PORT>/webhdfs/v1/<PATH>?op=OPEN
[&offset=<long>] [&length=<long>] [&buffersize=<int>] "


Create a Directory
Curl-i-X PUT "HTTP://<HOST>:<PORT>/<PATH>?OP=MKDIRS[&PERMISSION=<OCTAL>]"


Rename files, folders
Curl-i-X PUT "<HOST>:<PORT>/webhdfs/v1/<PATH>?op=RENAME&destination=<PATH>"


Delete files/folders
Curl-i-X DELETE "Http://


status information for files/folders
Curl-i "Http://<HOST>:<PORT>/webhdfs/v1/<PATH>?op=GETFILESTATUS"


Directory list
Curl-i "Http://<HOST>:<PORT>/webhdfs/v1/<PATH>?op=LISTSTATUS"


Get context rollup information for a directory
Curl-i "Http://<HOST>:<PORT>/webhdfs/v1/<PATH>?op=GETCONTENTSUMMARY"


Get the check Sum File
Curl-i "Http://<HOST>:<PORT>/webhdfs/v1/<PATH>?op=GETFILECHECKSUM"


Get home Directory
Curl-i "Http://<HOST>:<PORT>/webhdfs/v1/?op=GETHOMEDIRECTORY"


Set permissions
Curl-i-X PUT "Http://<HOST>:<PORT>/webhdfs/v1/<PATH>?op=SETPERMISSION [&permission=< Octal>] "


Set owner
Curl-i-X PUT "Http://<HOST>:<PORT>/webhdfs/v1/<PATH>?op=SETOWNER [&owner=<user>][ &group=<group>] "


Set up Backup
Curl-i-X PUT "Http://<HOST>:<PORT>/webhdfs/v1/<PATH>?op=SETREPLICATION [&replication=< Short>] "

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.