Migrating our Hadoop Cluster with Apache DistCp
Tags: hadoop, bigdata, data, python
Published: 2019-11-22 09:32:58

---
title: Migrating our Hadoop Cluster with Apache DistCp
published: true
date: 2018-03-31 17:11:56 UTC
tags: hadoop,big-data,data,python
canonical_url: 
---

#### From an unsecure cluster to a remote and secure cluster

### Whats Our Mission?

We need to migrate our **Entire Hadoop Cluster** from an unsecure CDH 5.7.1 cluster to a secure CDH 5.13.1 cluster in a remote Data Center.

And we wanted to find a complete product for our use case.

![](https://cdn-images-1.medium.com/max/686/1*yPv_3AmCyKOyVZ2AZeYflA.png)

### The Product Demands

- Migrate our data hermetically
- Migrate our Apahce Hive Metastore.
- Need to show BI on the transfer process

### So Whats The Big Deal?

There are couple of frameworks for handling this type of problem:

- [Cloudera BDR](https://www.cloudera.com/documentation/enterprise/5-11-x/topics/cm_bdr_tutorials.html)
- [Apache Falcon](https://falcon.apache.org)
- Oracle Golden Gate with [HDFS adapter](http://www.oracle.com/technetwork/middleware/goldengate/documentation/gg-java-adp-bigdata-hdfs-adp-2601138.pdf)and [Hive adapter](http://www.oracle.com/technetwork/middleware/goldengate/documentation/gg-java-adp-bigdata-hive-adp-2600938.pdf)
- [Oracle Data Integrator](https://www.linkedin.com/pulse/moving-data-across-hadoop-clusters-using-oracle-issam-hijazi/)
- And there are more that we didn’t cover

However with each frameworks we encounters another fallback..

- Cloudera BDR does not support unsecure cluster to secure cluster
- Apache Falcon does not support the current Hadoop version Cloudera uses
- Oracle told us that it is not the use case for Oracle Golden Gate and recommended us to use Oracle Data Integrator
- Our experience with Oracle Data Integrator wasn’t that great….

So we found ourselves in front this mission without any framework that will work for us and it was obvious we had to go back to the drawing board.

### What About Apache DistCp With some Python?

We always knew that we can use Apache DistCp from unsecure to a secure cluster but we wanted a complete product tested and reviewed that works, we didn’t want to develop our own “BDR”, although it came clear that we have to develop our own product.

### Our Flow

#### Data Copy

![](https://cdn-images-1.medium.com/max/198/1*-ZlDA_I4wwsfV3WH7kT7bQ.png)

1. Scan the Unsecure HDFS — recursively, we need to know also the sub paths to synchronize. how many files we have? path size?
2. Save the HDFS scan to Database Table.
3. Running The [Hadoop DistCp command](https://www.cloudera.com/documentation/enterprise/5-5-x/topics/cdh_admin_distcp_secure_insecure.html) from the Secure cluster.
4. We want the entire process to run with our team user, so we need to change the directory permissions.
5. Validating that each and every byte have been synchronized across the clusters

We decided to run the DistCp command in batches of 10 deepest sub directories each time, this decision was made due to resource limitation…

#### Apahce Hive Metastore Syncronization

![](https://cdn-images-1.medium.com/max/151/1*Zkszg-AJQgVuYvyPWLu8OQ.png)

1. List all the Hive databases in our Unsecure cluster.
2. List all the tables we have
3. Query “show create table” for each table.
4. Query the Secure cluster with the same query in order to create the tables.
5. Run Invalidate Metadata in order to “load” the data to impala, and msck repair for Hive

### Summary

You don’t need a fancy product to migrate or copy your data, you can always use the same old Hadoop distcp command with some hive querying.

Enjoy!


> Like this post? You want to access my private github projects?
> Support me via [Patreon](https://www.patreon.com/eranelbaz)
> Subscribe to my [YouTube Channel](https://www.youtube.com/channel/UCVUNeBGM5wZJKcOx0QwAaTA?sub_confirmation=1)