Create read replica in Aiven for Valkey Early availability
Aiven for Valkey read replica enables data replication from a primary to a replica service, improving performance and increasing redundancy for high availability and disaster recovery.
Prerequisites
- An Aiven account and API token.
- Aiven CLI tool.
Limitations
- You can create a maximum of 5 read replicas per primary service.
- Read replicas are supported only on the Startup plan.
Create a read replica
- Aiven Console
- Aiven CLI
- Aiven API
- Log in to the Aiven Console, select your project, and select your Aiven for Valkey service.
- On the Overview page, scroll to the Read replica section,
- Click Create replica.
- Enter a name for the read replica, select the cloud provider, region, and service plan, and click Create.
The read replica is listed in your project services and can be accessed from the Read replica section on the service's Overview page. The service type is identified by chips labeled Primary or Replica at the top.
To create a read replica using the Aiven CLI, use the following command with placeholders:
avn service create -t valkey -p startup-4 --project PROJECT_NAME \
--read-replica-for PRIMARY_SERVICE_NAME REPLICA_SERVICE_NAME
Parameters:
PROJECT_NAME
: Your project name.CLOUD_NAME
: Cloud provider name.PRIMARY_SERVICE_NAME
: Primary service name.REPLICA_SERVICE_NAME
: Replica service name.
To create a read replica for your Aiven for Valkey service via API, use the following command:
curl -X POST https://api.aiven.io/v1/project/PROJECT_NAME/service \
-H "Content-Type: application/json" \
-H "Authorization: bearer YOUR_AUTH_TOKEN" \
-d '{
"cloud": "CLOUD_NAME",
"plan": "startup-4",
"service_name": "REPLICA_SERVICE_NAME",
"service_type": "valkey",
"project": "PROJECT_NAME",
"service_integrations": [
{
"integration_type": "read_replica",
"source_service_name": "PRIMARY_SERVICE_NAME"
}
]
}'
Parameters:
PROJECT_NAME
: Your project name.YOUR_AUTH_TOKEN
: Your API authentication token.CLOUD_NAME
: Cloud provider name.REPLICA_SERVICE_NAME
: Replica service name.PRIMARY_SERVICE_NAME
: Primary service name.
Promote a replica to a standalone primary
You can promote your read replica to a primary service. After promotion, the replica becomes an independent primary service, disconnected from the original.
- Aiven Console
- Aiven CLI
- Aiven API
- Log in to the Aiven Console and select your Aiven for Valkey service.
- On the Overview page, scroll to the Read replica section.
- Click the replica service to promote.
- On the Replica service's Overview page, click Promote to primary.
- In the confirmation dialog, click Promote.
To promote the replica to primary using the Aiven CLI:
-
Retrieve the service integration ID with the
integration-list
command:avn service integration-list --project <project_name> <replica_service_name>
Parameters:
--project <project_name>
: Your project name.<replica_service_name>
: Your replica service name.
-
Delete the service integration with the following command:
noteDeleting the service integration breaks the replication link, promoting the replica to a standalone primary service.
avn service integration-delete --project PROJECT_NAME <integration_id>
Parameters:
PROJECT_NAME
: Your project name.<integration_id>
: The integration ID obtained in the previous step.
To promote the replica to primary using the Aiven API:
-
Get the service integration ID via an API call.
curl -s \
-H "Authorization: Bearer <token>" \
"https://api.aiven.io/v1/project/PROJECT_NAME/service/REPLICA_SERVICE_NAME/integration" \
| jq -r '.service_integrations[] | select(.source_service_name=="PRIMARY_SERVICE_NAME").service_integration_id'Parameters:
Authorization: Bearer <token>
: Your API authentication token.PROJECT_NAME
: Your project name.REPLICA_SERVICE_NAME
: Your replica service name.PRIMARY_SERVICE_NAME
: Your primary service name.service_integration_id
: Extracts the integration ID.
-
Delete the service integration using the obtained integration ID.
noteDeleting the service integration breaks the replication link, promoting the replica to a standalone primary service.
curl -X DELETE \
-H "Authorization: Bearer <token>" \
"https://api.aiven.io/v1/project/PROJECT_NAME/integration/INTEGRATION_ID"Parameters:
YOUR_AUTH_TOKEN
: Your API authentication token.PROJECT_NAME
: Your project name.INTEGRATION_ID
: The integration ID obtained in the previous step.