Skip to content

Commit

Permalink
instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
brettedw committed Dec 10, 2024
1 parent e2ffe0f commit e1ed4c7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions docs/database/CLUSTER_DB.MD
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ Spin up the Repo-Standby Cluster with:
### Promoting a Standby Cluster

Once a standby is stood up, it can be promoted to be the primary cluster. **Note: only do this if the existing primary has been shut down first.**
You can shutdown the primary cluster with this command:
`kubectl patch postgrescluster/<cluster-name> --type merge --patch '{"spec":{"shutdown": true}}'`
You can determine that the cluster is fully shutdown when there are no StatefulSet pods running for that cluster.

Promote the standby cluster by editing the [crunchy_standby.yaml](../../openshift/templates/crunchy_standby.yaml) to set the `standby` field to `false`.
You can determine that promotion has completed when the logs of the standby StatefulSet show a leader has been elected.

More details here: <https://access.crunchydata.com/documentation/postgres-operator/latest/architecture/disaster-recovery#promoting-a-standby-cluster>

Expand All @@ -66,8 +70,19 @@ More details here: <https://access.crunchydata.com/documentation/postgres-operat
The promoted standby cluster created it's own secrets for connecting to pgbouncer and it has created a new user in the database with the same name as the cluster. Ex. if the standby cluster is named "wps-crunchy-16-2024-12-10", the user will have the same name.
Once the standby has been promoted, the easiest way to update user privileges is to reassign table ownership from the old user to the new user.
`REASSIGN OWNED BY "<old-user>" TO "<new-user>";`

Once this is done, the deployment using the crunchy secrets will need to be updated. This can be done by manually editing the deployment YAML and changing all config that referenced the original crunchy secrets to the newly promoted standby cluster secrets. Once this is done, new pods should roll out successfully.
Use `\du` in psql to see users in the database.

Once this is done, the deployment using the crunchy secrets and cluster references will need to be updated. This can be done by manually editing the deployment YAML in the Openshift UI and changing all config that referenced the original crunchy cluster to the newly promoted standby cluster secrets. Once this is done, new pods should roll out successfully.

- Change to name of new cluster secret
- POSTGRES_READ_USER
- POSTGRES_WRITE_USER
- POSTGRES_PASSWORD
- POSTGRES_WRITE_HOST
- POSTGRES_READ_HOST
- POSTGRES_PORT
- Change to name of new cluster
- PATRONI_CLUSTER_NAME

## Cluster Restore From pg_dump

Expand Down

0 comments on commit e1ed4c7

Please sign in to comment.