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

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.
主站蜘蛛池模板: 鹤壁市| 武陟县| 汶上县| 华池县| 昭通市| 石柱| 盐山县| 大英县| 临湘市| 绵阳市| 罗山县| 建阳市| 陇川县| 贵溪市| 新平| 浦北县| 灯塔市| 四川省| 出国| 潼南县| 黔江区| 元氏县| 齐河县| 吴旗县| 鄂托克前旗| 普洱| 利辛县| 瓮安县| 隆尧县| 延吉市| 科尔| 满城县| 铁岭市| 高淳县| 黑龙江省| 堆龙德庆县| 张家口市| 辽宁省| 北宁市| 伊川县| 桂林市|