# Replication Manager Integration

Cloudera Migration Assistant (CMA) uses **Replication Manager** (RM) as the replication engine for CDP Base to CDP Base migrations. This page explains what Replication Manager is, when it is required, and how CMA interacts with it.

## What is Replication Manager?

Replication Manager is a Cloudera service that creates and manages data replication policies between clusters. It supports replication of:

- **HDFS data** (including HDFS to Ozone)
- **Hive metadata and data**
- **HBase tables**

CMA delegates all data replication operations to Replication Manager via its REST API.

## When is Replication Manager Required?

Replication Manager is required for **CDP Base to CDP Base** migrations that involve data replication:

| Migration Type | RM Required? |
|----------------|-------------|
| HDFS replication (Base to Base) | Yes |
| HDFS to Ozone migration | Yes |
| Hive replication (Base to Base) | Yes |
| HBase replication (Base to Base) | Yes |
| Scanning clusters | No |

## Where Does Replication Manager Run?

Replication Manager (DMX) 1.2 or above should be deployed on the **target cluster**, on the **same node as Cloudera Manager**. It is installed as a separate Cloudera Manager parcel alongside the CMA parcel.

```
Target Cluster Node (Cloudera Manager host)
├── CMA  (parcel)
└── Replication Manager (parcel)
```

## Prerequisites

| Requirement | Details |
|-------------|---------|
| **Cloudera Manager version** | 7.13.2 or later on the target cluster (required for HDFS to Ozone migrations) |
| **Deployment location** | Same node as Cloudera Manager on the target cluster |
| **Network access** | RM REST API port **9011** must be accessible from the CMA Agent on the target cluster |
| **CMA Agent** | Must be deployed and connected to CMA Master on the target cluster |
| **Cluster credentials** | Cloudera Manager admin credentials for both source and target clusters must be configured in CMA |
| **HDFS to Ozone feature flag** | The `CMF_FF_API_H2O_REPLICATION` environment variable must be set on the Cloudera Manager Server host (see below) |

### Enabling the HDFS to Ozone Feature Flag

For HDFS to Ozone migrations, Cloudera Manager requires the `CMF_FF_API_H2O_REPLICATION` feature flag to be enabled. Without this flag, the Replication Manager API endpoints for HDFS to Ozone replication are not available.

To enable the flag, add the following line to `/etc/default/cloudera-scm-server` on the Cloudera Manager Server host:

```bash
export CMF_FF_API_H2O_REPLICATION=true
```

After adding the flag, restart the Cloudera Manager Server:

```bash
sudo systemctl restart cloudera-scm-server
```

Wait for Cloudera Manager to become available again (port 7180) before proceeding with CMA setup.

> **Note:** This flag is only required for **HDFS to Ozone** migrations. It is not needed for HDFS-to-HDFS, Hive, or HBase replication.

## Configuring Replication Manager in CMA

Before CMA can use Replication Manager for data replication, the CMA Agents need to know where the Replication Manager service is located. You must register the Replication Manager instance in the **CMA Master UI** under the **Settings** tab.

### Steps

1. Open the CMA Web UI and navigate to **Settings**.
2. Go to the **RM App Access** section.
3. If CMA has already detected a Replication Manager service on one of the registered clusters, it will appear as a suggestion in the **Suggestions** dropdown. Select it to auto-fill the form, or fill in the fields manually:
   - **Replication Manager App URL** — the full URL of the RM REST API, including protocol, host, and port (e.g., `https://rm-host.example.com:9011`).
   - **Replication Manager App username** — the username for authenticating with the RM API.
   - **Replication Manager App password** — the password for authenticating with the RM API.
4. Click **Save and Push to Agents**.

CMA will save the RM credentials and push them to all connected CMA Agents. The Agents will then use these credentials to register the managed clusters with Replication Manager and to manage replication policies during migration execution.

> **Note:** If no RM App is detected on your clusters, the Settings page will display a warning: "No RM App found on your clusters." In this case, verify that Replication Manager is correctly installed and running on the target cluster before proceeding.

## How CMA Registers Clusters with Replication Manager

Once the RM credentials are configured in Settings, cluster registration with Replication Manager is **automatic** and transparent to the user. When a migration plan requires data replication, CMA handles the registration as follows:

1. **CMA Master** dispatches an `RM_CLUSTER_REGISTRATION` command to the CMA Agent on the target cluster.
2. The **CMA Agent** calls the Replication Manager REST API (`/cm/registerClusters`) to register both the source and target clusters.
3. CMA stores the required credentials in Replication Manager via the `/store/credential` endpoint.
4. Once registration is complete, Replication Manager can create replication policies between the registered clusters.

CMA verifies whether clusters are already registered and skips registration if they are.

## How CMA Uses Replication Manager

During migration execution, CMA interacts with Replication Manager to:

1. **Create replication policies** via the REST API for selected data (HDFS directories, Hive databases, HBase tables).
2. **Manage HDFS/Ozone snapshots** for incremental replication, enabling efficient delta transfers.
3. **Monitor policy execution** by polling policy status and reporting progress back to the CMA Master.
4. **Clean up** completed or failed policies as part of migration lifecycle management.

All Replication Manager interactions are performed by the CMA Agent on the target cluster and reported back to CMA Master for tracking and display in the UI.

## Network Requirements

| From | To | Port | Protocol | Purpose |
|------|----|------|----------|---------|
| CMA Agent (target) | Replication Manager | 9011 | REST (HTTP) | Replication policy management |
| Replication Manager | Source Cloudera Manager | 7180/7183 | HTTP/HTTPS | Source cluster access |
| Replication Manager | Target Cloudera Manager | 7180/7183 | HTTP/HTTPS | Target cluster access |

## Troubleshooting

| Issue | Possible Cause | Resolution |
|-------|----------------|------------|
| Replication policy creation fails | Clusters not registered in RM | Check CMA Agent logs for registration errors; verify RM is running on port 9011 |
| Registration fails with credential error | Incorrect CM credentials in CMA | Update Cloudera Manager credentials in CMA for the affected cluster |
| RM not reachable from Agent | Network/firewall issue | Ensure port 9011 is open between the Agent and RM on the target cluster |
| HDFS to Ozone replication not available | CM version too old | Upgrade Cloudera Manager on the target cluster to 7.13.2 or later |

## Related Documentation

- [CMA Deployment Architecture Overview](cma-deployment-architecture.md) - Overall architecture and component overview
- [Deploy the CMA server](cma-server-setup.md) - CMA installation and setup
- [Registering Clusters](../migration/cma-cluster-registration.md) - How to register clusters in CMA
- [HDFS to Ozone Migration](../migration/cma-hdfs-to-ozone-migration.md) - HDFS to Ozone migration guide
