日韩性视频-久久久蜜桃-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命令行客户端使用,命令行客户端支持的命令参数,常用命令参数介绍的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 日本欧美另类 | 久久久久久久福利 | 日本黄xxxxxxxxx100 | 男女黄床上色视频 | 亚洲国产精品成人综合在线 | 2020自拍偷拍 | 亚洲爱爱av| 99精品人妻无码专区在线视频区 | 国产av无毛 | 国产少妇一区二区 | 国产在线观 | 亚洲中文字幕一区 | xxx在线播放 | 四川丰满少妇被弄到高潮 | 国产蜜臀av一区二区 | 日本亚洲一区二区 | 全程偷拍露脸中年夫妇 | 久久高清精品 | 真人毛片97级无遮挡精品 | 久久狠狠爱 | 国产明星换脸xxxx色视频 | 久久久久久久国产精品视频 | 物业福利视频 | 深爱婷婷网 | jizz成人| 用力抵着尿进去了h | 国产激情一区二区三区视频免樱桃 | 成人一级影片 | 欧美aⅴ视频 | www.国产区 | 欧美视频一区二区三区四区 | 国产免费午夜 | 免费一级特黄特色毛片久久看 | 69热在线观看 | 国产福利合集 | 波多野结衣一区二区三区在线 | 国产日产欧美一区二区三区 | 成人av在线一区二区 | 日韩中文字幕亚洲 | 在线cao| 污片免费看 | 日本免费三级网站 | 人人91| 国产免费一区视频观看免费 | 四虎影视免费在线观看 | 伊人精品在线观看 | 成人在线小视频 | 国产av一区二区三区传媒 | 午夜爱爱毛片xxxx视频免费看 | 国产欧美日韩视频 | 懂色av一区二区三区在线播放 | 欧美超逼视频 | 日人视频| 天堂影视av | 岛国视频一区 | 银娇在线观看 | 欧美精品久久久久久久久久 | 国产一级精品毛片 | 性工作者十日谈 | 2021av| 国产二区电影 | 亚洲一区二区三区无码久久 | 久久久一区二区 | 国产区二区 | 亚洲码欧美码一区二区三区 | 日韩精品免费电影 | 国精品一区 | 麻豆精品影院 | 山村大伦淫第1部分阅读小说 | 欧美一级影院 | 亚洲色成人网站www永久四虎 | a√在线观看 | 欧美无砖砖区免费 | 成年人晚上看的视频 | 日韩精品在线观看中文字幕 | 日韩三级黄色 | 人人亚洲 | 牛牛av在线 | 欧美bbw视频 | 二区久久 | 偷拍亚洲精品 | 狠狠躁18三区二区一区 | 夜夜嗨视频 | 日本美女黄视频 | 越南性xxxx精品hd | r级无码视频在线观看 | 久久综合久色欧美综合狠狠 | 国产搞逼视频 | 欧美爽爽爽 | 美女考逼 | 韩国美女福利视频 | 亚洲天堂精品在线 | 不卡日本| 香蕉视频ap | 在线看国产视频 | 亚洲国产日韩a在线播放性色 | 传媒视频在线观看 | 精品人妻伦九区久久aaa片 | 午夜裸体性播放 |