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

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.
主站蜘蛛池模板: 鄱阳县| 焉耆| 修武县| 开鲁县| 杭州市| 太和县| 紫金县| 海门市| 浪卡子县| 上蔡县| 灌南县| 宜君县| 平和县| 禄丰县| 辛集市| 林州市| 仁化县| 高平市| 东光县| 丰城市| 新田县| 类乌齐县| 奉贤区| 灵宝市| 旺苍县| 十堰市| 黑水县| 东乌| 蛟河市| 唐山市| 游戏| 张家界市| 墨竹工卡县| 阿克苏市| 朝阳县| 常山县| 大港区| 灵台县| 柘荣县| 读书| 台州市|