instruction manual 03:hadoop basic operations
Part 1: View basic information for a Hadoop cluster
1. Querying Storage System Information
(1) Enter http://master:50070/in the address bar of the Web browser
See your Hadoop cluster fill out the following table
|
Configured capacity: The total amount of file system storage already configured |
|
|
DFS Remaining: Total amount of DFS storage that can be used |
|
|
Non the total amount of storage consumed by DFS used applications that are not DFS |
|
|
DFS used: Total amount of DFS storage used |
|
|
Live Nodes: Online data node: |
|
(2) Displaying data node information
Commands for querying HDFs information
Hdfs Dfsadmin–report [-live] [-dead] [decommissioning]
Report: Output file system basic information and related data statistics.
-report-live: The basic information of the online node in the output file system and the related data statistics.
-report-dead: The basic information of the failed node in the output file system and the related data statistics.
-report-decommissioning: The basic information of the inactive node in the output file system and the related data statistics. Example: HDFs dfsadmin–report–live View the basic information of the online node, please fill out the form below.
|
Node name (nodes) |
Total storage space (capacity) |
Use (DFS used) |
DFS not used (Non DFS used) |
DFS remaining (Remaining) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(3) Query the computing resource information of the cluster
enter "Http://master:8088/cluster/nodes" in the address bar of the browser
Continue to click the hyperlink "slave1:8042" on the page to display the resource information for the computer slave1.
Part 2: Uploading files to the HDFs directory
Scenario Description:
upload the original data file stored in this computer email_log.txt to the HDFs directory in the Hadoop cluster/user/root/
1. Basic operation of HDFs
The Monitoring service port (http://master:50070) for HDFs can be accessed remotely on the local computer's Web browser. When you need to access directories and files on HDFs, it is recommended to use the http://master:50070/nn_browsedfscontent.jspEnter the HDFs DFS command at the terminal of the cluster server to complete most of the administrative operations on the HDFs directory and files.
(1) Create a new directory
HDFs Dfs-mkdir [-p] <path>-P: No more than step-by-step creation of directories, plus the ability to create directories in multiple levels
Example:
[[email protected]] #hdfs dfs–mkdir–p/user/dfstest
[[email protected]] #hdfs dfs–mkdir–p/user/test/example
(2) Uploading Files
Command Explanation
HDFs DFS [-copyfromlocal [-f] [-P] [-l] <localsrc> ... <dst>] Copy files from the local file system to the HDFs file system, main parameters <localsrc >,<dst> The local file path to the target path of the copy.
HDFs dfs [-movefromlocal <localsrc> ... <dst>] Move files from the local file system to the HDFs file system, main parameters <localsrc> local file path, <dst> the target path for the move.
HDFs DFS [-put [-f] [-P] [-l] <localsrc> ... <dst>]
uploading files from the local file system to the HDFs file system, the main parameters <localsrc>,<dst> The local file path to the uploaded target path.
Example:
upload the local file a.txt on the cluster server node to the HDFs directory/user/dfstest. (A.txt please create your own)
[[email protected] hadoop-2.6.4] #hdfs dfs–copyfromlocal a.txt/user/dfstest
[[email protected] hadoop-2.6.4] #hdfs dfs–movefromlocal a.txt/user/dfstest/b.txt
[[email protected] hadoop-2.6.4] #hdfs dfs–put a.txt/user/dfstest/c.txt(3) Download file
Command Explanation
HDFs DFS [-copytolocal [-P] [-IGNORECRC] [-CRC] <src> ... <localdst>] Copy files from the HDFs file system to the local file system, main parameters <src >,<localdst> for the HDFs file system path to the local file system path.
HDFs DFS [-get [-P] [-IGNORECRC] [-CRC] <src>...<localdst>] Gets the file of the specified path on the HDFs file system to the local file system, main parameters <src> ,<localdst> the HDFs file system path to the local file system path.
Example:
download A.txt and c.txt from/user/dfstest, stored in the local directory/data/hdfs_test/on the Cluster server node master. (Please create your own hdfs_test directory)
[[email protected] hdfs_test] #hdfs dfs–copytolocal/user/dfstest/a.txt
[[email protected] hdfs_test] #hdfs dfs get/user/dfstest/c.txt
[[email protected] hdfs_test] # ls(3) Viewing the contents of a file
Command Explanation
HDFs dfs [-cat [-IGNORECRC] <src> ...] view HDFs file contents, main parameters <src> indicates file path.
HDFs DFS [-tail [-F] <file>] outputs the last 1024 bytes of the HDFs file, main parameters <file> specified file.
Example:
[[email protected] hdfs_test] #hdfs dfs–cat/user/dfstest/a.txt
[[email protected] hdfs_test] #hdfs dfs–tail/user/dfstest/c.txt(4) deleting files or directories
Command Explanation
HDFs DFS [-RM [-F] [-r|-r] [-skiptrash] <src> ...] delete files on HDFs, main parameter-R for recursive deletion,<src> specifies the path of the deleted file.
HDFs dfs [-rmdir [--ignore-fail-on-non-empty] <dir> ...] If you are deleting a directory, you can use this method, main parameters <dir> specify the directory path.
Example:
[[email protected] hdfs_test] #hdfs dfs–mkdir/user/dfstest/rmdir
[[email protected] hdfs_test] #hdfs dfs–rm/user/dfstest/c.txt
[[email protected] hdfs_test] #hdfs dfs–rmdir/user/dfstest/rmdir2. Uploading Files to HDFs
(1) Transfer the data file from the hard disk of the local computer email_log.txt to the local directory/root/hadoop of the cluster Server (master).
you can upload using tools such as SSH secure.
(2) perform HDFS command on the terminal of the Cluster Server (master), upload email_log.txt to the HDFs directory/user/root/
Hdfs dfs-put/root/hadoop/email_log.txt/user/root/
Instruction manual 03:hadoop Basic operations