Let us understand how to copy files with in HDFS (from one HDFS location to another HDFS location).
We can use hdfs dfs -cp
command to copy files with in HDFS.
One need to have at least read permission on source folders or files and write permission on target folder for cp
command to work as expected..
hdfs dfs -cp /public/retail_db/* /user/`whoami`/retail_db
in the above command we are copying data from hdfs location /public/retail_db to the retail_db folder in user home dir in hadoop file system
hdfs dfs -ls /user/`whoami`/retail_db
Found 9 items drwxr-xr-x - itversity supergroup 0 2022-05-29 17:28 /user/itversity/retail_db/categories -rw-r--r-- 1 itversity supergroup 10303297 2022-05-29 17:28 /user/itversity/retail_db/create_db.sql -rw-r--r-- 1 itversity supergroup 1748 2022-05-29 17:28 /user/itversity/retail_db/create_db_tables_pg.sql drwxr-xr-x - itversity supergroup 0 2022-05-29 17:28 /user/itversity/retail_db/customers drwxr-xr-x - itversity supergroup 0 2022-05-29 17:28 /user/itversity/retail_db/departments -rw-r--r-- 1 itversity supergroup 10297372 2022-05-29 17:28 /user/itversity/retail_db/load_db_tables_pg.sql drwxr-xr-x - itversity supergroup 0 2022-05-29 17:28 /user/itversity/retail_db/order_items drwxr-xr-x - itversity supergroup 0 2022-05-29 17:28 /user/itversity/retail_db/orders drwxr-xr-x - itversity supergroup 0 2022-05-29 17:28 /user/itversity/retail_db/products