HDFS Shell 조작 연습
9902 단어 shell
Content 1. HDFS 셸 기본 동작
1.1 HDFS 디 렉 터 리 탐색
/opt/hadoop$ bin/hadoop fs -ls
1.2 HDFS 디 렉 터 리 에 자료 업로드
/opt/hadoop$ bin/hadoop fs -put conf input
/opt/hadoop$ bin/hadoop fs -ls
/opt/hadoop$ bin/hadoop fs -ls input
1.3 HDFS 자 료 를 로 컬 디 렉 터 리 에 다운로드
/opt/hadoop$ bin/hadoop fs -get input fromHDFS
/opt/hadoop$ ls -al | grep fromHDFS
/opt/hadoop$ ls -al fromHDFS
1.4 파일 삭제
/opt/hadoop$ bin/hadoop fs -ls input
/opt/hadoop$ bin/hadoop fs -rm input/masters
1.5 파일 직접 보기
/opt/hadoop$ bin/hadoop fs -ls input
/opt/hadoop$ bin/hadoop fs -cat input/slaves
1.6 더 많은 명령 조작
hadooper@vPro:/opt/hadoop$ bin/hadoop fs
Usage: java FsShell
[-ls <path>]
[-lsr <path>]
[-du <path>]
[-dus <path>]
[-count[-q] <path>]
[-mv <src> <dst>]
[-cp <src> <dst>]
[-rm <path>]
[-rmr <path>]
[-expunge]
[-put <localsrc> ... <dst>]
[-copyFromLocal <localsrc> ... <dst>]
[-moveFromLocal <localsrc> ... <dst>]
[-get [-ignoreCrc] [-crc] <src> <localdst>]
[-getmerge <src> <localdst> [addnl]]
[-cat <src>]
[-text <src>]
[-copyToLocal [-ignoreCrc] [-crc] <src> <localdst>]
[-moveToLocal [-crc] <src> <localdst>]
[-mkdir <path>]
[-setrep [-R] [-w] <rep> <path/file>]
[-touchz <path>]
[-test -[ezd] <path>]
[-stat [format] <path>]
[-tail [-f] <file>]
[-chmod [-R] <MODE[,MODE]... | OCTALMODE> PATH...]
[-chown [-R] [OWNER][:[GROUP]] PATH...]
[-chgrp [-R] GROUP PATH...]
[-help [cmd]]
Generic options supported are
-conf <configuration file> specify an application configuration file
-D <property=value> use value for given property
-fs <local|namenode:port> specify a namenode
-jt <local|jobtracker:port> specify a job tracker
-files <comma separated list of files> specify comma separated files to be copied to the map reduce cluster
-libjars <comma separated list of jars> specify comma separated jar files to include in the classpath.
-archives <comma separated list of archives> specify comma separated archives to be unarchived on the compute machines.
The general command line syntax is
bin/hadoop command [genericOptions] [commandOptions]
Content 2. 웹 페이지 Gui 로 정보 조회
Content 3. 더 많은 HDFS 셸 사용법
$ bin/hadoop fs -ls input
Found 4 items
-rw-r--r-- 2 hadooper supergroup 115045564 2009-04-02 11:51 /user/hadooper/input/1.txt
-rw-r--r-- 2 hadooper supergroup 987864 2009-04-02 11:51 /user/hadooper/input/2.txt
-rw-r--r-- 2 hadooper supergroup 1573048 2009-04-02 11:51 /user/hadooper/input/3.txt
-rw-r--r-- 2 hadooper supergroup 25844527 2009-04-02 11:51 /user/hadooper/input/4.txt
$ bin/hadoop fs -ls hdfs://gm1.nchc.org.tw:9000/user/hadooper/input
Found 4 items
-rw-r--r-- 2 hadooper supergroup 115045564 2009-04-02 11:51 /user/hadooper/input/1.txt
-rw-r--r-- 2 hadooper supergroup 987864 2009-04-02 11:51 /user/hadooper/input/2.txt
-rw-r--r-- 2 hadooper supergroup 1573048 2009-04-02 11:51 /user/hadooper/input/3.txt
-rw-r--r-- 2 hadooper supergroup 25844527 2009-04-02 11:51 /user/hadooper/input/4.txt
-cat
$ bin/hadoop fs -cat quota/hadoop-env.sh
-chgrp
$ bin/hadoop fs -chgrp -R hadooper own
$ bin/hadoop fs -chmod -R 755 own
$ bin/hadoop fs -chown -R hadooper own
$ bin/hadoop fs -put input dfs_input
-copyToLocal, -get
$ bin/hadoop fs -get dfs_input input1
-cp
$ bin/hadoop fs -cp own hadooper
$ bin/hadoop fs -du input
Found 4 items
115045564 hdfs://gm1.nchc.org.tw:9000/user/hadooper/input/1.txt
987864 hdfs://gm1.nchc.org.tw:9000/user/hadooper/input/2.txt
1573048 hdfs://gm1.nchc.org.tw:9000/user/hadooper/input/3.txt
25844527 hdfs://gm1.nchc.org.tw:9000/user/hadooper/input/4.txt
$ bin/hadoop fs -dus input
hdfs://gm1.nchc.org.tw:9000/user/hadooper/input 143451003
$ bin/hadoop fs -expunge
$ echo "this is one; " >> in1/input
$ echo "this is two; " >> in1/input2
$ bin/hadoop fs -put in1 in1
$ bin/hadoop fs -getmerge in1 merge.txt
$ cat ./merge.txt
-ls
$ bin/hadoop fs -ls
$ bin/hadoop fs -lsr /
$ bin/hadoop fs -mkdir a b c
$ bin/hadoop fs -moveFromLocal in1 in2
$ bin/hadoop fs -mv in2 in3
$ bin/hadoop fs -rm in1/input
$ bin/hadoop fs -rmr in1
$ bin/hadoop fs -setrep -w 2 -R input
Replication 2 set: hdfs://gm1.nchc.org.tw:9000/user/hadooper/input/1.txt
Replication 2 set: hdfs://gm1.nchc.org.tw:9000/user/hadooper/input/2.txt
Replication 2 set: hdfs://gm1.nchc.org.tw:9000/user/hadooper/input/3.txt
Replication 2 set: hdfs://gm1.nchc.org.tw:9000/user/hadooper/input/4.txt
Waiting for hdfs://gm1.nchc.org.tw:9000/user/hadooper/input/1.txt ... done
Waiting for hdfs://gm1.nchc.org.tw:9000/user/hadooper/input/2.txt ... done
Waiting for hdfs://gm1.nchc.org.tw:9000/user/hadooper/input/3.txt ... done
Waiting for hdfs://gm1.nchc.org.tw:9000/user/hadooper/input/4.txt ... done
-stat
$ bin/hadoop fs -stat input
2009-04-02 03:51:29
$ bin/hadoop fs -tail input/1.txt
$ bin/hadoop fs -test -e /user/hadooper/input/5.txt
$ bin/hadoop fs -test -z /user/hadooper/input/5.txt
test: File does not exist: /user/hadooper/input/5.txt
$ bin/hadoop fs -test -d /user/hadooper/input/5.txt
test: File does not exist: /user/hadooper/input/5.txt
-text
$ hadoop fs -text macadr-eth1.txt.gz
00:1b:fc:61:75:b1
00:1b:fc:58:9c:23
$ bin/hadoop fs -text b/a.txt.zip
PK
���:��H{
a.txtUT b��Ib��IUx��sssss
test
PK
���:��H{
��a.txtUTb��IUxPK@C
$ bin/hadoop fs -touchz b/kk
$ bin/hadoop fs -test -z b/kk
$ echo $?
1
$ bin/hadoop fs -test -z b/a.txt.zip
$ echo $?
0
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
✨〰️ ZI 〰️✨ Vim 구문❮ ZI ❯ 🧙♀️ Zsh를 위한 스위스 아미 나이프. 모든 것을 함께 붙일 수 있도록 설계되었습니다. zsh 유형의 파일에 있는 명령에 대한 Vim 구문 정의입니다. 📥 설치 Vim 플러그인으로 로드합니다. 예를...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.