官术网_书友最值得收藏!

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:

  1. First of all, the client contacts NameNode because it needs a specific file in HDFS.
  2. NameNode then checks whether such a file exists in its FSImage. If the file is not present, the error code is returned to the client.
  3. If the file exists, NameNode checks the metadata for blocks and replica placements in DataNodes.
  4. NameNode then directly points DataNode from where the blocks would be given to the client one by one. The data is directly copied from DataNode to the client machine. and it never goes through NameNode to avoid bottlenecks.
  5. Thus, the file is exported to the local machine from HDFS.
主站蜘蛛池模板: 水富县| 和顺县| 浮梁县| 类乌齐县| 三河市| 连城县| 桐城市| 桃园县| 伊川县| 静乐县| 明星| 论坛| 阳谷县| 泊头市| 海兴县| 洪洞县| 伊通| 平果县| 余姚市| 嵊泗县| 长海县| 古丈县| 蓬安县| 兴城市| 和平区| 青海省| 湖南省| 铁岭市| 清流县| 集安市| 四平市| 邵阳县| 孟津县| 敦煌市| 桃江县| 揭西县| 隆昌县| 柏乡县| 四平市| 探索| 罗源县|