Task:
Get PostgreSQL version and update.
Notes:
- For these instructions, we have version 13.14 PostgreSQL running on RHEL 8.6.x. We will upgrade PostgreSQL to the newest version (13.16 at the time of this writing), and upgrade the out-of-date OS to the lastest 8.9.x. Since we have a PostgreSQL replica, we'll upgrade the primary first, and then the secondary.
- For RockyOS, besides the kernel* exclusion, the repo list for exclude is likely baseOS and/or epel instead of redhat-releases.
IMPORTANT:
- Take VM cold snapshots or backup before performing.
- For any apps using this DB set, shut them down beforehand.The DBs need to be last shutdown and first up, with the primary DB node shutdown last and started up first.
1. Get the PostgreSQL version:
$ ssh myid@dbappliance.mindwatering.net
$ sudo su
(or)
$ pbrun su -
# su postgres -
bash-4.4$ psql -c 'SELECT version();'
version
---------------------
PostgreSQL 13.14 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 8.x.0 202xxxxx (Red Hat 8.6.0-xx), 64-bit
(1 row)
bash-4.4$ exit
2. OS Upgrade:
a. Check the yum.conf and dnf.conf files. We need to make sure kernel and release files can be upgraded. For example, we comment out, with #, the exclusion of the kernel and redhat-release packages below.
# vi /etc/yum.conf
[main]
# exclude=kernel* redhat-release* postgresql13-*
...
<esc>:wq (to save)
# vi /etc/dnf/dnf.conf
[main]
# exclude=kernel* redhat-release* postgresql13-*
...
<esc>:wq (to save)
b. Perform the upgrade:
# dnf update
<review and accept updates>
3. After the update, we can put the entries back to limit the updates. Re-edit the yum.conf and dnf.conf and remove the # before the exclude statement.
e.g. # exclude=kernel* redhat-release* postgresql13-* to exclude=kernel* redhat-release* postgresql13-*
4. Perform post-upgrade validation:
a. Verify w/in PostgreSQL the new version:
$ ssh myid@dbappliance.mindwatering.net
$ sudo su
(or)
$ pbrun su -
# su postgres -
bash-4.4$ psql -c 'SELECT version();'
version
---------------------
PostgreSQL 13.16 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 8.x.0 202xxxxx (Red Hat 8.9.0-xx), 64-bit
(1 row)
b. Verify primary DB replication:
(still on dbappliance as postgres user)
bash-4.4$ psql -c 'select * from pg_stat_replication;'
<view result>
e.g.
client_addr | state
10.10.3.1 | streaming
(1 row)
bash-4.4$ exit
# exit
$ exit
c. Verify replica DB replication:
$ ssh myid@dbappliancerep.mindwatering.net
$ sudo su
(or)
$ pbrun su -
# su postgres -
bash-4.4$ psql -c 'select * from pg_stat_wal_receiver;'
<view result, errors?>
- Failure:
< 0 rows> indicates an error
- Success:
<1 row>
pid | 156789
status | streaming
bash-4.4$ exit
# exit
$ exit
5. Remove the VM Snapshots (if applied).
6. Start back up any VMs/containers using the DB and its replica.
previous page
|