Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Several common commands of hadoop

Shulou Source: shulou.com Published: 2022-06-03 02:28:39 10月17日 Update

Official document: http://hadoop.apache.org/docs/r1.2.1/file_system_shell.html

1. Log in to the primary node and switch to the hdfs user

[hdfs@cdhm1~] # su-hdfs

2. List the subdirectories and files of the current directory

[hdfs@cdhm1] $hadoop fs-ls / Found 2 itemsdrwxrwxrwt-hdfs supergroup 02017-05-23 16:39 / tmpdrwxr-xr-x-hdfs supergroup 02017-05-24 15:45 / user

3. In the Hadoop file system, create a test directory

[hdfs@cdhm1 ~] $hadoop fs-mkdir / user/hdfs/test

Check that there is a test directory under the directory, and it is created successfully.

[hdfs@cdhm1] $hadoop fs-ls / user/hdfs/Found 4 itemsdrwx--hdfs supergroup0 2017-05-26 08:00 / user/hdfs/.Trashdrwxr-xr-x-hdfs supergroup0 2017-06-05 15 15 paste 19Greater hdfsax. SparkStagingdrwx-- hdfs supergroup0 2017-05-24 15:46/user/hdfs/.stagingdrwxr-xr-x-hdfs supergroup0 2017-07-03 10:19 / user/hdfs/test

4. Delete the test directory

[hdfs@cdhm1 ~] $hadoop fs-rmr / user/hdfs/test17/07/03 10:46:06INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 1440 minutes, Emptier interval = 0 minutes.Moved:'hdfs://cdhm1:8020/user/hdfs/test' to trash at:hdfs://cdhm1:8020/user/hdfs/.Trash/Current

Check again that the test directory is gone.

[hdfs@cdhm1] $hadoop fs-ls / user/hdfs/Found 3 itemsdrwx--hdfs supergroup 0 2017-07-03 10:46 / user/hdfs/.Trashdrwxr-xr-x-hdfs supergroup 0 2017-06-05 1515 19UserUserUserCharger hdfsscar.sparkStagingdrwx-- hdfs supergroup 0 2017-05-24 15:46/user/hdfs/.staging

5. Download the files in the Hadoop file system to the local

[hdfs@cdhm1 ~] $hadoop fs-get / user/hdfs/test2

Check the local test2 download successfully

[hdfs@cdhm1 ~] $lstest2 test.txt

Upload local files to the Hadoop file system

[hdfs@cdhm1 ~] $hadoop fs-put test.txt / user/hdfs/

Check that test.txt has been uploaded successfully in hadoop

[hdfs@cdhm1] $hadoop fs-ls / user/hdfs/Found 5 itemsdrwx--hdfs supergroup 0 2017-07-03 10:46 / user/hdfs/.Trashdrwxr-xr-x-hdfs supergroup 0 2017-06-05 1515 hdfs 19user hdfs hdfs.sparkStagingdrwx-- hdfs supergroup 0 2017-05-24 15lace 46hand username hdfshand. Supergroup 0 2017-07-03 11:13 / user/hdfs/test.txtdrwxr-xr-x-hdfs supergroup 0 2017-07-03 11:04 / user/hdfs/test2

Tags: File directory success system under again subdirectory official file download document user node switch login command commonly used Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker NVidia Microsoft Apple MariaDB