Skip to content

Commit 3c7c783

Browse files
Sync docs from Discourse (#606)
Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 75f7f01 commit 3c7c783

35 files changed

+1516
-404
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Connection pooling
2+
3+
Connection pooling is a strategy to reduce the amount of active connections and the costs of reopening connections. It requires maintaining a set of persistently opened connections, called a pool, that can be reused by clients.
4+
5+
Since PostgreSQL spawns separate processes for client connections, it can be beneficial in some use cases to maintain a client side connection pool rather than increase the database connection limits and resource consumption.
6+
7+
A way to achieve this with Charmed PostgreSQL is by integrating with the [PgBouncer charm](https://charmhub.io/pgbouncer?channel=1/stable).
8+
9+
## Increasing maximum allowed connections
10+
11+
If using PgBouncer is not enough to handle the connections load of your application, you can increase the amount of connections that PostgreSQL can open via the [`experimental_max_connections` config parameter](https://charmhub.io/postgresql/configurations#experimental_max_connections).
12+
13+
[note type="caution"]
14+
**Disclaimer:** Each connection opened by PostgreSQL spawns a new process, which is resource-intensive. Use this option as a last resort.
15+
16+
[Contact us](/t/11863) for more guidance about your use-case.
17+
[/note]

docs/how-to/h-async-integrate.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
This guide will show you how to integrate a client application with a cross-regional async setup using an example PostgreSQL deployment with two servers: one in Rome and one in Lisbon.
44

55
## Prerequisites
6-
* `juju v.3.4.2+`
6+
* Juju `v.3.4.2+`
7+
* Make sure your machine(s) fulfill the [system requirements](/t/11743)
8+
* See [supported target/source model relationships](/t/15412#substrate-dependencies).
79
* A cross-regional async replication setup
8-
* Refer to the page [How to set up clusters](/t/13991)
10+
* See [How to set up clusters](/t/13991)
911

1012
## Summary
1113
* [Configure database endpoints](#configure-database-endpoints)
@@ -53,7 +55,7 @@ juju switch app
5355
juju deploy postgresql-test-app
5456
juju deploy pgbouncer --channel 1/stable
5557

56-
juju integrate postgresql-test-app:first-database pgbouncer
58+
juju integrate postgresql-test-app:database pgbouncer
5759
juju integrate pgbouncer db1database
5860
```
5961

docs/how-to/h-async-remove-recover.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
This guide will cover how to manage clusters using an example PostgreSQL deployment with two servers: one in Rome and one in Lisbon.
44

55
## Prerequisites
6-
* `juju v.3.4.2+`
6+
* Juju `v.3.4.2+`
7+
* Make sure your machine(s) fulfill the [system requirements](/t/11743)
8+
* See [supported target/source model relationships](/t/15412#substrate-dependencies).
79
* A cross-regional async replication setup
8-
* Refer to the page [How to set up clusters](/t/13991)
10+
* See [How to set up clusters](/t/13991)
911

1012
## Summary
1113
* [Switchover](#switchover)

docs/how-to/h-async-set-up.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ Cross-regional (or multi-server) asynchronous replication focuses on disaster re
44

55
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.
66

7+
## Prerequisites
8+
* Juju `v.3.4.2+`
9+
* Make sure your machine(s) fulfill the [system requirements](/t/11743)
10+
* See [supported target/source model relationships](/t/15412#substrate-dependencies).
11+
712
## Summary
813
* [Deploy](#deploy)
914
* [Offer](#offer)
@@ -22,10 +27,10 @@ juju add-model rome
2227
juju add-model lisbon
2328

2429
juju switch rome # active model must correspond to cluster
25-
juju deploy postgresql db1 --channel=14/edge/async-replication --config profile=testing --base [email protected]
30+
juju deploy postgresql db1
2631

2732
juju switch lisbon
28-
juju deploy postgresql db2 --channel=14/edge/async-replication --config profile=testing --base [email protected]
33+
juju deploy postgresql db2
2934
```
3035

3136
## Offer
@@ -34,30 +39,30 @@ juju deploy postgresql db2 --channel=14/edge/async-replication --config profile=
3439

3540
```shell
3641
juju switch rome
37-
juju offer db1:async-primary async-primary
42+
juju offer db1:replication-offer replication-offer
3843
```
3944

4045
## Consume
4146

4247
Consume asynchronous replication on planned `Standby` cluster (Lisbon):
4348
```shell
4449
juju switch lisbon
45-
juju consume rome.async-primary
46-
juju integrate async-primary db2:async-replica
50+
juju consume rome.replication-offer
51+
juju integrate replication-offer db2:replication
4752
```
4853

4954
## Promote or switchover a cluster
5055

51-
To define the primary cluster, use the `promote-cluster` action.
56+
To define the primary cluster, use the `create-replication` action.
5257

5358
```shell
54-
juju run -m rome db1/leader promote-cluster
59+
juju run -m rome db1/leader create-replication
5560
```
5661

5762
To switchover and use `lisbon` as the primary instead, run
5863

5964
```shell
60-
juju run -m lisbon db2/leader promote-cluster force-promotion=true
65+
juju run -m lisbon db2/leader promote-to-primary
6166
```
6267

6368
## Scale a cluster

docs/how-to/h-async.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Cross-regional async replication
2+
3+
Cross-regional (or multi-server) asynchronous replication focuses on disaster recovery by distributing data across different servers.
4+
5+
## Prerequisites
6+
* Juju `v.3.4.2+`
7+
* Make sure your machine(s) fulfill the [system requirements](/t/11743)
8+
9+
### Substrate dependencies
10+
11+
The following table shows the source and target controller/model combinations that are currently supported:
12+
13+
| | AWS | GCP | Azure |
14+
|---|---|:---:|:---:|
15+
| AWS | | | |
16+
| GCP | | ![ check ] | ![ check ] |
17+
| Azure | | ![ check ] | ![ check ] |
18+
19+
## How-to guides
20+
21+
* [How to set up clusters for cross-regional async replication](/t/13991)
22+
* [How to integrate with a client application](/t/13992)
23+
* [How to remove or recover a cluster](/t/13994)
24+
* [Switchover](/t/13994#switchover)
25+
* [Detach](/t/13994#detach-a-cluster)
26+
* [Recover](/t/13994#recover-a-cluster)
27+
28+
<!-- BADGES -->
29+
[check]: https://img.shields.io/badge/%E2%9C%93-brightgreen
30+
[cross]: https://img.shields.io/badge/x-white

docs/how-to/h-deploy-airgapped.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Deploy in an offline or air-gapped environment
2+
3+
An air-gapped environment refers to a system that does not have access to the public internet.
4+
This guide goes through the special configuration steps for installing Charmed PostgreSQL VM in an air-gapped environment.
5+
6+
## Requirements
7+
8+
Canonical does not prescribe how you should set up your specific air-gapped environment. However, it is assumed that it meets the following conditions:
9+
10+
* A VM/hardware resources available for Juju.
11+
* DNS is configured to the local nameservers.
12+
* [Juju is configured](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#configure-juju) to use local air-gapped services.
13+
* The [`store-admin`](https://snapcraft.io/store-admin) tool is installed and configured.
14+
* [Air-gapped CharmHub](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/) is installed and running.
15+
* [Air-gapped Snap Store Proxy](https://documentation.ubuntu.com/snap-store-proxy/) is installed and running.
16+
* Local APT and LXD Images caches are reachable.
17+
18+
## Air-gapped setup summary
19+
20+
[1\. Export snaps and charms](#1-export-snaps-and-charms) <br>
21+
[2\. Transfer binary blobs](#2-transfer-binary-blobs) <br>
22+
[3\. Import snaps and charms](3-import-snaps-and-charms) <br>
23+
[4\. Deploy PostgreSQL](#4-deploy-postgresql)
24+
25+
## Air-gapped day-to-day example
26+
27+
### 1. Export snaps and charms
28+
Exporting VM SNAPs and Charms and are currently independent processes. The `store-admin` tool is designed to simplify the process.
29+
30+
Future improvements are planned to the `store-admin` tool so that it could potentially export all necessary SNAP resource(s) from the official SnapStore with Charms simultaneously. Other planned improvements include supporting the export of specific charm and resource by revisions ([PF-5369](https://warthogs.atlassian.net/browse/PF-5369), [PF-5185](https://warthogs.atlassian.net/browse/PF-5185)).
31+
32+
#### Charms
33+
The necessary charm(s) can be exported as bundle or independently (charm-by-charm). See the Snap Proxy documentation:
34+
* [Offline Charmhub configuration > Export charm bundle](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#export-charm-bundles)
35+
* [Offline Charmhub configuration > Export charms](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#export-charms)
36+
37+
The bundle export example:
38+
39+
<details>
40+
<summary><code>store-admin export bundle postgresql-bundle --channel=14/edge --series=jammy --arch=amd64</code></summary>
41+
42+
```
43+
Downloading postgresql-bundle revision 140 (14/edge)
44+
[####################################] 100%
45+
Downloading data-integrator revision 71 (edge)
46+
[####################################] 100%
47+
Downloading grafana-agent revision 286 (edge)
48+
[####################################] 100%
49+
Downloading landscape-client revision 69 (edge)
50+
[####################################] 100%
51+
Downloading pgbouncer revision 473 (1/edge)
52+
[####################################] 100%
53+
Downloading postgresql revision 487 (14/edge)
54+
[####################################] 100%
55+
Downloading postgresql-test-app revision 256 (edge)
56+
[####################################] 100%
57+
Downloading s3-integrator revision 59 (edge)
58+
[####################################] 100%
59+
Downloading self-signed-certificates revision 200 (edge)
60+
[####################################] 100%
61+
Downloading sysbench revision 78 (edge)
62+
[####################################] 100%
63+
Downloading ubuntu-advantage revision 113 (edge)
64+
[####################################] 100%
65+
Successfully exported charm bundle postgresql-bundle: /home/ubuntu/snap/store-admin/common/export/postgresql-bundle-20241008T083251.tar.gz
66+
67+
```
68+
</details>
69+
70+
#### SNAPs
71+
Usually charms require SNAPs (and some manually pin them). For the manual SNAP exports, follow the official Snap Store Proxy documentation: [Offline Charmhub configuration > Export SNAP](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#export-snap-resources). Data team is shipping the mapping [snap.yaml](https://github.com/canonical/postgresql-bundle/blob/main/releases/latest/) to the published [bundle.yaml](https://github.com/canonical/postgresql-bundle/blob/main/releases/latest/):
72+
73+
> **Warning**: always use snap.yaml and bundle.yaml from the same Git commit (to match each other)!
74+
75+
<details>
76+
<summary><code>store-admin export snaps --from-yaml snaps.yaml</code></summary>
77+
78+
```shell
79+
Downloading grafana-agent revision 51 (latest/stable amd64)
80+
[####################################] 100%
81+
Downloading grafana-agent revision 82 (latest/stable amd64)
82+
[####################################] 100%
83+
Downloading charmed-pgbouncer revision 16 (1/edge amd64)
84+
[####################################] 100%
85+
Downloading charmed-postgresql revision 133 (14/edge amd64)
86+
[####################################] 100%
87+
Downloading canonical-livepatch revision 282 (latest/stable amd64)
88+
[####################################] 100%
89+
Successfully exported snaps:
90+
grafana-agent: /home/ubuntu/snap/store-admin/common/export/grafana-agent-20241008T082122.tar.gz
91+
charmed-pgbouncer: /home/ubuntu/snap/store-admin/common/export/charmed-pgbouncer-20241008T082122.tar.gz
92+
charmed-postgresql: /home/ubuntu/snap/store-admin/common/export/charmed-postgresql-20241008T082122.tar.gz
93+
canonical-livepatch: /home/ubuntu/snap/store-admin/common/export/canonical-livepatch-20241008T082122.tar.gz
94+
```
95+
</details>
96+
97+
### 2. Transfer the binary blobs
98+
99+
Transfer the binary blobs using the way of your choice into the air-gapped environment.
100+
101+
```shell
102+
cp /home/ubuntu/snap/store-admin/common/export/*.tar.gz /media/usb/
103+
104+
...
105+
cp /media/usb/*.tar.gz /var/snap/snap-store-proxy/common/charms-to-push/
106+
```
107+
> **Note**: always check [checksum](https://en.wikipedia.org/wiki/Checksum) for the transferred blobs!
108+
109+
### 3. Import snaps and charms
110+
111+
Import the [snap](https://documentation.ubuntu.com/snap-store-proxy/en/airgap/#importing-pushing-snaps) and [charm](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#import-packages) blobs into local air-gapped CharmHub:
112+
113+
> **Note**: when importing machine charms that depend on a snap for functionality, you must first manually import the required snap.
114+
```shell
115+
sudo snap-store-proxy push-snap /var/snap/snap-store-proxy/common/snaps-to-push/charmed-postgresql-20241008T082122.tar.gz
116+
117+
sudo snap-store-proxy push-charm-bundle /var/snap/snap-store-proxy/common/charms-to-push/postgresql-bundle-20241003T104903.tar.gz
118+
```
119+
> **Note**: when [re-importing](https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/#import-packages) charms or importing other revisions, make sure to provide the `--push-channel-map`.
120+
121+
### 4. Deploy PostgreSQL
122+
123+
Deploy and operate Juju charms normally:
124+
```shell
125+
juju deploy postgresql
126+
```
127+
[note]
128+
**Note**: All the charms revisions and snap revisions deployed in the air-gapped environment must match the official CharmHub and SnapStore revisions.
129+
130+
Use [the official release notes](/t/11875) as a reference.
131+
[/note]
132+
133+
## Additional resources
134+
135+
* https://docs.ubuntu.com/snap-store-proxy/en/airgap
136+
* https://documentation.ubuntu.com/snap-store-proxy/
137+
* https://documentation.ubuntu.com/snap-store-proxy/en/airgap-charmhub/
138+
* https://ubuntu.com/kubernetes/docs/install-offline
139+
* [Charmed Kubeflow > Install in an airgapped environment](https://charmed-kubeflow.io/docs/install-in-airgapped-environment)
140+
* [Wikipedia > Air gap (networking)](https://en.wikipedia.org/wiki/Air_gap_(networking))
141+
142+
[note]
143+
If you expect having several concurrent connections frequently, it is highly recommended to deploy [PgBouncer](https://charmhub.io/pgbouncer?channel=1/stable) alongside PostgreSQL. For more information, read our explanation about [Connection pooling](/t/15777).
144+
[/note]

0 commit comments

Comments
 (0)