In this blog post we will look at the installation of PostgreSQL 14 on Fedora 38/37/36/35/34/33. PostgreSQL is a free to use and powerful relational database management system. PostgreSQL has been in active development for over 30 years and has earned a strong reputation in its reliability, robustness, and performance. As of this article update, the latest stable release of PostgreSQL is version 14.
This new release of PostgreSQL 14 comes with several new features designed to ease administration and development of intense data-driven applications. Some of the improvements are in complex data types support, logical replication, connection concurrency, query parallelism, and high-write workloads among many other features and improvements.
Some highlights in PostgreSQL 14 release
Below are some enhancements in PostgreSQL 14 database management system:
- Significant performance increases through parallel queries, heavily concurrent workloads, partitioned databases, logical replication, and vacuuming.
- JSON Conveniences and multiranges- enabling the representation of non-contiguous data ranges.
- OUT parameters can now be used to return data from stored procedures.
- Subscripting operators have been added to the jsonb and hstore types.
- Supports pipelined queries through libpq, which can significantly increase throughput over high-latency connections.
- Updates to B-tree indexes are more efficiently managed, resulting in less index bloat.
- Security enhancements
The PostgreSQL team provides and maintains a YUM repository with pre-built binary packages of PostgreSQL. We’ll be adding the repository to our Fedora system and install PostgreSQL 14 on Fedora Linux system. We’ll also cover installation of PostgreSQL 14 on Fedora Linux from the OS AppStream repositories.
Step 1 – Install PostgreSQL 14 on Fedora
You can choose option 1 or 2 to Install PostgreSQL 14 on Fedora;
Option 1 – Install PostgreSQL 14 from PostgreSQL repo
If PostgreSQL 14 packages are not in the AppStream repositories on your Fedora Linux system, you’ve to add PostgreSQL repositories manually to the system.
Add the PostgreSQL Yum Repository
Add PostgreSQL Yum Repository to your Fedora system by running the below command:
Fedora 38:
sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/F-38-x86_64/pgdg-fedora-repo-latest.noarch.rpm
Fedora 37:
sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/F-37-x86_64/pgdg-fedora-repo-latest.noarch.rpm
Fedora 36:
sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/F-36-x86_64/pgdg-fedora-repo-latest.noarch.rpm
Fedora 35:
sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/F-35-x86_64/pgdg-fedora-repo-latest.noarch.rpm
Fedora 34:
sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/F-34-x86_64/pgdg-fedora-repo-latest.noarch.rpm
Fedora 33:
sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/F-33-x86_64/pgdg-fedora-repo-latest.noarch.rpm
Fedora 32:
sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/F-32-x86_64/pgdg-fedora-repo-latest.noarch.rpm
When prompted to confirm installation, press the y key.
....
Transaction Summary
======================================================================================================================================================================================================
Install 1 Package
Total size: 10 k
Installed size: 11 k
Is this ok [y/N]: y
Install PostgreSQL 14 on Fedora
Once the PostgreSQL repository is added to your Fedora system, install PostgreSQL 14 Server and Client packages:
sudo dnf module reset postgresql -y
sudo dnf install vim postgresql14-server postgresql14
Option 2: Install PostgreSQL 14 on Fedora from OS AppStream repo
In newer releases of Fedora, PostgreSQL 14 is available in system provided AppStream module. Start by resetting PostgreSQL module:
sudo dnf module reset postgresql -y
Then enable the PostgreSQL 14 module with the commands below:
$ sudo dnf module enable postgresql:14
Dependencies resolved.
======================================================================================================================================================================================================
Package Architecture Version Repository Size
======================================================================================================================================================================================================
Enabling module streams:
postgresql 14
Transaction Summary
======================================================================================================================================================================================================
Is this ok [y/N]: y
Complete!
When done install PostgreSQL 14 on Fedora Linux system:
sudo dnf install vim postgresql-server postgresql
Accept all installation prompts:
....
Transaction Summary
======================================================================================================================================================================================================
Install 3 Packages
Total download size: 8.0 M
Installed size: 31 M
Is this ok [y/N]: y
Step 2 – Initialize PostgreSQL 14 database on Fedora
Run the commands below to initialize the database:
# AppStream PostgreSQL install
$ sudo postgresql-setup --initdb
* Initializing database in '/var/lib/pgsql/data'
* Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log
# PostgreSQL Repo install
$ sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
Initializing database ... OK
Start and enable postgresql database service:
# AppStream PostgreSQL install
$ sudo systemctl enable --now postgresql
# PostgreSQL Repo install
$ sudo systemctl enable --now postgresql-14
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-14.service → /usr/lib/systemd/system/postgresql-14.service.
Confirm service status.
$ systemctl status postgresql
## OR ##
$ systemctl status postgresql-14
● postgresql-14.service - PostgreSQL 14 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-14.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2021-11-17 10:19:09 UTC; 46s ago
Docs: https://www.postgresql.org/docs/14/static/
Process: 8167 ExecStartPre=/usr/pgsql-14/bin/postgresql-14-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 8172 (postmaster)
Tasks: 8 (limit: 2320)
Memory: 16.0M
CPU: 72ms
CGroup: /system.slice/postgresql-14.service
├─8172 /usr/pgsql-14/bin/postmaster -D /var/lib/pgsql/14/data/
├─8173 "postgres: logger " "" "" "" "" "" "" "" "" "" "" "" ""
├─8175 "postgres: checkpointer " "" "" "" "" "" "" "" "" "" ""
├─8176 "postgres: background writer " "" "" "" "" "" "" "" "" "
├─8177 "postgres: walwriter " "" "" "" "" "" "" "" "" "" "" "" "
├─8178 "postgres: autovacuum launcher " "" "" "" "" "" "" "" "" "
├─8179 "postgres: stats collector " "" "" "" "" "" "" "" "" "" ""
└─8180 "postgres: logical replication launcher " "" "" "" "" "" ""
Nov 17 13:17:28 fedora-35.lab systemd[1]: Starting PostgreSQL database server...
Nov 17 13:17:28 fedora-35.lab postmaster[38315]: 2021-11-17 13:17:28.564 EAT [38315] LOG: redirecting log output to logging collector process
Nov 17 13:17:28 fedora-35.lab postmaster[38315]: 2021-11-17 13:17:28.564 EAT [38315] HINT: Future log output will appear in directory "log".
Nov 17 13:17:28 fedora-35.lab systemd[1]: Started PostgreSQL database server.
Step 3 – Enable remote Access to PostgreSQL (Optional)
If you have remote applications connecting to this PostgreSQL server, you should allow postgresql service on firewalld if running.
sudo firewall-cmd --add-service=postgresql --permanent
sudo firewall-cmd --reload
Then edit the file /var/lib/pgsql/14/data/postgresql.conf
and set Listen address to your server IP address or “*” for all interfaces, or specific IP address/subnet.
# AppStream PostgreSQL install
$ sudo vim /var/lib/pgsql/data/postgresql.conf
listen_addresses = '*'
# PostgreSQL Repo install
$ sudo vi /var/lib/pgsql/14/data/postgresql.conf
listen_addresses = '*'
Also set PostgreSQL to accept remote connections from allowed hosts.
# AppStream PostgreSQL install
$ sudo vim /var/lib/pgsql/data/pg_hba.conf
# Accept from anywhere
host all all 0.0.0.0/0 md5
# Accept from trusted subnet
host all all 10.10.10.0/24 md5
# PostgreSQL Repo install
$ sudo vim /var/lib/pgsql/14/data/pg_hba.conf
# Accept from anywhere
host all all 0.0.0.0/0 md5
# Accept from trusted subnet
host all all 10.10.10.0/24 md5
Restart PostgreSQL 14 service after making the change.
sudo systemctl restart postgresql
## OR ##
sudo systemctl restart postgresql-14
Step 4 – Set PostgreSQL admin user’s (postgres) password
In this step you can set PostgreSQL admin user password.
sudo su - postgres
psql -c "alter user postgres with password 'StrongDBPassword'"
Replace StrongDBPassword with the new password for postgres user.
Step 5 – Install pgAdmin 4 Web Management
pgAdmin is a popular and feature rich Open Source administration and development platform for PostgreSQL database systems. Refer to our guide in the link below for a step-by-step installation:
Recommended books: