Welcome to today’s guide on how to install PostgreSQL 13 on openSUSE 15 Linux system. PostgreSQL is a powerful, open source object-relational database that has been in active development for over 30 years. PostgreSQL is known to be stable, reliable, feature robustness, and its top-notch performance.

PostgreSQL 13 includes significant improvements to its indexing and lookup system that benefit large databases, including space savings and performance gains for indexes, faster response times for queries that use aggregates or partitions, better query planning when using enhanced statistics, and more.

Install PostgreSQL 13 on openSUSE 15

Follow the steps in the next sections to install PostgreSQL 13 on openSUSE 15. This latest release of PostgreSQL is not available in the upstream OS repositories and we’ll have to add the Project official repository manually.

Step 1: Update System

Let’s start by ensuring openSUSE system is updated. Start by refreshing all repositories:

$ sudo zypper refresh
Retrieving repository 'openSUSE-Cloud' metadata ---------------------------------------------------------------------------------------------------------------[\]

New repository or package signing key received:

  Repository:       openSUSE-Cloud
  Key Name:         Cloud OBS Project <[email protected]>
  Key Fingerprint:  ACE2204F 418CFEB8 BF02ABF5 9338BC79 29DD7D91
  Key Created:      Fri May 15 13:49:33 2020
  Key Expires:      Sun Jul 24 13:49:33 2022
  Rpm Name:         gpg-pubkey-29dd7d91-5ebe9ded


Do you want to reject the key, trust temporarily, or trust always? [r/t/a/?] (r): a
Retrieving repository 'openSUSE-Cloud' metadata ............................................................................................................[done]
Building repository 'openSUSE-Cloud' cache .................................................................................................................[done]
Retrieving repository 'openSUSE-Non-Oss' metadata ..........................................................................................................[done]
Building repository 'openSUSE-Non-Oss' cache ...............................................................................................................[done]
Retrieving repository 'openSUSE-Oss' metadata ..............................................................................................................[done]
Building repository 'openSUSE-Oss' cache ...................................................................................................................[done]
Retrieving repository 'openSUSE-Update' metadata ...........................................................................................................[done]
Building repository 'openSUSE-Update' cache ................................................................................................................[done]
Retrieving repository 'openSUSE-Update-Non-Oss' metadata ...................................................................................................[done]
Building repository 'openSUSE-Update-Non-Oss' cache ........................................................................................................[done]
All repositories have been refreshed.

Trust all keys when asked to avoid more prompts.

Once this is done you can upgrade all OS packages.

sudo zypper update

Agree to installations:

....
The following product is going to be reinstalled:
  "openSUSE Leap 15.2"

The following 7 packages require a system reboot:
  dbus-1 glibc kernel-default-5.3.18-lp152.50.1 kernel-firmware libopenssl1_1 systemd udev

270 packages to upgrade, 144 new, 1 to remove.
Overall download size: 407.3 MiB. Already cached: 0 B. After the operation, additional 1.1 GiB will be used.

    Note: System reboot required.
Continue? [y/n/v/...? shows all options] (y): y

Wait for all packages to be downloaded and installed then do a system reboot.

sudo reboot

Step 2: Add PostgreSQL 13 repository

Wait for the system to be rebooted then login and add PostgreSQL 13 repository:

sudo zypper addrepo https://download.postgresql.org/pub/repos/zypp/repo/pgdg-sles-15-pg13.repo

Confirm the repository is added and available for use.

$ sudo zypper repos --uri | grep pgdg-13

If you get results from the output you should be ready to begin the installation of PostgreSQL 13 on openSUSE 15.

Step 3: Install PostgreSQL 13 openSUSE 15

With the repository configured and working you can start the installation of PostgreSQL 13 openSUSE 15.

sudo zypper install postgresql13-server

Trust the repository GPG keys to begin the installation.

...
New repository or package signing key received:

  Repository:       PostgreSQL 13 SLES 15.2 - x86_64
  Key Name:         PostgreSQL RPM Building Project <[email protected]>
  Key Fingerprint:  68C9E2B9 1A37D136 FE74D176 1F16D2E1 442DF0F8
  Key Created:      Tue Jan  8 21:59:38 2008
  Key Expires:      (does not expire)
  Subkey:           783AA47CD43F1AF8 2008-01-08 [does not expire]
  Rpm Name:         gpg-pubkey-442df0f8-4783f24a


Do you want to reject the key, trust temporarily, or trust always? [r/t/a/?] (r): a

Download and install PostgreSQL 13 packages with y key.

The following 3 NEW packages are going to be installed:
  postgresql13 postgresql13-libs postgresql13-server

3 new packages to install.
Overall download size: 16.0 MiB. Already cached: 0 B. After the operation, additional 75.4 MiB will be used.
Continue? [y/n/v/...? shows all options] (y): y

Step 4: Initialize and Start PostgreSQL 13 Service

PostgreSQL database initialization is required before you can use the database server.

$ sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
Initializing database ... OK

To start the database service with systemd run the following commands:

sudo systemctl start postgresql-13.service

Also enable the service to be started at system boot.

$ sudo systemctl enable postgresql-13.service
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-13.service → /usr/lib/systemd/system/postgresql-13.service.

The database data are located in below directory:

$ ls  /var/lib/pgsql/13/data/
PG_VERSION        pg_hba.conf    pg_snapshots  pg_xact
base              pg_ident.conf  pg_stat       postgresql.auto.conf
current_logfiles  pg_logical     pg_stat_tmp   postgresql.conf
global            pg_multixact   pg_subtrans   postmaster.opts
log               pg_notify      pg_tblspc     postmaster.pid
pg_commit_ts      pg_replslot    pg_twophase
pg_dynshmem       pg_serial      pg_wal

Confirm the service is in running state:

$ systemctl status postgresql-13
● postgresql-13.service - PostgreSQL 13 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vend>
   Active: active (running) since Tue 2020-12-01 12:19:49 UTC; 3min 24s ago
     Docs: https://www.postgresql.org/docs/13/static/
 Main PID: 1887 (postmaster)
    Tasks: 8
   CGroup: /system.slice/postgresql-13.service
           ├─1887 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
           ├─1888 postgres: logger
           ├─1890 postgres: checkpointer
           ├─1891 postgres: background writer
           ├─1892 postgres: walwriter
           ├─1893 postgres: autovacuum launcher
           ├─1894 postgres: stats collector
           └─1895 postgres: logical replication launcher

Dec 01 12:19:49 opensuse15 systemd[1]: Starting PostgreSQL 13 database server...
Dec 01 12:19:49 opensuse15 postmaster[1887]: 2020-12-01 12:19:49.337 UTC [1887]>
Dec 01 12:19:49 opensuse15 postmaster[1887]: 2020-12-01 12:19:49.337 UTC [1887]>
Dec 01 12:19:49 opensuse15 systemd[1]: Started PostgreSQL 13 database server.

Step 5: Set PostgreSQL admin user’s password

Update the PostgreSQL admin user password

$ sudo su - postgres
[email protected]:~> psql -c "alter user postgres with password 'StrongDBPassword'"
ALTER ROLE

Step 6: Enable remote Database connections (Optional)

If you want remote applications to connect to the database server you’ll need to edit the file:

$ sudo vim /var/lib/pgsql/13/data/postgresql.conf

Set the Listen address to your server IP address or “*” for all interfaces.

# line 59
listen_addresses = '192.168.10.10'

Also set PostgreSQL to accept remote connections

$ sudo vi /var/lib/pgsql/13/data/pg_hba.conf

# Accept from anywhere (not recommended)
host all all 0.0.0.0/0 md5

# Accept from trusted subnet (Recommended setting)
host all all 192.168.18.0/24 md5

Save the configurations then restart the database service to effect the changes.

sudo systemctl restart postgresql-13

Test connection using the psql command while providing username and optionally database name.

$ psql -U <dbuser> -h <serverip> -p 5432 <dbname>

We hope you enjoy running PostgreSQL 13 on openSUSE 15. Below are other PostgreSQL guides available in our website.

How To Install PostgreSQL 13 on Oracle Linux 8

How To Install PostgreSQL 13 on Amazon Linux 2

LEAVE A REPLY

Please enter your comment!
Please enter your name here