Skip to content

Commit 827e4f7

Browse files
authored
Merge pull request #5965 from EnterpriseDB/docs/pgd_reedit_14
Reedit of PGD major rolling upgrades topic
2 parents ec1f3a5 + 0bfa62c commit 827e4f7

File tree

1 file changed

+68
-53
lines changed

1 file changed

+68
-53
lines changed

product_docs/docs/pgd/5/upgrades/upgrading_major_rolling.mdx

Lines changed: 68 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ redirects:
99

1010
## Upgrading Postgres major versions
1111

12-
Upgrading a Postgres database's major version to access improved features, performance enhancements, and security updates is a common administration task. Doing the same for a Postgres Distributed (PGD) cluster deployed with Trusted Postgres Architect (TPA) is essentially the same process but performed as a rolling upgrade.
12+
Upgrading a Postgres database's major version to access improved features, performance enhancements, and security updates is a common administration task. Doing the same for an EDB Postgres Distributed (PGD) cluster deployed with Trusted Postgres Architect (TPA) is essentially the same process but performed as a rolling upgrade.
1313

1414
The rolling upgrade process allows updating individual cluster nodes to a new major Postgres version while maintaining cluster availability and operational continuity. This approach minimizes downtime and ensures data integrity by allowing the rest of the cluster to remain operational as each node is upgraded sequentially.
1515

@@ -25,7 +25,7 @@ To do this, connect to one of the nodes using SSH and run the `pgd show-nodes` c
2525
sudo -u postgres pgd show-nodes
2626
```
2727

28-
The `pgd show-nodes` command shows you all the nodes in your PGD cluster and the subgroup to which each node belongs. Then you want to find out which node is the write leader in each subgroup by running:
28+
The `pgd show-nodes` command shows you all the nodes in your PGD cluster and the subgroup to which each node belongs. Then you want to find out which node is the write leader in each subgroup:
2929

3030
```bash
3131
sudo -u postgres pgd show-groups
@@ -40,72 +40,80 @@ You now have enough information to determine your upgrade order, one subgroup at
4040
### Perform the upgrade on each node
4141

4242
!!! Note
43-
To help prevent data loss, ensure that your databases and configuration files are backed up before starting the upgrade process.
43+
To help prevent data loss, before starting the upgrade process, ensure that your databases and configuration files are backed up.
4444
!!!
4545

4646
Using the [preliminary order](#prepare-the-upgrade), perform the following steps on each node while connected via SSH:
4747

4848
* **Confirm the current Postgres version**
49-
* View versions from PGD by running `sudo -u postgres pgd show-version`.
49+
* View versions from PGD:
50+
51+
`sudo -u postgres pgd show-version`.
5052
* Ensure that the expected major version is running.
5153

5254

5355
* **Verify that the target node isn't the write leader**
54-
* Check whether the target node is the write leader for the group you're upgrading using `sudo -u postgres pgd show-groups`.
55-
* If the target node is the current write leader for the group/subgroup you're upgrading, perform a [planned switchover](#perform-a-planned-switchover) to another node.
56-
* `sudo -u postgres pgd switchover --group-name <group_name> --node-name <new_write_leader_node_name>`
56+
* Check whether the target node is the write leader for the group you're upgrading:
57+
58+
`sudo -u postgres pgd show-groups`
59+
* If the target node is the current write leader for the group/subgroup you're upgrading, perform a [planned switchover](#perform-a-planned-switchover) to another node:
60+
61+
`sudo -u postgres pgd switchover --group-name <group_name> --node-name <new_write_leader_node_name>`
5762

5863

5964
* **Stop Postgres on the target node**
60-
* Stop the Postgres service on the current node by running `sudo systemctl stop postgres`.
61-
* The target node is no longer actively participating as a node in the cluster.
65+
* Stop the Postgres service on the current node:
66+
67+
`sudo systemctl stop postgres`
68+
69+
The target node is no longer actively participating as a node in the cluster.
6270

6371

6472
* **Install PGD and utilities**
65-
* Install PGD and its utilities compatible with the Postgres version you're upgrading to.
66-
* `sudo apt install edb-bdr<new_pgd_version_number>-pg<new_postgres_version_number> edb-bdr-utilities`
73+
* Install PGD and its utilities compatible with the Postgres version you're upgrading to:
6774

75+
`sudo apt install edb-bdr<new_pgd_version_number>-pg<new_postgres_version_number> edb-bdr-utilities`
6876

6977
* **Initialize the new Postgres instance**
70-
* Create a directory that will house the database files for the new version of PostgreSQL:
71-
* `sudo mkdir -p /opt/postgres/datanew`
72-
* Ensure that user postgres has ownership permissions (chown) to the directory.
73-
* Initialize a new PostgreSQL database cluster in the directory you just created.
74-
* This step involves using the `initdb` command provided by the newly installed version of PostgreSQL.
75-
* Replace `<path_to_postgres_bin>` with the path to the bin directory of the newly installed PostgreSQL version: `sudo -u postgres <path_to_postgres_bin>/initdb -D /opt/postgres/datanew`.
76-
* You may need to run this command as the postgres user or another user with appropriate permissions.
77-
* Make sure to include the `--data-checksums` flag to ensure the cluster uses data checksums.
78+
* Create a directory to house the database files for the new version of PostgreSQL:
7879

80+
`sudo mkdir -p /opt/postgres/datanew`
81+
* Ensure that the user postgres has ownership permissions to the directory using `chown`.
82+
* Initialize a new PostgreSQL database cluster in the directory you just created. This step involves using the `initdb` command provided by the newly installed version of PostgreSQL. Include the `--data-checksums` flag to ensure the cluster uses data checksums.
83+
84+
`sudo -u postgres <path_to_postgres_bin>/initdb -D /opt/postgres/datanew --data-checksums`
85+
86+
Replace `<path_to_postgres_bin>` with the path to the bin directory of the newly installed PostgreSQL version.
87+
88+
You may need to run this command as the postgres user or another user with appropriate permissions.
7989

8090
* **Migrate configuration to the new Postgres version**
8191
* Locate the following configuration files in your current PostgreSQL data directory:
82-
* `postgresql.conf`
83-
* The main configuration file containing settings related to the database system.
84-
* `postgresql.auto.conf`
85-
* Contains settings set by PostgreSQL, such as those modified by the `ALTER SYSTEM` command.
86-
* `pg_hba.conf`
87-
* Manages client authentication, specifying which users can connect to which databases from which hosts.
88-
* The entire `conf.d` directory (if present)
89-
* Allows for organizing configuration settings into separate files for better manageability.
92+
* `postgresql.conf` &mdash; The main configuration file containing settings related to the database system.
93+
* `postgresql.auto.conf`&mdash; Contains settings set by PostgreSQL, such as those modified by the `ALTER SYSTEM` command.
94+
* `pg_hba.conf` &mdash; Manages client authentication, specifying which users can connect to which databases from which hosts.
95+
* The entire `conf.d` directory (if present) &mdash; Allows for organizing configuration settings into separate files for better manageability.
9096
* Copy these files and the `conf.d` directory to the new data directory you created for the upgraded version of PostgreSQL.
9197

9298

9399
* **Verify the Postgres service is inactive**
94100
* Before proceeding, it's important to ensure that no PostgreSQL processes are active for both the old and the new data directories. This verification step prevents any data corruption or conflicts during the upgrade process.
95-
* Use the `sudo systemctl status postgres` command to verify that Postgres was stopped.
96-
* If it isn't stopped, run `systemctl stop postgres` and verify again that it was stopped.
101+
102+
Use the `sudo systemctl status postgres` command to verify that Postgres was stopped. If it isn't stopped, run `systemctl stop postgres` and verify again that it was stopped.
97103

98104

99105
* **Swap PGDATA directories for version upgrade**
100-
* Rename `/opt/postgres/data` to `/opt/postgres/dataold` and `/opt/postgres/datanew` to `/opt/postgres/data`.
101-
* This step readies your system for the next crucial phase: running pg_upgrade to finalize the PostgreSQL version transition.
106+
* Rename `/opt/postgres/data` to `/opt/postgres/dataold` and `/opt/postgres/datanew` to `/opt/postgres/data`.
107+
108+
This step readies your system for the next crucial phase: running pg_upgrade to finalize the PostgreSQL version transition.
102109

103110

104111
* **Verify upgrade feasibility**
105112
* The `bdr_pg_upgrade` tool offers a `--check` option designed to perform a preliminary scan of your current setup, identifying any potential issues that could hinder the upgrade process.
106-
* You need to run this check from an upgrade directory with ownership given to user `postgres`, such as `/home/upgrade/`, so that the upgrade log files created by `bdr_pg_upgrade` can be stored.
107-
* To initiate the safety check, append the `--check` option to your `bdr_pg_upgrade` command.
108-
* This operation simulates the upgrade process without making any changes, providing insights into any compatibility issues, deprecated features, or configuration adjustments required for a successful upgrade.
113+
114+
You need to run this check from an upgrade directory with ownership given to user postgres, such as `/home/upgrade/`, so that the upgrade log files created by `bdr_pg_upgrade` can be stored. To initiate the safety check, append the `--check` option to your `bdr_pg_upgrade` command.
115+
116+
This operation simulates the upgrade process without making any changes, providing insights into any compatibility issues, deprecated features, or configuration adjustments required for a successful upgrade.
109117
* Address any warnings or errors indicated by this check to ensure an uneventful transition to the new version.
110118

111119

@@ -117,23 +125,27 @@ Using the [preliminary order](#prepare-the-upgrade), perform the following steps
117125

118126
* **Update the Postgres service configuration**
119127
* Update the service configuration to reflect the new PostgreSQL version by updating the version number in the `postgres.service` file:
120-
* `sudo sed -i -e 's/<old_version_number>/<new_version_number>/g' /etc/systemd/system/postgres.service`
128+
129+
`sudo sed -i -e 's/<old_version_number>/<new_version_number>/g' /etc/systemd/system/postgres.service`
121130
* Refresh the system's service manager to apply these changes:
122-
* `sudo systemctl daemon-reload`
131+
132+
`sudo systemctl daemon-reload`
123133

124134

125135
* **Restart Postgres**
126-
* Proceed to restart the PostgreSQL service.
127-
* `systemctl start postgres`
136+
* Proceed to restart the PostgreSQL service:
137+
138+
`systemctl start postgres`
128139

129140

130141
* **Validate the new Postgres version**
131-
* Verify that your PostgreSQL instance is now upgraded by again running `sudo -u postgres pgd show-version`.
142+
* Verify that your PostgreSQL instance is now upgraded:
143+
144+
`sudo -u postgres pgd show-version`
132145

133146

134147
* **Clean up post-upgrade**
135-
* Run `vacuumdb` with the `ANALYZE` option immediately after the upgrade but before introducing a heavy production load.
136-
* Running this command minimizes the immediate performance impact, preparing the database for more accurate testing.
148+
* Run `vacuumdb` with the `ANALYZE` option immediately after the upgrade but before introducing a heavy production load. Running this command minimizes the immediate performance impact, preparing the database for more accurate testing.
137149
* Remove the old version's data directory, `/opt/postgres/dataold`.
138150

139151
### Reconcile the upgrade with TPA
@@ -143,18 +155,21 @@ TPA needs to continue to manage the deployment effectively after all the nodes h
143155
Follow these steps to update the configuration and redeploy the PGD cluster through TPA.
144156

145157
* **Update the `config.yml`**
146-
* Change the `config.yml` of the TPA-managed cluster to the new version.
147-
* `cluster_vars: postgres_version: '<new_version_number>'`
158+
* Change the `config.yml` of the TPA-managed cluster to the new version:
159+
160+
`cluster_vars: postgres_version: '<new_version_number>'`
148161

149162

150163
* **Use `tpaexec` to redeploy the PGD cluster with the updated `config.yml`**
151-
* `tpaexec deploy <cluster_name>`
164+
* Use this the `deploy` option:
165+
166+
`tpaexec deploy <cluster_name>`
152167

153168
The worked example that follows shows upgrading the Postgres major version from 15 to 16 on a PGD 5 cluster deployed with TPA in detail.
154169

155170
## Worked example
156171

157-
This worked example starts with a TPA-managed PGD cluster deployed using the [AWS Quickstart](https://www.enterprisedb.com/docs/pgd/latest/quickstart/quick_start_aws/). The cluster has three nodes: kaboom, kaolin, and kaftan, all running Postges 15.
172+
This worked example starts with a TPA-managed PGD cluster deployed using the [AWS quick start](/pgd/latest/quickstart/quick_start_aws/). The cluster has three nodes: kaboom, kaolin, and kaftan, all running Postgres 15.
158173

159174
This example starts with kaboom.
160175

@@ -164,7 +179,7 @@ Some steps of this process involve running commands as the Postgres owner. We re
164179

165180
### Confirm the current Postgres version
166181

167-
SSH into kaboom to confirm the major version of Postgres is expected by running:
182+
SSH into kaboom to confirm the major version of Postgres is expected:
168183

169184
```bash
170185
sudo -u postgres pgd show-version
@@ -305,14 +320,14 @@ sudo mv /opt/postgres/datanew /opt/postgres/data
305320
```
306321

307322
!!! Important
308-
If something goes wrong at some point during the procedure, you may want to rollback/revert a node to the older major version. To do this, rename directories again so that the current data directory, `/opt/postgres/data`, becomes `/opt/postgres/datafailed` and the old data directory, `/opt/postgres/dataold`, becomes the current data directory:
323+
If something goes wrong at some point during the procedure, you may want to roll back/revert a node to the older major version. To do this, rename directories again so that the current data directory, `/opt/postgres/data`, becomes `/opt/postgres/datafailed` and the old data directory, `/opt/postgres/dataold`, becomes the current data directory:
309324

310325
```bash
311326
sudo mv /opt/postgres/data /opt/postgres/datafailed
312327
sudo mv /opt/postgres/dataold /opt/postgres/data
313328
```
314329

315-
This rolls back/reverts the node back to the previous major version of Postgres.
330+
This rolls back/reverts the node to the previous major version of Postgres.
316331
!!!
317332

318333
### Verify upgrade feasibility
@@ -367,7 +382,7 @@ Checking for new cluster tablespace directories ok
367382
```
368383

369384
!!! Note
370-
If you didn't initialize Postgres 16 with checksums using the `--data-checksums` option, but did initialize checksums with your Postgres 15 instance, an error tells you about the incompatibility:
385+
If you didn't initialize Postgres 16 with checksums using the `--data-checksums` option but did initialize checksums with your Postgres 15 instance, an error tells you about the incompatibility:
371386

372387
```bash
373388
old cluster uses data checksums but the new one does not
@@ -506,7 +521,7 @@ sudo systemctl daemon-reload
506521

507522
### Restart Postgres
508523

509-
Start the modified Postgres service by running:
524+
Start the modified Postgres service:
510525

511526
```bash
512527
sudo systemctl start postgres
@@ -560,11 +575,11 @@ Upgrading the target node is now complete.
560575

561576
After completing the upgrade on kaboom, run the same steps on kaolin and kaftan.
562577

563-
If you followed along with this example and kaftan is the write leader, to ensure availability, you must [perform a planned switchover](#perform-a-planned-switchover) to another, already upgraded node before running the upgrade steps on kaftan.
578+
If you followed along with this example and kaftan is the write leader, to ensure availability, you must [perform a planned switchover](#perform-a-planned-switchover) to another node that was already upgraded before running the upgrade steps on kaftan.
564579

565580
#### Check Postgres versions across the cluster
566581

567-
After completing the upgrade on all nodes, while connected to one of the nodes, you can once again check your versions:
582+
After completing the upgrade on all nodes, while connected to one of the nodes, you can check your versions again:
568583

569584
```bash
570585
sudo -u postgres pgd show-version
@@ -585,7 +600,7 @@ This output shows that all the nodes are successfully upgraded to the new Postgr
585600

586601
#### Reconcile with TPA
587602

588-
After all the nodes are upgraded, you still need to [reconcile](https://www.enterprisedb.com/docs/tpa/latest/reference/reconciling-local-changes/) the upgraded version of Postgres with TPA so you can continue to use TPA to manage the cluster in the future.
603+
After all the nodes are upgraded, you still need to [reconcile](/tpa/latest/reference/reconciling-local-changes/) the upgraded version of Postgres with TPA so you can continue to use TPA to manage the cluster in the future.
589604

590605
To do this, return to the command line where your TPA cluster directory resides. In this worked example, the TPA cluster directory is `/home/ubuntu/democluster` on the instance where you originally deployed the cluster using TPA.
591606

0 commit comments

Comments
 (0)