KEEP GOING

[hadoop] hdfs 명령어 총 정리(ls, get, copyFromLocal, put, cp, copyToLocal, rm, cat) 본문

bigdata/hadoop

[hadoop] hdfs 명령어 총 정리(ls, get, copyFromLocal, put, cp, copyToLocal, rm, cat)

jmHan 2023. 1. 14. 14:02
반응형

hdfs 명령어 정리

hdfs는 하둡에서 대용량 데이터를 저장하고 처리할 수 있는 파일 시스템입니다. hdfs에 접근하는 다양한 CLI 명령어들이 존재하는데 이를 정리하고자 게시글을 작성하였습니다.

hdfs에서 파일을 확인하는 방법, hdfs에서 로컬로 파일을 복사하는 방법, 역으로 로컬에서 hdfs로 파일을 복사하는 방법, hdfs 내에서 파일을 복사하는 방법 등을 배워보겠습니다.  

 

현재 디렉터리 내 파일 확인 

check hdfs files in working directory

hadoop fs -ls

 

hdfs에서 로컬로 파일 복사 

copy from hdfs to the local file sytem

hadoop fs -get <input_path> <output_path>
hadoop fs -copyToLocal <input_path> <output_path>
hdfs dfs -copyToLocal <input_path> <output_path>

input_path: hdfs 상의 경로  

output_path: local에서의 경로 

 

로컬에서 hdfs로 파일 보내기 

push local file to hdfs

hadoop fs -put <input_path> <output_path>
hadoop fs -copyFromLocal <input_path> <output_path>

input_path: local에서의 경로 

output_path: hdfs 상의 경로 

 

hdfs 내에서 파일 복사 

copy in hdfs

hadoop fs -cp <file1> <file2>

hadoop fs -cp A B

파일 A의 내용을 B라는 이름을 가진 파일에 복사  

 

hdfs 내에서 파일 삭제

rm in hdfs

hadoop fs -rm <file_name>

 

hdfs 파일 확인 

read in hdfs file

hadoop fs -cat <file_name>

 

hdfs 상의 디렉터리 생성 

make directory in hdfs

hdfs dfs -mkdir <path/file_name>

 

hdfs 내에서 파일 이동 

move in hdfs 

hdfs dfs -mv <source/file_name> <destination/file_name>

 

 

반응형
Comments