Hadoop FS Copy

Share

                Hadoop FS Copy

Hadoop FS Copy is a command used to copy files and directories between Hadoop Distributed File System (HDFS) locations. Hadoop provides a command-line interface called hadoop fs that allows you to interact with HDFS and perform various file and directory operations, including copying data. The copyFromLocal and copyToLocal commands are commonly used for copying data to and from HDFS.

Here’s how you can use hadoop fs to copy data in HDFS:

  1. Copy from Local to HDFS (copyFromLocal):

    • The copyFromLocal command is used to copy files or directories from your local file system into HDFS.
    • The basic syntax is:
    shell
    hadoop fs -copyFromLocal <local-source> <hdfs-destination>

    For example, to copy a local file named localfile.txt to an HDFS directory named /user/hadoop/hdfsdir, you would use:

    shell
    hadoop fs -copyFromLocal localfile.txt /user/hadoop/hdfsdir
  2. Copy from HDFS to Local (copyToLocal):

    • The copyToLocal command is used to copy files or directories from HDFS to your local file system.
    • The basic syntax is:
    shell
    hadoop fs -copyToLocal <hdfs-source> <local-destination>

    For example, to copy a file named hdfspath/file.txt from HDFS to your local directory /localpath, you would use:

    shell
    hadoop fs -copyToLocal hdfspath/file.txt /localpath
  3. Recursive Copy:

    • You can use the -r or --recursive option to perform a recursive copy of directories and their contents.
    shell
    hadoop fs -copyFromLocal -r localdir /user/hadoop/hdfsdir

    This command copies the entire contents of the local directory localdir to the HDFS directory /user/hadoop/hdfsdir.

  4. Overwriting Existing Files:

    • By default, if a file with the same name already exists in the destination location, Hadoop will not overwrite it.
    • To force overwriting, you can use the -f option.
    shell
    hadoop fs -copyFromLocal -f localfile.txt /user/hadoop/hdfsdir

Hadoop Training Demo Day 1 Video:

 
You can find more information about Hadoop Training in this Hadoop Docs Link

 

Conclusion:

Unogeeks is the No.1 IT Training Institute for Hadoop Training. Anyone Disagree? Please drop in a comment

You can check out our other latest blogs on Hadoop Training here – Hadoop Blogs

Please check out our Best In Class Hadoop Training Details here – Hadoop Training

💬 Follow & Connect with us:

———————————-

For Training inquiries:

Call/Whatsapp: +91 73960 33555

Mail us at: info@unogeeks.com

Our Website ➜ https://unogeeks.com

Follow us:

Instagram: https://www.instagram.com/unogeeks

Facebook:https://www.facebook.com/UnogeeksSoftwareTrainingInstitute

Twitter: https://twitter.com/unogeeks


Share

Leave a Reply

Your email address will not be published. Required fields are marked *