Skip to content

Setting up a remote database

Jo Cook edited this page Jan 29, 2021 · 4 revisions

Prerequisites:

  • A PostgreSQL host that you can connect to via port 5432 from the computer you're going to be installing the containers on
  • The credentials for the superuser (generally postgres)
  • Some method of running psql on the PostgreSQL host, either from your container host or your local pc
  • if running the containers via AWS ECS then use the following script to install psql on the host instance:

sudo amazon-linux-extras install postgresql12

Initial docker prep

  • Add the environment variable GEONETWORK_DB_HOST to your .env or .env-local file and set it to the address of the postgresql host
  • Comment out or remove the service definition for the postgres container from the docker-compose file you're using (and associated ecs-params.yml if using ECS)

PostgreSQL prep

Run the following steps to prep the template database, create a user, and install the necessary extensions:

Connect to the template1 database on your host (substitute in the host address, the same as you have for GEONETWORK_DB_HOST in .env or .env-local):

psql -h [host] -U postgres -d template1;

Enter the postgres user password at the prompt. Then run the following commands in psql, substituting 'yourgeonetworkpasswordinquotes' (the same as you have for POSTGRES_PASSWORD in .env or .env-local)

create user geonetwork with encrypted password [password] createdb;
create extension postgis;
create extension hstore;
create database geonetwork with template template1;
alter database geonetwork owner to geonetwork;

You should then be able to start up GeoNetwork with a fresh, blank database. The GeoNetwork start-up procedure, if it can connect to your database, will then populate the public schema with the necessary tables. If this doesn't happen, then it's likely that GeoNetwork could not connect to your database host. Check the log files if you are able to access them, otherwise work through the process of using psql to connect using the geonetwork user credentials from the computer you're running the containers on, and then the containers themselves (which might mean installing psql inside the container).

Clone this wiki locally