PostgreSQL Installation
Installation
RHEL Installation
- Disable the built-in PostgreSQL module
sudo dnf -qy module disable postgresql
- Enable the official PostgreSQL Yum Repository
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
- Install PostgreSQL
sudo dnf install postgresql15-server -y
- Initialize the PostgreSQL database
sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
- Start service on boot
sudo systemctl enable postgresql-15.service
- Start the service
sudo systemctl start postgresql-15.service
- Confirm that PostgreSQL is now started as a systemd service
sudo systemctl status postgresql-15.service
Ubuntu Installation
- Create the repository configuration
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
- Import the repository signing key, and update the package lists
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
- Update the package list
sudo apt-get update
- Install PostgreSQL with a specific release version, see Minimum requirements section for supported versions.
sudo apt-get -y install postgresql-15
- Confirm that PostgreSQL is now started as a systemd service
sudo systemctl status postgresql
Portal Dedicated user account and database
Create User Account
Create a new user for access from the Portal Dedicated.
The examples create a user portal_db_user
with a password of portal_db_password
, but should be customised as required.
The username and password will be required to configure the Portal Dedicated.
echo "CREATE USER portal_db_user WITH PASSWORD 'portal_db_password'" | sudo su postgres -c "psql"
Create Database
Creates a new database for storage of Portal Dedicated data.
The examples create a database portal
and is the recommended database name.
The -O
flag specified the owner of the database and should match the user account created above, the example uses portal_db_user
.
The database name will be required to configure the Portal Dedicated.
sudo su postgres -c 'createdb -O portal_db_user portal'
Configuration
The configuration files are located in different places depending on the OS and version of PostgreSQL.
- Ubuntu:
/etc/postgresql/15/main/
- Centos:
/var/lib/pgsql/15/data/
Enable remote access (optional)
Depending on the OS and version of PostgreSQL the database could be started with external access disabled.
If the database is not on the same server as the Portal Dedicated it will be required to edit the configuration to allow access.
Edit postgresql.conf
in the relevant configuration directory and add/update the following property:
listen_addresses = '*'
which allows access from all hosts.
Enable MD5 password authentication
By default MD5 hashed password authentication is disabled, but is required for Portal Dedicated connections.
To enable, edit pg_hba.conf
in the relevant configuration directory and:
- Change any mentions of ident to md5.
- Ensure the access methods for IPv4 connections is md5.
- Save and close the file.
Restart PostgreSQL with the new configuration:
Ubuntu
sudo systemctl restart postgresql
Rhel
sudo systemctl restart postgresql-15.service