Exporting HDFS data to a local machine
In this recipe, we are going to export/copy data from HDFS to the local machine.
Getting ready
To perform this recipe, you should already have a running Hadoop cluster.
How to do it...
Performing this recipe is as simple as copying data from one folder to the other. There are a couple of ways in which you can export data from HDFS to the local machine.
- Using the
copyToLocal
command, you'll get this code:hadoop fs -copyToLocal /mydir1/LICENSE.txt /home/ubuntu
- Using the
get
command, you'll get this code:hadoop fs -get/mydir1/LICENSE.txt /home/ubuntu
How it works...
When you use HDFS copyToLocal
or the get
command, the following things occur:
- First of all, the client contacts
NameNode
because it needs a specific file ...
Get Hadoop Real-World Solutions Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.