You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: product_docs/docs/pgd/5/upgrades/upgrading_major_rolling.mdx
+68-53Lines changed: 68 additions & 53 deletions
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ redirects:
9
9
10
10
## Upgrading Postgres major versions
11
11
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.
13
13
14
14
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.
15
15
@@ -25,7 +25,7 @@ To do this, connect to one of the nodes using SSH and run the `pgd show-nodes` c
25
25
sudo -u postgres pgd show-nodes
26
26
```
27
27
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:
29
29
30
30
```bash
31
31
sudo -u postgres pgd show-groups
@@ -40,72 +40,80 @@ You now have enough information to determine your upgrade order, one subgroup at
40
40
### Perform the upgrade on each node
41
41
42
42
!!! 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.
44
44
!!!
45
45
46
46
Using the [preliminary order](#prepare-the-upgrade), perform the following steps on each node while connected via SSH:
47
47
48
48
***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`.
50
52
* Ensure that the expected major version is running.
51
53
52
54
53
55
***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.
* 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:
* 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:
78
79
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.
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.
79
89
80
90
***Migrate configuration to the new Postgres version**
81
91
* 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`— The main configuration file containing settings related to the database system.
93
+
*`postgresql.auto.conf`— Contains settings set by PostgreSQL, such as those modified by the `ALTER SYSTEM` command.
94
+
*`pg_hba.conf`— Manages client authentication, specifying which users can connect to which databases from which hosts.
95
+
* The entire `conf.d` directory (if present) — Allows for organizing configuration settings into separate files for better manageability.
90
96
* Copy these files and the `conf.d` directory to the new data directory you created for the upgraded version of PostgreSQL.
91
97
92
98
93
99
***Verify the Postgres service is inactive**
94
100
* 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.
97
103
98
104
99
105
***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.
102
109
103
110
104
111
***Verify upgrade feasibility**
105
112
* 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.
109
117
* Address any warnings or errors indicated by this check to ensure an uneventful transition to the new version.
110
118
111
119
@@ -117,23 +125,27 @@ Using the [preliminary order](#prepare-the-upgrade), perform the following steps
117
125
118
126
***Update the Postgres service configuration**
119
127
* 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`
121
130
* Refresh the system's service manager to apply these changes:
122
-
*`sudo systemctl daemon-reload`
131
+
132
+
`sudo systemctl daemon-reload`
123
133
124
134
125
135
***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`
128
139
129
140
130
141
***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`
132
145
133
146
134
147
***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.
137
149
* Remove the old version's data directory, `/opt/postgres/dataold`.
138
150
139
151
### Reconcile the upgrade with TPA
@@ -143,18 +155,21 @@ TPA needs to continue to manage the deployment effectively after all the nodes h
143
155
Follow these steps to update the configuration and redeploy the PGD cluster through TPA.
144
156
145
157
***Update the `config.yml`**
146
-
* Change the `config.yml` of the TPA-managed cluster to the new version.
***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>`
152
167
153
168
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.
154
169
155
170
## Worked example
156
171
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.
158
173
159
174
This example starts with kaboom.
160
175
@@ -164,7 +179,7 @@ Some steps of this process involve running commands as the Postgres owner. We re
164
179
165
180
### Confirm the current Postgres version
166
181
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:
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:
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.
316
331
!!!
317
332
318
333
### Verify upgrade feasibility
@@ -367,7 +382,7 @@ Checking for new cluster tablespace directories ok
367
382
```
368
383
369
384
!!! 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:
371
386
372
387
```bash
373
388
old cluster uses data checksums but the new one does not
@@ -506,7 +521,7 @@ sudo systemctl daemon-reload
506
521
507
522
### Restart Postgres
508
523
509
-
Start the modified Postgres service by running:
524
+
Start the modified Postgres service:
510
525
511
526
```bash
512
527
sudo systemctl start postgres
@@ -560,11 +575,11 @@ Upgrading the target node is now complete.
560
575
561
576
After completing the upgrade on kaboom, run the same steps on kaolin and kaftan.
562
577
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.
564
579
565
580
#### Check Postgres versions across the cluster
566
581
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:
568
583
569
584
```bash
570
585
sudo -u postgres pgd show-version
@@ -585,7 +600,7 @@ This output shows that all the nodes are successfully upgraded to the new Postgr
585
600
586
601
#### Reconcile with TPA
587
602
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.
589
604
590
605
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.
0 commit comments