Bidirectional replication example of two active clusters

Review the bidirectional replication example to learn how you can configure and start replication with Streams Replication Manager in a deployment with two active clusters configured with bidirectional replication.

In a typical scenario, you may have two active Kafka clusters within the same region but in separate availability zones. With bidirectional replication, clients can connect to either cluster in case one is temporarily unavailable.

This example demonstrates the steps required to configure the deployment shown below. Additionally, it also provides example commands to start replication between clusters.

Figure 1. Bidirectional Replication of Active Clusters
  • The following list of steps assume that both clusters are unsecured.
  • The following list of steps assume that the Streams Replication Manager Service role is running on all Kafka broker hosts and is targeting its co-located cluster (the cluster it is running in).
  • Steps 1 through 6 must be carried out on all clusters for all SRM services. The steps highlight when the configuration differs from cluster to cluster or if it is identical on all clusters.
  • The following list of steps assume that the DefaultReplicationPolicy is in use.
  1. Define external clusters:
    1. In Cloudera Manager, go to Administration > External Accounts.
    2. Go to the Kafka Credentials tab.
      On this tab you will create a credential for each external cluster taking part in the replication process.
    3. Click Add Kafka credentials.
    4. Configure the Kafka credential:
      On the primary cluster you have to add a credential that defines secondary. For example:
      Name=secondary
      Bootstrap servers=secondary-1.cloudera.com:9092, secondary-2.cloudera.com:9092, secondary-3.cloudera.com:9092
      Security protocol=PLAINTEXT
      
      On the secondary cluster you have to add a credential that defines primary. For example:
      Name=primary
      Bootstrap servers=primary-1.cloudera.com:9092, primary-2.cloudera.com:9092, primary-3.cloudera.com:9092
      Security protocol=PLAINTEXT
      
    5. Click Add.
      If credential creation is successful, a new entry corresponding to the Kafka credential you specified appears on the page.
  2. Define the co-located Kafka cluster:
    1. In Cloudera Manager, go to Clusters and select the Streams Replication Manager service.
    2. Go to Configuration.
    3. Find and enable the Kafka Service property.
    4. Find and configure the Streams Replication Manager Co-located Kafka Cluster Alias property.
      The alias you configure represents the co-located cluster. Enter an alias that is unique and easily identifiable. On the primary cluster:
      primary
      On the secondary cluster:
      secondary
  3. Add the clusters defined with Kafka credentials to SRM’s configuration:
    1. Find and configure the External Kafka Accounts property.
    2. Click the add button and add new lines for each Kafka credential you created.
    3. Add the names of all Kafka credentials.
      Each Kafka credential must be added to a new line. On the primary cluster:
      secondary
      On the secondary cluster:
      primary
  4. Find and configure the Streams Replication Manager Cluster alias property.
    Add all cluster aliases to this property. This includes the aliases present in both the External Kafka Accounts and Streams Replication Manager Co-located Kafka Cluster Alias properties. Delimit the aliases with commas. In the case of this example the configuration is identical on both clusters:
    primary, seconadry
  5. Configure Driver role target clusters:
    1. Find the Streams Replication Manager Driver Target Cluster property.
    2. Add the cluster aliases that you want the driver role to target.
      In the case of this example, each Driver should target its co-located cluster. On the primary cluster:
      primary
      On the secondary cluster:
      secondary
  6. Add and enable replications:
    1. Find the Streams Replication Manager's Replication Configs property.
    2. Click the add button and add new lines for each unique replication you want to add and enable.
    3. Add and enable your replications.

      In the case of this example, the configuration will be identical on both clusters:

      primary->secondary.enabled=true
      secondary->primary.enabled=true
      
  7. Replicate data between clusters with the following commands:
    srm-control topics --source primary --target secondary --add ".*"
    
    srm-control topics --source secondary --target primary --add ".*"