The Road to Java Big Data--HDFS Detailed Explanation (3)--Basic Commands

HDFS (Distributed File Storage System)--Basic Commands

Table of contents

HDFS (Distributed File Storage System)--Basic Commands

1. Common commands

2. Other commands


1. Common commands

Order

illustrate

hadoop  fs -mkdir /park

In the root directory of hdfs, create a park directory

hadoop  fs  -ls  /

Check which directories are in the root directory of hdfs

hadoop  fs -put  /root/1.txt  /park

Put 1.txt in the root directory of the linux operating system in the park directory of hdfs

hadoop  fs -get  /park/jdk  /home

Download the files in the park directory under the hdfs file system to the home directory of linux

hadoop fs -rm /park/filename

Delete the specified file in the park directory of hdfs

hadoop fs -rmdir /park

Delete the park directory, but there are no files in the prerequisite directory

hadoop fs -rmr /park

Delete the park directory, even if there are files in the directory

hadoop fs -cat /park/a.txt

View the a.txt file in the park directory

hadoop fs -tail /park/a.txt

View the data at the end of the a.txt file in the park directory

haddop jar  xxx.jar

Execute the jar package

hadoop fs -cat /park/result/part-r-00000

View the contents of the /park/result/part-r-00000 file

hadoop  fs  –mv  /park02  /park01  

Rename the park02 directory on HDFS to park01 command.

hadoop  fs -mv /park02/1.txt /park01

Move 1.txt in the park02 directory to the /park01 directory

hadoop fs -touchz /park/2.txt

create an empty file

hadoop fs -getmerge /park  /root/tmp

Merge all the files in the park directory into one file and download it to the tmp directory in the root directory of linux

hadoop dfsadmin -safemode leave

exit hadoop safe mode

hadoop dfsadmin -safemode enter

enter safe mode

hadoop dfsadmin -rollEdits

Manually perform fsimage file and Edis file merge metadata

hadoop dfsadmin -report

View surviving datanode node information

hadoop fsck /park

Report the health status of the /park directory

hadoop fsck /park/1.txt  -files  -blocks -locations  -racks

View 1.txt file block information and rack information

 

hadoop fs -expunge

Manually empty the hdfs recycle bin

2. Other commands

Order

illustrate

hadoop  fs -cp  /park01/1.txt  /park02

Copy 1.txt under /park01 on HDFS to the /park02 directory.
There can be multiple target paths, separated by spaces, for example: hadoop fs -cp /park01/1.txt /park02 /park03……

hadoop fs -du /park/1.txt

View the size of a file on HDFS. You can also view the specified directory, if it is a directory, list all the files and their sizes in the directory, for example: hadoop fs -du /park

hadoop fs -copyFromLocal  /home/1.txt /park01

Upload the local file 1.txt to the /park01 directory

hadoop fs -copyToLocal /park01/1.txt  /home

Copy 1.txt on HDFS to the local file system

hadoop  fs -lsr  /

Recursively view all content in the specified directory

Guess you like

Origin blog.csdn.net/a34651714/article/details/102818989