LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

doctl-databases-replica

manage database read replicas

TLDR

List replicas
$ doctl databases replica list [cluster_id]
copy
Create a read replica in another region
$ doctl databases replica create [cluster_id] [replica_name] --region [fra1] --size [db-s-1vcpu-1gb]
copy
Get replica info
$ doctl databases replica get [cluster_id] [replica_name]
copy
Retrieve connection details for a replica
$ doctl databases replica connection [cluster_id] [replica_name]
copy
Delete a replica
$ doctl databases replica delete [cluster_id] [replica_name]
copy
Promote a replica to a standalone primary cluster
$ doctl databases replica promote [cluster_id] [replica_name]
copy

SYNOPSIS

doctl databases replica command database-cluster-id [replica-name] [flags]

DESCRIPTION

doctl databases replica manages read replicas for DigitalOcean managed database clusters. Read replicas are read-only copies of a primary database that provide horizontal scaling for read-heavy workloads and geographic distribution of data.Replicas asynchronously replicate data from the primary cluster, allowing applications to distribute read queries across multiple database instances. This reduces load on the primary and improves query performance. Replicas can be placed in different regions for lower latency to geographically distributed users.In disaster recovery scenarios, replicas can be promoted to standalone clusters, creating an independent database cluster from the replica. This provides failover capabilities and data migration options.

OPTIONS

--region SLUG

Region to place the replica in, e.g. `nyc1` or `fra1`. Defaults to the primary's region.
--size SLUG
Machine size for the replica, e.g. `db-s-1vcpu-1gb`.
--private-network-uuid UUID
VPC to attach the replica to.
-o, --output FORMAT
Output format: `text` (default) or `json`.
--format FIELDS
Comma-separated list of columns to display.

SUBCOMMANDS

list cluster-id

Retrieve the list of read-only replicas for a cluster.
create cluster-id name
Create a read-only replica. Accepts --region, --size, and --private-network-uuid.
get cluster-id name
Retrieve information about a read-only replica.
delete cluster-id name
Delete a read-only replica. -f, --force skips the confirmation prompt.
connection cluster-id name
Retrieve the connection string, host, port, user, and password for a replica.
promote cluster-id name
Promote a read-only replica to become an independent primary cluster.

INSTALL

sudo dnf install doctl
copy
sudo pacman -S doctl
copy
sudo apk add doctl
copy
brew install doctl
copy
nix profile install nixpkgs#doctl
copy

CAVEATS

Replication is asynchronous, so a replica can lag behind the primary and serve slightly stale rows. promote is irreversible: the replica becomes an independent cluster, stops following the primary, and is billed as a full cluster from then on. Read replicas are not offered for every engine or plan (they are unavailable on the smallest shared-CPU tiers and on some engines), and each replica is billed at the price of its own size.

SEE ALSO

RESOURCES

Copied to clipboard
Kai