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

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.
主站蜘蛛池模板: 柏乡县| 泽库县| 泸州市| 眉山市| 桐城市| 穆棱市| 唐河县| 乐业县| 常宁市| 上虞市| 个旧市| 晋江市| 文山县| 桓台县| 黔南| 凭祥市| 云霄县| 南部县| 邳州市| 永寿县| 新沂市| 杭锦后旗| 密云县| 余干县| 沂水县| 米易县| 吉林市| 古田县| 冀州市| 平定县| 六安市| 农安县| 河北区| 玉林市| 萍乡市| 治多县| 嵩明县| 长阳| 苍溪县| 滨海县| 南溪县|