日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

HDFS命令行客户端使用,命令行客户端支持的命令参数,常用命令参数介绍

發布時間:2024/9/27 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HDFS命令行客户端使用,命令行客户端支持的命令参数,常用命令参数介绍 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

3.HDFS的shell(命令行客戶端)操作

3.1 HDFS命令行客戶端使用

HDFS提供shell命令行客戶端,使用方法如下:

[toto@hadoop hadoop-2.8.0]$ hdfs dfs -ls /???? (推薦使用這種方式,hdfs現在這種是最新的一種方式)

Found 4 items

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 14:01 /findbugs-1.3.9

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 03:23 /hive

drwx------?? - toto supergroup????????? 0 2017-05-29 14:47 /tmp

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 14:47 /user

[toto@hadoop hadoop-2.8.0]$

?

或者使用:

[toto@hadoop hadoop-2.8.0]$ hadoop fs -ls /

Found 4 items

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 14:01 /findbugs-1.3.9

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 03:23 /hive

drwx------?? - toto supergroup????????? 0 2017-05-29 14:47 /tmp

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 14:47 /user

[toto@hadoop hadoop-2.8.0]$

?

3.2 命令行客戶端支持的命令參數

[toto@hadoop learn]$ hadoop fs help

Usage: hadoop fs [generic options]

?????? [-appendToFile <localsrc> ... <dst>]

?????? [-cat [-ignoreCrc] <src> ...]

?????? [-checksum <src> ...]

?????? [-chgrp [-R] GROUP PATH...]

?????? [-chmod [-R] <MODE[,MODE]... | OCTALMODE> PATH...]

?????? [-chown [-R] [OWNER][:[GROUP]] PATH...]

?????? [-copyFromLocal [-f] [-p] [-l] [-d] <localsrc> ... <dst>]

?????? [-copyToLocal [-f] [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]

?????? [-count [-q] [-h] [-v] [-t [<storage type>]] [-u] [-x] <path> ...]

?????? [-cp [-f] [-p | -p[topax]] [-d] <src> ... <dst>]

?????? [-createSnapshot <snapshotDir> [<snapshotName>]]

?????? [-deleteSnapshot <snapshotDir> <snapshotName>]

?????? [-df [-h] [<path> ...]]

?????? [-du [-s] [-h] [-x] <path> ...]

?????? [-expunge]

?????? [-find <path> ... <expression> ...]

?????? [-get [-f] [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]

?????? [-getfacl [-R] <path>]

?????? [-getfattr [-R] {-n name | -d} [-e en] <path>]

?????? [-getmerge [-nl] [-skip-empty-file] <src> <localdst>]

?????? [-help [cmd ...]]

?????? [-ls [-C] [-d] [-h] [-q] [-R] [-t] [-S] [-r] [-u] [<path> ...]]

?????? [-mkdir [-p] <path> ...]

?????? [-moveFromLocal <localsrc> ... <dst>]

?????? [-moveToLocal <src> <localdst>]

?????? [-mv <src> ... <dst>]

?????? [-put [-f] [-p] [-l] [-d] <localsrc> ... <dst>]

?????? [-renameSnapshot <snapshotDir> <oldName> <newName>]

?????? [-rm [-f] [-r|-R] [-skipTrash] [-safely] <src> ...]

?????? [-rmdir [--ignore-fail-on-non-empty] <dir> ...]

?????? [-setfacl [-R] [{-b|-k} {-m|-x <acl_spec>} <path>]|[--set <acl_spec> <path>]]

?????? [-setfattr {-n name [-v value] | -x name} <path>]

?????? [-setrep [-R] [-w] <rep> <path> ...]

?????? [-stat [format] <path> ...]

?????? [-tail [-f] <file>]

?????? [-test -[defsz] <path>]

?????? [-text [-ignoreCrc] <src> ...]

?????? [-touchz <path> ...]

?????? [-truncate [-w] <length> <path> ...]

?????? [-usage [cmd ...]]

?

?[toto@hadoop learn]$

?

3.2 常用命令參數介紹

關于hdfs的命令,可以查看http://hadoop.apache.org/docs/r1.0.4/cn/hdfs_shell.html

FS Shell

調用文件系統(FS)Shell命令應使用?bin/hadoop fs <args>的形式。 所有的的FS shell命令使用URI路徑作為參數。URI格式是scheme://authority/path。對HDFS文件系統,scheme是hdfs,對本地文件系統,scheme是file。其中scheme和authority參數都是可選的,如果未加指定,就會使用配置中指定的默認scheme。一個HDFS文件或目錄比如/parent/child可以表示成hdfs://namenode:namenodeport/parent/child,或者更簡單的/parent/child(假設你配置文件中的默認值是namenode:namenodeport)。大多數FS Shell命令的行為和對應的Unix Shell命令類似,不同之處會在下面介紹各命令使用詳情時指出。出錯信息會輸出到stderr,其他信息輸出到stdout。

?

?

-help????????????

功能:輸出這個命令參數手冊

-ls?

功能:顯示目錄信息

示例: hadoop fs -ls hdfs://hadoop:9000/

備注:這些參數中,所有的hdfs路徑都可以簡寫

-->hadoop fs -ls /?? 等同于上一條命令的效果

[toto@hadoop learn]$ hadoop fs -ls hdfs://hadoop:9000/

Found 4 items

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 14:01 hdfs://hadoop:9000/findbugs-1.3.9

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 03:23 hdfs://hadoop:9000/hive

drwx------?? - toto supergroup????????? 0 2017-05-29 14:47 hdfs://hadoop:9000/tmp

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 14:47 hdfs://hadoop:9000/user

[toto@hadoop learn]$

?

上面的命令等同:hadoop fs -ls /

?

[toto@hadoop learn]$ hadoop fs -ls hdfs://hadoop:9000/findbugs-1.3.9

下面的命令表示同時列出hdfs://hadoop:9000/findbugs-1.3.9和hive下面的內容

[toto@hadoop learn]$ hadoop fs -ls hdfs://hadoop:9000/findbugs-1.3.9 /hive

-mkdir???

?

mkdir

使用方法:hadoop fs -mkdir <paths>?

功能:在hdfs上創建目錄,接受路徑指定的uri作為參數,創建這些目錄。其行為類似于Unix的mkdir -p,它會創建路徑中的各級父目錄。

示例:hadoop fs? -mkdir? -p? /aaa/bbb/cc/dd

?

再如示例:

[toto@hadoop learn]$hadoop fs –mkdir -p /user/hadoop/dir1 /user/hadoop/dir2

[toto@hadoop learn]$ hadoop fs -mkdir -p hdfs://hadoop:9000/toto hdfs://hadoop:9000/toto2

[toto@hadoop learn]$ hadoop fs -ls /

Found 6 items

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 14:01 /findbugs-1.3.9

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 03:23 /hive

drwx------? ?- toto supergroup????????? 0 2017-05-29 14:47 /tmp

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 23:40 /toto

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 23:41 /toto2

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 23:36 /user

?

對應瀏覽器上的訪問效果如下:http://hadoop:50070/explorer.html#/

顯示效果一致

-moveFromLocal??

使用方法:dfs -moveFromLocal <src> <dst>

功能:從本地剪切粘貼到hdfs

[toto@hadoop learn]$ ls

hadoop? LICENSE-ASM.txt

[toto@hadoop learn]$ hdfs dfs -moveFromLocal LICENSE-ASM.txt /toto

[toto@hadoop learn]$ hdfs dfs -ls /toto

Found 1 items

-rw-r--r--?? 3 toto supergroup?????? 1511 2017-05-29 23:50 /toto/LICENSE-ASM.txt

[toto@hadoop learn]$

?

再如:

[toto@hadoop learn]$ hadoop fs -moveFromLocal hadoop /toto

[toto@hadoop learn]$ hadoop fs -ls /toto

Found 2 items

-rw-r--r--?? 3 toto supergroup?????? 1511 2017-05-29 23:50 /toto/LICENSE-ASM.txt

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 23:53 /toto/hadoop

[toto@hadoop learn]$

?

-moveToLocal?????????????

功能:從hdfs剪切粘貼到本地

示例:hadoop? fs? - moveToLocal?? /aaa/bbb/cc/dd? /home/hadoop/a.txt

--appendToFile?

功能:追加一個文件到已經存在的文件末尾

示例:hadoop? fs? -appendToFile? ./hello.txt? hdfs://hadoop:9000/hello.txt

可以簡寫為:

Hadoop? fs? -appendToFile? ./hello.txt? /hello.txt

?

實際案例:

[toto@hadoop learn]$ hadoop fs -put text.txt /toto

[toto@hadoop learn]$ hadoop fs -ls /toto

Found 3 items

-rw-r--r--?? 3 toto supergroup?????? 1511 2017-05-29 23:50 /toto/LICENSE-ASM.txt

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 23:53 /toto/hadoop

-rw-r--r--?? 3 toto supergroup????????? 0 2017-05-29 23:59 /toto/text.txt

[toto@hadoop learn]$ cat hello.txt

示例:hadoop? fs? -appendToFile? ./hello.txt? hdfs://hadoop:9000/hello.txt

可以簡寫為:

Hadoop? fs? -appendToFile? ./hello.txt? /hello.txt

?

將文件上傳到hdfs

[toto@hadoop learn]$ hadoop fs -appendToFile ./hello.txt hdfs://hadoop:9000/toto/text.txt

查看拼接到text.txt中的內容

[toto@hadoop learn]$ hadoop fs -cat /toto/text.txt

示例:hadoop? fs? -appendToFile? ./hello.txt? hdfs://hadoop:9000/hello.txt

可以簡寫為:

Hadoop? fs? -appendToFile? ./hello.txt? /hello.txt

?

[toto@hadoop learn]$

-cat?

功能:顯示文件內容?

示例:hadoop fs -cat? /hello.txt

?

?

-tail????????????????

功能:顯示一個文件的末尾

示例:hadoop? fs? -tail? /weblog/access_log.1

實際案例:

[toto@hadoop learn]$ hadoop fs -tail /toto/text.txt

示例:hadoop? fs? -appendToFile? ./hello.txt? hdfs://hadoop:9000/hello.txt

可以簡寫為:

Hadoop? fs? -appendToFile? ./hello.txt? /hello.txt

?

[toto@hadoop learn]$

?

?

?

-text?????????????????

功能:以字符形式打印一個文件的內容

示例:hadoop? fs? -text? /weblog/access_log.1

實際案例:

[toto@hadoop learn]$ hadoop fs -text /toto/text.txt

示例:hadoop? fs? -appendToFile? ./hello.txt? hdfs://hadoop:9000/hello.txt

可以簡寫為:

Hadoop? fs? -appendToFile? ./hello.txt? /hello.txt

?

[toto@hadoop learn]$

-chgrp

-chmod

-chown

功能:linux文件系統中的用法一樣,對文件所屬權限

示例:

hadoop? fs? -chmod? 666? /hello.txt

hadoop? fs? -chown? someuser:somegrp?? /hello.txt

?

實際案例:

[toto@hadoop learn]$ hadoop fs -chmod 777 /toto/text.txt

[toto@hadoop learn]$ hadoop fs -ls /toto/text.txt

-rwxrwxrwx?? 3 toto supergroup??????? 149 2017-05-30 00:01 /toto/text.txt

[toto@hadoop learn]$ hadoop fs -chmod 666 /toto/text.txt

[toto@hadoop learn]$ hadoop fs -ls /toto/text.txt

-rw-rw-rw-?? 3 toto supergroup??????? 149 2017-05-30 00:01 /toto/text.txt

[toto@hadoop learn]$

-copyFromLocal???

功能:從本地文件系統中拷貝文件到hdfs路徑去

示例:hadoop? fs? -copyFromLocal? ./jdk.tar.gz? /aaa/

?

實際案例:

[toto@hadoop learn]$ cat hello.txt

示例:hadoop? fs? -appendToFile? ./hello.txt? hdfs://hadoop:9000/hello.txt

可以簡寫為:

Hadoop? fs? -appendToFile? ./hello.txt? /hello.txt

?

[toto@hadoop learn]$ hadoop fs -copyFromLocal ./hello.txt /toto2

[toto@hadoop learn]$ ls

hello.txt? text.txt

[toto@hadoop learn]$ hadoop fs -ls /toto2

Found 1 items

-rw-r--r--?? 3 toto supergroup??????? 149 2017-05-30 00:09 /toto2/hello.txt

[toto@hadoop learn]$

?

-copyToLocal?????

功能:從hdfs拷貝到本地

示例:hadoop fs -copyToLocal /aaa/jdk.tar.gz

實際案例:

[toto@hadoop learn]$ hadoop fs -ls /

Found 6 items

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 14:01 /findbugs-1.3.9

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 03:23 /hive

drwx------?? - toto supergroup????????? 0 2017-05-29 14:47 /tmp

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 23:59 /toto

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-30 00:09 /toto2

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 23:36 /user

[toto@hadoop learn]$ hadoop fs -copyToLocal /findbugs-1.3.9 ./

[toto@hadoop learn]$ ls

findbugs-1.3.9? hello.txt? text.txt

[toto@hadoop learn]$ hadoop fs -ls /

Found 6 items

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 14:01 /findbugs-1.3.9

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 03:23 /hive

drwx------?? - toto supergroup????????? 0 2017-05-29 14:47 /tmp

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 23:59 /toto

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-30 00:09 /toto2

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 23:36 /user

[toto@hadoop learn]$

-cp?????????????

功能:從hdfs的一個路徑拷貝hdfs的另一個路徑

示例: hadoop ?fs ?-cp? /aaa/jdk.tar.gz? /bbb/jdk.tar.gz.2

Usage: hadoop fs [generic options] -cp [-f] [-p | -p[topax]] [-d] <src> ... <dst>

[toto@hadoop learn]$ hadoop fs -cp -p /findbugs-1.3.9 /toto2

[toto@hadoop learn]$ hadoop fs -ls /toto2

Found 2 items

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 14:01 /toto2/findbugs-1.3.9

-rw-r--r--?? 3 toto supergroup??????? 149 2017-05-30 00:09 /toto2/hello.txt

[toto@hadoop learn]$

?

?

-mv????????????????????

功能:在hdfs目錄中移動文件

示例: hadoop ?fs ?-mv? /aaa/jdk.tar.gz? /

實際案例:

[toto@hadoop learn]$ hadoop fs -ls /toto2

Found 2 items

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 14:01 /toto2/findbugs-1.3.9

-rw-r--r--?? 3 toto supergroup??????? 149 2017-05-30 00:09 /toto2/hello.txt

[toto@hadoop learn]$ hadoop fs -mv /toto/hello.txt /user

mv: `/toto/hello.txt': No such file or directory

[toto@hadoop learn]$ hadoop fs -mv /toto2/hello.txt /user

[toto@hadoop learn]$ hadoop fs -ls /user

Found 3 items

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 23:36 /user/hadoop

-rw-r--r--?? 3 toto supergroup??????? 149 2017-05-30 00:09 /user/hello.txt

drwxr-xr-x?? - toto supergroup????????? 0 2017-05-29 14:51 /user/toto

[toto@hadoop learn]$

-get?????????????

功能:等同于copyToLocal,就是從hdfs下載文件到本地

示例:hadoop fs -get? /aaa/jdk.tar.gz

?????

功能:合并下載多個文件

示例:比getmerge??? 如hdfs的目錄 /aaa/下有多個文件:log.1, log.2,log.3,...

hadoop fs -getmerge /aaa/log.* ./log.sum

-put???????????????

功能:等同于copyFromLocal

示例:hadoop ?fs ?-put? /aaa/jdk.tar.gz? /bbb/jdk.tar.gz.2

-rm???????????????

功能:刪除文件或文件夾

示例:hadoop fs -rm -r /aaa/bbb/

實際案例:

?

-rmdir????????????????

功能:刪除空目錄

示例:hadoop? fs? -rmdir?? /aaa/bbb/ccc

?

刪除非空文件夾時不讓報錯的命令:

hadoop fs -rmdir --ignore-fail-on-non-empty /toto2/findbugs-1.3.9/lib

-df??????????????

功能:統計文件系統的可用空間信息

示例:hadoop ?fs ?-df? -h ?/

[toto@hadoop learn]$ hdfs dfs -df -h /

Filesystem???????????? Size???? Used? Available? Use%

hdfs://hadoop:9000? 134.4 G? 472.4 M???? 97.8 G??? 0%

?

?

-du

功能:統計文件夾的大小信息

示例:

hadoop? fs? -du? -s? -h /aaa/*

[toto@hadoop learn]$ hadoop fs -du -s -h /toto2

2.3 M? /toto2

[toto@hadoop learn]$

-count????????

功能:統計一個指定目錄下的文件節點數量

示例:hadoop fs -count /aaa/

?

-setrep???????????????

功能:設置hdfs中文件的副本數量

示例:hadoop fs -setrep 3 /aaa/jdk.tar.gz?? (這里的3)

實際命令:

[toto@hadoop learn]$ hadoop fs -setrep 3 /toto2/findbugs-1.3.9

Replication 3 set: /toto2/findbugs-1.3.9/LICENSE-ASM.txt

Replication 3 set: /toto2/findbugs-1.3.9/LICENSE-bcel.txt

Replication 3 set: /toto2/findbugs-1.3.9/LICENSE-commons-lang.txt

Replication 3 set: /toto2/findbugs-1.3.9/LICENSE-docbook.txt

Replication 3 set: /toto2/findbugs-1.3.9/LICENSE-dom4j.txt

Replication 3 set: /toto2/findbugs-1.3.9/LICENSE-jFormatString.txt

Replication 3 set: /toto2/findbugs-1.3.9/LICENSE-jaxen.txt

Replication 3 set: /toto2/findbugs-1.3.9/LICENSE-jcip.txt

Replication 3 set: /toto2/findbugs-1.3.9/LICENSE-jdepend.txt

Replication 3 set: /toto2/findbugs-1.3.9/LICENSE-jsr305.txt

Replication 3 set: /toto2/findbugs-1.3.9/LICENSE-mysql-connector.txt

Replication 3 set: /toto2/findbugs-1.3.9/LICENSE.txt

?

?

補充:查看dfs集群工作狀態的命令

hdfs dfsadmin -report

?

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的HDFS命令行客户端使用,命令行客户端支持的命令参数,常用命令参数介绍的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美香蕉视频 | 午夜小视频免费 | 久久精品一区二区国产 | 两个人看的www视频免费完整版 | 久久视频这里只有精品 | 欧美不卡网 | 日韩一级在线播放 | 午夜视频1000 | 中文在线最新版天堂 | av动漫网| 欧美精品hd| 亚洲a在线播放 | 国产精彩视频一区 | 日韩天堂av| 日韩成人欧美 | 久久九九久精品国产免费直播 | 国产成年人| 国语对白精彩对话 | 国产性在线 | 欧美激情成人在线 | 日韩另类视频 | 国产成人无码精品久久久久 | 男生捅女生肌肌 | 色视频在线观看免费 | 中文字幕在线观看 | 性感美女av在线 | 欧美激情一区二区三区在线 | 色婷婷av一区二区三区gif | 在线免费看av网站 | 日本中文在线视频 | 超级砰砰砰97免费观看最新一期 | 欧美日韩精品一区二区三区视频播放 | 欧美日本日韩 | 美女扒开大腿让男人桶 | 国产激情福利 | 欧美在线观看免费高清 | 夜夜嗨网站 | 黄色大片久久 | 桃色一区二区 | 德国经典free性复古xxxx | 亚洲最大中文字幕 | 在线观看日本中文字幕 | 日本一区二区精品 | 天堂国产精品 | 亚洲涩涩涩 | 亚洲伊人影院 | 欧美乱大交xxxxx潮喷 | 久久久亚洲av波多野结衣 | 精品一区二区三区在线免费观看 | 国产99999| 中文字幕在线视频免费 | 国产大片一区二区三区 | 日本在线视频一区 | 在线免费观看高清视频 | 青青草伊人网 | 亚洲va韩国va欧美va | 久久午夜免费视频 | 日本成人在线免费 | 性感av在线 | 免费网站www在线观看 | 岛国中文字幕 | 亚洲成人激情在线 | 免费人成年激情视频在线观看 | 欧美色图888| 少妇久久久久久 | 成人自拍视频 | 鸥美毛片| 亚洲最大色网站 | 小视频在线看 | 青青青免费在线视频 | 奇米777第四色 | 日韩91在线| 澳门av网站| 黄色片中国| 16—17女人毛片 | 亚洲午夜久久久 | xxxxx黄色片 噜噜噜噜噜色 | 色狠狠av老熟女 | 美女福利视频在线观看 | 国产一区二区三区视频免费在线观看 | 黄网在线| 色综合综合色 | 国产三级一区二区三区 | 999zyz玖玖资源站永久 | 99er热精品视频| 成人理论影院 | 久久久久久国产视频 | 噜噜色综合 | 国产成人视屏 | 波多野吉衣在线视频 | 亚洲乱码国产乱码精品精软件 | 中日韩在线观看视频 | 六月丁香在线视频 | 一本久道久久综合无码中文 | 好吊色综合 | 欧美日韩在线视频播放 | 亚洲视频91| 欧美啪啪一区二区 | 18禁免费无码无遮挡不卡网站 |