Using the command line to manage files on HDFS--转载
原文地址:http://zh.hortonworks.com/hadoop-tutorial/using-commandline-manage-files-hdfs/
In this tutorial we will walk through some of the basic HDFS commands you will need to manage files on HDFS. To complete this tutorial you will need a working HDP cluster. The easiest way to have a Hadoop cluster is to download the?Hortonworks Sandbox.
Let’s get started.
Step 1: Let’s create a directory in HDFS, upload a file and list.
Let’s look at the syntax first:
hadoop fs -mkdir:
- It will take path uri’s as argument and creates directory or directories.
hadoop fs -ls:
- Lists the contents of a directory
- For a file returns stats of a file
Let’s use the following commands as follows and execute. You can ssh to the sandbox using Tools like Putty. You could download putty.exe from the internet.
Let’s touch a file locally.
$ touch filename.txtStep 2: Now, let’s check how to find out space utilization in a HDFS dir.
hadoop fs -du:
- Displays sizes of files and directories contained in the given directory or the size of a file if its just a file.
Step 4:
Now let’s see how to upload and download files from and to Hadoop Data File System(HDFS)
Upload: ( we have already tried this earlier)
hadoop fs -put:
- Copy single src file, or multiple src files from local file system to the Hadoop data file system
Download:
hadoop fs -get:
- Copies/Downloads files to the local file system
Step 5: Let’s look at quickly two advanced features.
hadoop fs -getmerge
- Takes a source directory files as input and concatenates files in src into the destination local file.
hadoop distcp:
- Copy file or directories recursively
- It is a tool used for large inter/intra-cluster copying
- It uses MapReduce to effect its distribution copy, error handling and recovery, and reporting
You could use the following steps to perform getmerge and discp.
Let’s upload two files for this exercise first:
Step 6:Getting help
You can use Help command to get list of commands supported by Hadoop Data File System(HDFS)
Example: hadoop fs -helpHope this short tutorial was useful to get the basics of file management.
轉載于:https://www.cnblogs.com/davidwang456/p/5074126.html
總結
以上是生活随笔為你收集整理的Using the command line to manage files on HDFS--转载的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: hadoop命令帮助
- 下一篇: hadoop跑第一个实例过程