We can copy files from HDFS to local file system either by using copyToLocal
or get
command.
hdfs dfs -copyToLocal
orhdfs dfs -get
– to copy files or directories from HDFS to local filesystem.- It will read all the blocks using index in sequence and construct the file in local file system.
- If the target file or directory already exists in the local file system,
get
will fail saying already exists
Syntax of the command is:
hdfs dfs -get <hdfs path> <local path>
hdfs dfs -copyToLocal <hdfs path> <local path>
hdfs dfs -get /user/`whoami`/retail_db /home/`whoami`
hdfs dfs -copyToLocal /user/`whoami`/retail_db /home/`whoami`