Installing the postgres 15.x client on Amazon Linux 2
If you are using a Amazon Linux 2 based Ec2 instance, to install and run postgresql tools like psql and pg_dump, today the highest versions of postgres tools available from the repository is postgres 14. You can check the currently available versions using the following command
amazon-linux-extras | grep -i postgre
This command will list versions postgres 10 through 14.
You can enable the Redhat repositories for postgres on your amazon linux 2 host, and install the postgres 15.x client from those repositories. The steps are as follows.
Upgrade to the latest version of amazon linux 2 (Optional)
If you already have a postgres package installed consider removing it.
Enable the postgres repo for redhat linux
create a new file /etc/yum.repos.d/pgdg.repo
Add the following lines to pgdg.repo
[pgdg15]
name=PostgreSQL 15 for Redhat Linux - x86_64
baseurl=https://download.postgresql.org/pub/repos/yum/15/redhat/rhel-7.10-x86_64
enabled=1
gpgcheck=0
sudo yum makecache
sudo yum repolist (ensure that pgdg15 shows as a repository)
sudo yum install libzstd
sudo yum --disablerepo="*" --enablerepo="pgdg15" install postgresql15-15.3-1PGDG.rhel7 (To get postgres 15.3)
Now you should have 15.3 versions of psql and pg_dump etc