Hadoop hdfs常用命令

2021-10-03 10:34:50 字數 4388 閱讀 7293

model@host2 ~]$ hadoop dfs -ls

deprecated: use of this script to execute hdfs command is deprecated.

instead use the hdfs command for it.

found 3 items

drwx------ - model supergroup 0 2020-01-20 23:00 .trash

drwxr-xr-x - model supergroup 0 2020-01-19 17:06 .sparkstaging

drwx------ - model supergroup 0 2020-01-21 15:34 .staging

[model@host2 ~]$ hadoop fs -ls

found 3 items

drwx------ - model supergroup 0 2020-01-20 23:00 .trash

drwxr-xr-x - model supergroup 0 2020-01-19 17:06 .sparkstaging

drwx------ - model supergroup 0 2020-01-21 15:34 .staging

$ hadoop version

hadoop 2.6.0-cdh5.15.0

subversion -r e3cb23a1cb2b89d074171b44e71f207c3d6ffa50

compiled by jenkins on 2018-05-24t11:19z

compiled with protoc 2.5.0

from source with checksum 2efeda2e2d6b27ecf59ab56fffd9881

this command was run using /opt/cloudera/parcels/cdh-5.15.0-1.cdh5.15.0.p0.21/jars/hadoop-common-2.6.0-cdh5.15.0.jar

hadoop fs -mkdir /建立hdfs目錄

hadoop fs -ls /列出hdfs目錄

hadoop fs -copyfromlocal /複製本地(local)檔案到hdfs

hadoop fs -put /複製本地(local)檔案到hdfs

hadoop fs -cat /列出hdfs目錄下的檔案內容

hadoop fs -copytolocal /將hdfs上的檔案複製到本地(local)

hadoop fs -get /將hdfs上的檔案複製到本地(local)

hadoop fs -cp /複製hdfs檔案

hadoop fs -rm /複製hdfs檔案

hadoop  fs -ls /user/hive/warehouse/edw_ai.db/mod
hadoop  fs -rm -r  /user/hive/warehouse/edw_ai.db/mod
**

說明** http://master:50070

hadoop hdfs web介面**

hadoop fs -mkdir

$ hadoop fs -mkdir test //不指定路徑 則預設 在 /user/賬號名

$ hadoop fs -ls /user/model

found 4 items

drwx------ - model supergroup 0 2020-01-21 16:22 /user/model/.trash

drwxr-xr-x - model supergroup 0 2020-01-19 17:06 /user/model/.sparkstaging

drwx------ - model supergroup 0 2020-01-21 15:34 /user/model/.staging

drwxr-xr-x - model supergroup 0 2020-01-21 16:26 /user/model/test

$ hadoop fs -ls /

found 2 items

drwxrwxrwt - hdfs supergroup 0 2019-12-26 16:41 /tmp

drwxrwxrwx - hdfs supergroup 0 2020-01-17 15:26 /user

$ hadoop fs -mkdir -p /user/model/test1/test11

$ hadoop fs -ls -r /user/model

drwx------ - model supergroup 0 2020-01-21 16:22 /user/model/.trash

drwx------ - model supergroup 0 2020-01-21 16:22 /user/model/.trash/current

drwx------ - model supergroup 0 2020-01-21 16:22 /user/model/.trash/current/user

drwx------ - model supergroup 0 2020-01-21 16:22 /user/model/.trash/current/user/model

drwxr-xr-x - model supergroup 0 2020-01-21 16:19 /user/model/.trash/current/user/model/test2020

drwxr-xr-x - model supergroup 0 2020-01-19 17:06 /user/model/.sparkstaging

drwx------ - model supergroup 0 2020-01-21 15:34 /user/model/.staging

drwxr-xr-x - model supergroup 0 2020-01-21 16:26 /user/model/test

drwxr-xr-x - model supergroup 0 2020-01-21 16:42 /user/model/test1

drwxr-xr-x - model supergroup 0 2020-01-21 16:42 /user/model/test1/test11

hadoop fs -copyfromlocal

hadoop fs -copyfromlocal /user/model/test1/test11 /user/mode/test

hadoop fs -copyfromlocal /user/model/test1/test11 /user/mode/test

hadoop fs -put
hadoop fs -cat

hadoop fs -cat /user/model/test/echo.txt

hadoop fs -copytolocal

[model@host2 ~]$ mkdir test

[model@host2 ~]$ cd test/

[model@host2 test]$ ls

[model@host2 test]$ ll

hadoop fs -get

[model@host2 test]$ ll

total 8

hadoop fs -cp
hadoop fs -rm

/刪除目錄

hadoop fs -rm -r /user/model/test

hadoop hdfs常用命令

1.hadoop fs 檢視hadoop hdfs支援的所有命令 2.hadoop fs ls 列出目錄及檔案資訊 3.hadoop fs lsr 迴圈列出目錄 子目錄及檔案資訊 4.hadoop fs put test.txt user sunlightcs 將本地檔案系統的test.txt複製到...

hadoop hdfs 常用命令

size large hadoop常用命令 hadoop fs 檢視hadoop hdfs支援的所有命令 hadoop fs ls 列出目錄及檔案資訊 hadoop fs lsr 迴圈列出目錄 子目錄及檔案資訊 hadoop fs put test.txt user sunlightcs 將本地檔案...

hadoop HDFS常用命令

hdfs提供 shell 命令列客戶端,使用方法如下 cat ignorecrc checksum chgrp r group path.chmod r path.chown r owner group path.copyfromlocal f p copytolocal p ignorecrc c...