Enable cross-cluster replication in Aiven for Apache Cassandra® Limited availability
Enabling the cross-cluster replication (CCR) feature requires building a CCR setup in the Aiven platform and, next, configuring the replication on the Apache Cassandra side.
This article covers the first part only by providing instructions on how to set up CCR for your Aiven for Apache Cassandra® service on the Aiven side.
The other part about configuring the replication factor on the Apache Cassandra side, see Set up the replication factor.
You can enable CCR either when creating a new Aiven for Apache Cassandra service or for an existing service.
Limitations
See CCR limitations for limitations that apply to CCR on Aiven for Apache Cassandra.
Tools
To enable CCR, you can use the following tools:
- Aiven Console
- CLI
- API
Prerequisites
- This is a limited availability feature. To try it out, contact the sales team at sales@aiven.io.
- Aiven account
- Depending on the method you choose to use for enabling CCR
- Access to Aiven Console
cURL
CLI tool- Aiven CLI tool
- See Limitations.
Enable CCR in the console
Using Aiven Console, you can enable CCR for
- New Aiven for Apache Cassandra service by creating a totally new CCR service pair or
- Existing Aiven for Apache Cassandra service by adding a CCR peer service in another region to an existing service.
Create a CCR service pair
- Log in to Aiven Console.
- From the Services page, select +Create service.
- In the Create service view
- Select Apache Cassandra® and, next, a cloud provider and a cloud region for your service.
- To activate CCR, select the Enable Cross Cluster Replication toggle, which unfolds an additional section for setting up another Apache Cassandra service.
- Select a cloud provider and a cloud region for the second service.
- Select one service plan for your two new services.
- Optionally, add an additional disk storage for your services.
- Enter names for your services.
Notice that the service names you enter are automatically copied as the names for datacenters for the services. The datacenters names can be required when executing statements on your databases.
- Verify your choices in the Services summary card on the right and, if your configuration turns out as expected, select +Create services if the setting looks.
You've created two new services that are connected for CCR purposes. You can preview CCR details for your services by selecting Overview from the sidebar and going to the Cross Cluster replication section.
Add a CCR peer to an existing service
-
Log in to Aiven Console.
-
From the Services page, select an Aiven for Apache Cassandra service on which you'd like to enable CCR.
-
In the Overview page of your service, go to the Cross Cluster Replication section and select Migrate to Cross Cluster.
noteWhen you enable CCR on a particular service, you create another service with the same plan, number of nodes, and disk storage.
-
In the Create a Cross Cluster Replica view
- Select a cloud provider and a cloud region, define a name for your new service, and select Continue.
- Examine the Service Summary section and make sure the configuration for your new service meets your expectations. If so, select Create Cross Cluster Replica.
CCR has been enabled by connecting your service to another new service, which is now visible in the Overview page in the Cross Cluster replication section.
Enable CCR with CLI
Using CLI, you can enable CCR for
- New Aiven for Apache Cassandra service by creating a totally new CCR service pair or
- Existing Aiven for Apache Cassandra service by adding a CCR peer service in another region to an existing service.
In this instruction, the Aiven CLI client is used to interact with Aiven APIs.
service_to_join_with
parameter value needs to be set to a name of an existing service in the same project. The supplied service name indicates the service you connect to for enabling CCR. The two connected services create a CCR service pair.cassandra.datacenter
is a datacenter name used to identify nodes from a particular service in the cluster's topology. In CCR for Aiven for Apache Cassandra, all nodes of either of the two services belong to a single datacenter; therefore, a value of thecassandra.datacenter
parameter needs to be unique for each service. It's recommended to set it equal to the service name.
Create a CCR service pair
-
Use the avn service create command to create a service (
service_1
).avn service create \
--project project_name \
--service-type cassandra \
--cloud cloud_region_name \
--plan service_plan_name \
-c cassandra.datacenter=datacenter_1_name \
service_1_name -
Create another new service (
service_2
). This time, include theservice_to_join_with
parameter to connect it toservice_1
and create a CCR pair. Set the value of theservice_to_join_with
parameter to the name ofservice_1
.importantSee Limitations before you set the parameters.
avn service create \
--project project_name \
--service-type cassandra \
--cloud cloud_region_name \
--plan service_plan_name \
-c cassandra.datacenter=datacenter_2_name \
-c service_to_join_with=service_1_name \
service_2_name
Add a CCR peer to an existing service
Use the avn service create command to create a service with CCR enabled. Use the
service_to_join_with
parameter to connect your new service to an
existing service creating a CCR pair. Set the value of the
service_to_join_with
parameter to the name of the existing service.
See Limitations before you set the parameters.
avn service create \
--project project_name \
--service-type cassandra \
--cloud cloud_region_name \
--plan service_plan_name \
-c cassandra.datacenter=datacenter_name \
-c service_to_join_with=existing_service_name \
new_service_name
Enable CCR with API
Using Aiven APIs, you can enable CCR for
- New Aiven for Apache Cassandra service by creating a totally new CCR service pair or
- Existing Aiven for Apache Cassandra service by adding a CCR peer service in another region to an existing service.
In this instruction, the curl
command line tool is used to interact
with Aiven APIs.
service_to_join_with
parameter value needs to be set to a name of an existing service in the same project. The supplied service name indicates the service you connect to for enabling CCR. The two connected services create a CCR service pair.cassandra.datacenter
is a datacenter name used to identify nodes from a particular service in the cluster's topology. In CCR for Aiven for Apache Cassandra, all nodes of either of the two services belong to a single datacenter; therefore, a value of thecassandra.datacenter
parameter needs to be unique for each service. It's recommended to set it equal to the service name.
Create a CCR service pair
Use the
ServiceCreate
API to create a service with CCR enabled. When constructing the API
request, add the user_config
object to the request body and nest
inside it the service_to_join_with
and datacenter
fields.
-
Use the ServiceCreate API to create a service (
service_1
).curl --request POST \
--url https://api.aiven.io/v1/project/YOUR_PROJECT_NAME/service \
--header 'Authorization: Bearer YOUR_BEARER_TOKEN' \
--header 'content-type: application/json' \
--data
'{
"cloud": "string",
"plan": "string",
"service_name": "service_1_name",
"service_type": "cassandra"
}' -
Create another new service (
service_2
). This time when constructing the API request, add theuser_config
object to the request body and nest inside it theservice_to_join_with
anddatacenter
fields. Set the value of theservice_to_join_with
parameter to the name ofservice_1
to connect both services and create a CCR pair.importantSee Limitations before you set the parameters.
curl --request POST \
--url https://api.aiven.io/v1/project/YOUR_PROJECT_NAME/service \
--header 'Authorization: Bearer YOUR_BEARER_TOKEN' \
--header 'content-type: application/json' \
--data
'{
"cloud": "string",
"plan": "string",
"service_name": "service_2_name",
"service_type": "cassandra",
"user_config": {
"cassandra": {
"datacenter": "datacenter_name"
},
"service_to_join_with": "service_1_name"
}
}'
Add a CCR peer to an existing service
Use the
ServiceCreate
API to create a service with CCR enabled. When constructing the API
request, add the user_config
object to the request body and nest
inside it the service_to_join_with
and datacenter
fields. Set the
value of the service_to_join_with
parameter to the name of your
existing service to connect it to your new service and create a CCR
pair.
See Limitations before you set the parameters.
curl --request POST \
--url https://api.aiven.io/v1/project/YOUR_PROJECT_NAME/service \
--header 'Authorization: Bearer YOUR_BEARER_TOKEN' \
--header 'content-type: application/json' \
--data
'{
"cloud": "string",
"plan": "string",
"service_name": "new_service_name",
"service_type": "cassandra",
"user_config": {
"cassandra": {
"datacenter": "datacenter_name"
},
"service_to_join_with": "existing_service_name"
}
}'
What's next
- Set up the replication factor
- Manage CCR on Aiven for Apache Cassandra
- Disable CCR on Aiven for Apache Cassandra