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

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.
主站蜘蛛池模板: 广安市| 德钦县| 聊城市| 勐海县| 错那县| 商城县| 应用必备| 扬中市| 雅江县| 古蔺县| 兰溪市| 冀州市| 准格尔旗| 留坝县| 关岭| 咸阳市| 墨玉县| 台安县| 卢龙县| 西乌| 怀来县| 灵武市| 黄冈市| 珠海市| 绍兴市| 崇州市| 昭苏县| 青海省| 东安县| 叶城县| 岳阳市| 台中县| 太保市| 临西县| 明光市| 邹城市| 许昌市| 自贡市| 华宁县| 民丰县| 巩留县|