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

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.
主站蜘蛛池模板: 香港| 红河县| 五原县| 华宁县| 安仁县| 高碑店市| 江川县| 华坪县| 墨脱县| 伊川县| 芦山县| 雅江县| 锦屏县| 巫溪县| 贵溪市| 景东| 遵义县| 云浮市| 江山市| 连州市| 绍兴市| 连州市| 连城县| 玉屏| 洛川县| 岫岩| 乌拉特后旗| 洛隆县| 东阳市| 邹平县| 金堂县| 重庆市| 东山县| 光泽县| 始兴县| 河津市| 澳门| 兴安盟| 遂昌县| 英超| 交口县|