Charmed PostgreSQL VM

Channel Revision Published Runs on
latest/stable 345 09 Nov 2023
Ubuntu 22.04 Ubuntu 20.04 Ubuntu 18.04 Ubuntu 16.04 Ubuntu 14.04
latest/stable 239 09 Feb 2022
Ubuntu 22.04 Ubuntu 20.04 Ubuntu 18.04 Ubuntu 16.04 Ubuntu 14.04
latest/stable 226 01 Apr 2021
Ubuntu 22.04 Ubuntu 20.04 Ubuntu 18.04 Ubuntu 16.04 Ubuntu 14.04
14/stable 468 11 Sep 2024
Ubuntu 22.04
14/stable 467 11 Sep 2024
Ubuntu 22.04
14/candidate 529 29 Nov 2024
Ubuntu 22.04
14/candidate 528 29 Nov 2024
Ubuntu 22.04
14/beta 529 28 Nov 2024
Ubuntu 22.04
14/beta 528 28 Nov 2024
Ubuntu 22.04
14/edge 535 13 Dec 2024
Ubuntu 22.04
14/edge 534 13 Dec 2024
Ubuntu 22.04
16/edge 527 27 Nov 2024
Ubuntu 24.04
16/edge 526 27 Nov 2024
Ubuntu 24.04
juju deploy postgresql --channel 14/stable
Show information

Platform:

Ubuntu
24.04 22.04 20.04 18.04 16.04 14.04

Set up clusters for cross-regional async replication

Cross-regional (or multi-server) asynchronous replication focuses on disaster recovery by distributing data across different servers.

This guide will show you the basics of initiating a cross-regional async setup using an example PostgreSQL deployment with two servers: one in Rome and one in Lisbon.

Prerequisites

Summary


Deploy

To deploy two clusters in different servers, create two juju models - one for the rome cluster, one for the lisbon cluster. In the example below, we use the config flag profile=testing to limit memory usage.

juju add-model rome 
juju add-model lisbon

juju switch rome # active model must correspond to cluster
juju deploy postgresql db1

juju switch lisbon 
juju deploy postgresql db2

Offer

Offer asynchronous replication in one of the clusters.

juju switch rome
juju offer db1:replication-offer replication-offer

Consume

Consume asynchronous replication on planned Standby cluster (Lisbon):

juju switch lisbon
juju consume rome.replication-offer
juju integrate replication-offer db2:replication

Promote or switchover a cluster

To define the primary cluster, use the create-replication action.

juju run -m rome db1/leader create-replication

To switchover and use lisbon as the primary instead, run

juju run -m lisbon db2/leader promote-to-primary

Scale a cluster

The two clusters work independently, which means that it’s possible to scale each cluster separately. The -m flag defines the target of this action, so it can be performed within any active model.

For example:

juju add-unit db1 -n 2 -m rome
juju add-unit db2 -n 2 -m lisbon

Note: Scaling is possible before and after the asynchronous replication is established/created.


Help improve this document in the forum (guidelines). Last updated 3 months ago.