Perform Aiven for PostgreSQL® switchover to the recovery region Limited availability
Perform a planned promotion of your recovery service while the primary service is healthy.
Switch over to your Aiven for PostgreSQL® recovery service for planned maintenance, simulating a disaster, or testing the resilience of your infrastructure.
Prerequisites
- CRDR setup up and running
- One of the following tools for operating CRDR:
Switch over
- CLI
- API
- Terraform
Use the Aiven CLI to perform a switchover:
avn service disaster-recovery promote-to-master \
--project PROJECT_NAME \
SERVICE_NAME
Replace the placeholders with your actual values:
PROJECT_NAME
: Your Aiven project nameSERVICE_NAME
: Name of your recovery PostgreSQL service
Monitor the switchover status:
avn service disaster-recovery get \
--project PROJECT_NAME \
SERVICE_NAME
Verify the service state after switchover:
avn service get \
--project PROJECT_NAME \
SERVICE_NAME
Use the ServiceUpdate API endpoint to perform a switchover:
curl -X PUT \
"https://api.aiven.io/v1/project/PROJECT_NAME/service/SERVICE_NAME" \
-H "Authorization: Bearer API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"disaster_recovery_promote_to_master": true
}'
Replace the placeholders:
PROJECT_NAME
: Your Aiven project nameSERVICE_NAME
: Name of your recovery PostgreSQL serviceAPI_TOKEN
: Your Aiven API authentication token
Check the disaster recovery status:
curl -X GET \
"https://api.aiven.io/v1/project/PROJECT_NAME/service/SERVICE_NAME/disaster-recovery" \
-H "Authorization: Bearer API_TOKEN"
Verify the service state after switchover:
curl -X GET \
"https://api.aiven.io/v1/project/PROJECT_NAME/service/SERVICE_NAME" \
-H "Authorization: Bearer API_TOKEN"
The
aiven_service_integration
resource with the disaster_recovery
type manages the active-passive relationship between
services. CRDR operations are performed by manipulating this integration.
To trigger switchover and promote the recovery service to active:
-
Comment out or remove the existing disaster recovery integration.
# resource "aiven_service_integration" "disaster_recovery" {
# project = var.project_name
# integration_type = "disaster_recovery"
# source_service_name = aiven_postgresql.primary.service_name
# destination_service_name = aiven_postgresql.recovery.service_name
# }or
terraform destroy -target=aiven_service_integration.disaster_recovery
-
Create an integration with the roles reversed.
resource "aiven_service_integration" "disaster_recovery_switched" {
project = var.project_name
integration_type = "disaster_recovery"
source_service_name = aiven_postgresql.recovery.service_name # Now active
destination_service_name = aiven_postgresql.primary.service_name # Now passive
} -
Wait for the switchover to complete before applying the new configuration.
terraform apply
When the switchover process is completed, your primary service is Passive, and the recovery service is Active, which means the recovery service is in control over your workloads.
Related pages