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

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.
主站蜘蛛池模板: 遂宁市| 陆河县| 临澧县| 韶关市| 马尔康县| 湘西| 佛山市| 赤峰市| 柞水县| 承德市| 蓬安县| 尚志市| 湖口县| 景洪市| 通榆县| 淳安县| 垦利县| 资源县| 盐津县| 商水县| 临朐县| 双辽市| 霍州市| 大名县| 鸡泽县| 万山特区| 武鸣县| 浮梁县| 江阴市| 全南县| 准格尔旗| 富川| 冷水江市| 扬州市| 包头市| 边坝县| 无棣县| 永清县| 汉源县| 南昌市| 永昌县|