Installing PostgreSQL

COMP3311 22T3 ♢ Installing PostgreSQL ♢ [0/5]
❖ How to Install PostgreSQL @ Home

These slides (and accompanying video) describe


Pre-requisites:   make and gcc
COMP3311 22T3 ♢ Installing PostgreSQL ♢ [1/5]
❖ How to Install PostgreSQL @ Home (cont)

Summary:

And off you go ...
COMP3311 22T3 ♢ Installing PostgreSQL ♢ [2/5]
❖ How to Install PostgreSQL @ Home (cont)

My env script

# Set up environment for running PostgreSQL
# Must be "source"d from sh, bash, ksh, ...

# PostgreSQL needs more memory on MacOS
# sudo sysctl -w kern.sysv.shmmax=1073741824
# sudo sysctl -w kern.sysv.shmall=1073741824

PGHOME=/Users/jas/pgsql
export PGDATA=$PGHOME/data
export PGHOST=$PGDATA
export PGPORT=5432
export LD_LIBRARY_PATH=$PGHOME/lib
PATH=$PGHOME/bin:$PATH
pg1() { pg_ctl start -l $PGHOME/log ; }
pg0() { pg_ctl stop ; }

Obviously, adjust to suit your local conditions

COMP3311 22T3 ♢ Installing PostgreSQL ♢ [3/5]
❖ How to Install PostgreSQL @ Home (cont)


On MacOS, PostgreSQL grabs more memory than MacOS expects

If you have "Out of memory" (or somesuch) errors, you'll need

# PostgreSQL needs more memory
sudo sysctl -w kern.sysv.shmmax=1073741824
sudo sysctl -w kern.sysv.shmall=1073741824

You only need to run these commands once (if at all)

COMP3311 22T3 ♢ Installing PostgreSQL ♢ [4/5]
❖ How to Install PostgreSQL @ Home (cont)


What I edited in postgresql.conf

...
listen_addresses = ''    # what IP address(es) to listen on;
#port = 5432             # (change requires restart)
max_connections = 8      # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
unix_socket_directories = '/Users/jas/pgsql13/data'
                         # comma-separated list of directories
                         # (change requires restart)
...

The socket directory has to match the value of $PGDATA

COMP3311 22T3 ♢ Installing PostgreSQL ♢ [5/5]


Produced: 18 Sep 2022