HDFS 명령어 모음
대부분 리눅스 command와 비슷해서 큰 설명없이도 이해가 쉬웠다.
Dir, File 조회
ls
hdfs dfs -ls /
파일 출력
lsr
hdfs dfs -lsr /
하위 디렉토리 포함하여 파일 출력
du
hdfs dfs -du -h /
파일 용량을 확인, h는 사람이 보기 편하게 만들어주는 것이다.
hdfs dfs -du -h -s /
s 를 붙이면 summary 용량을 확인할 수 있다.
cat
hdfs dfs -cat filename
파일 내용 출력
text
hdfs dfs -text filename
파일 내용 출력하며 압축된 형태도 가능
mkdir
hdfs dfs -mkdir dirname
dir 생성
head, tail
hdfs dfs -head filename
hdfs dfs -tail filename
파일의 시작/끝 부분의 1KB 확인
파일 복사 & 삭제
put
hdfs dfs -put local경로 hdfs경로
copyFromLocal
hdfs dfs -copyFromLocal local경로 hdfs경로
로컬에 있는 파일/폴더 를 hdfs의 경로로 복사(업로드)
get
hdfs dfs -get hdfs경로 local경로
hdfs 파일을 로컬로 복사(다운로드)
cp
hdfs dfs -cp origianl copied
복사
getmerge
hdfs dfs -getmerge -skip-empty-file -nl file1 file2 mergedFile
파일들을 합친다.
-skip-empty-file은 빈파일은 머지 제외
-nl은 파일 사이 newline 추가
rm
hdfs dfs -rm filename
파일 삭제
-R 로 recursively
rmdir
hdfs dfs -rmdir dirname
dir 삭제
권한 변경
chmod
hdfs dfs -chmod 권한번호 filename
파일에 대한 권한을 변경
-R로 재귀적으로 사용 가능
chown
hdfs dfs -chown owner:ownerGroup filename
owner와 ownerGroup에 변경하고 싶은 소유권을 넣어 변경
-R로 재귀적으로 사용 가능
chgrp
hdfs dfs -chgrp groupname filename
소유권 그룹만 변경
Utils
touchz
hdfs dfs -touchz filename
0byte 파일 생성
stat
hdfs dfs -stat format filename
파일에 대한 자세한 통계 조회, 포맷은 아래 내용 참고
Format accepts permissions in octal (%a), symbolic (%A), filesize in bytes (%b), type (%F), group name of owner (%g), name (%n), block size (%o), replication (%r), user name of owner(%u), access date(%x, %X), and modification date (%y, %Y). %x and %y show UTC date as “yyyy-MM-dd HH:mm:ss”, and %X and %Y show milliseconds since January 1, 1970 UTC. If the format is not specified, %y is used by default.
예) hdfs dfs -stat "size:%b type:%F filename:%n block_size:%o replication:%r m_date:%y" filename
setrep
hdfs dfs -setrep -w 3 filename
file에 대해 replica factor 변경
expunge
hdfs dfs -expunge
휴지통 비우기
'Data Engineering > Hadoop' 카테고리의 다른 글
Amazon EMR Hadoop 구축해보기 | MYSQL RDS, EMR 클러스터 생성 (0) | 2024.01.12 |
---|---|
Hadoop의 Fair Call Queue (0) | 2024.01.09 |
Hadoop RAID, Eraser Coding (1) | 2024.01.08 |
Observer Name Node(ONN)로 부하 분산 (0) | 2024.01.08 |
Hadoop의 High Availability (고가용성) 아키텍처 (1) | 2024.01.08 |