Postgresql

Hardware requirements

CPU

At least 2 cores.

Memory

At least 2GB of RAM.

Disk

The recommended size is at least 1GB of disk.

Installation

Version 13 included in distribution and can be installed with the following command:

sudo apt-get install postgresql

Allow local oka user to be authenticated postgres-side:

# Replace 'ident' by 'md5' in /etc/postgresql/13/main/pg_hba.conf lines 86 and 88

sudo vim /etc/postgresql/<VERSION>/main/pg_hba.conf
# or
sed -i -E "s|host    all(.*)ident|host    all\1md5|g" /etc/postgresql/<VERSION>/main/pg_hba.conf

HowTo

  • Start the database service:

    sudo systemctl enable postgresql
    sudo systemctl restart postgresql
    

Note

The systemctl service can sometimes be name differently, such as postgresql-12. Check it with systemctl list-units | grep postgres.

Setting up

An oka user (protected by the okapwd password - use a strong password here) and an oka_db database must be created:

sudo -i -u postgres
    psql
        CREATE USER oka WITH PASSWORD 'okapwd';
        ALTER ROLE oka SET client_encoding TO 'utf8';
        ALTER ROLE oka SET timezone TO 'UTC';
        ALTER ROLE oka SET default_transaction_isolation TO 'read committed';
        CREATE DATABASE oka_db;
        GRANT ALL PRIVILEGES ON DATABASE oka_db TO oka;
        ctrl+d
    ctrl+d
sudo service postgresql restart

Warning

Starting from version 15, postgresql changed the default behavior of its public schema. Therefore, as Django requires access to this particular schema, you will need to give access to the database to the user you defined for OKA. This can be done by additionally applying the following commands for example:

GRANT ALL ON DATABASE oka_db TO oka;
ALTER DATABASE oka_db OWNER TO oka;