doctl Verified current stable Not installed? Cloud Infrastructure

Doctl / Create Database Replica

Create Database Replica

Create a new database replica for a specified database.

$
Terminal
doctl d r c <database_id> <replica_name>

When To Use

During load-balancing and scaling operations to enhance read performance.

Pro Tip

Use the `--region` flag to create the replica in a specified data center to reduce latency for users.

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
Creating database replica...

ID          Name               Status
------------------------------------------------
12345678   my-database       active
87654321   my-replica        creating

Replica created successfully!

Anatomy of Output

Understanding the result

Creating replica: replica_name for database: database_id Creation Status

Indicates the command's target database.

Replica created successfully with ID: 789014 Output

Confirms the successful creation and provides the new ID.

Power User Variants

Optimized versions

doctl databases replica create database_id replica_name --region sfo2

Create a replica in a specific region.

Unix Pipeline

Shell combinations

doctl databases replica create --help

View detailed help for creation options.

Troubleshooting

Common pitfalls

Error: Database does not support replicas

Solution: Ensure that the database engine and version support the replica feature.

Error: Invalid database ID

Solution: Double-check the database_id for correctness.

Error: Region not available

Solution: Verify that the selected region supports the database engine.

Command Breakdown

What each part is doing

doctl
Base Command
The executable that performs this operation. Here it runs Doctl before the shell applies any redirect operators.
d
d|databases
The value supplied for d|databases.
r
r|replica
The value supplied for r|replica.
c
c|create
The value supplied for c|create.
<database_id>
database id
The value supplied for database id.
<replica_name>
replica name
The value supplied for replica name.

How To Run

Execution path

  1. Step 1

    Run `doctl databases replica create <database_id> <replica_name>`

  2. Step 2

    Monitor the status with `doctl databases list`

  3. Step 3

    Ensure load balancing is configured for optimal performance.

Alternative Approaches

Comparable commands in other tools

Alternative cloud infrastructure tools for the same job.