Database Setup

Attention

You must have a properly configured Postgres installation for this to work. If you have a fresh install of Postgres on Ubuntu then you may want to configure the postgres user password to complete the postgres setup

Install PostgreSQL

Please refer to the PostgreSQL documentation on how to install and configure it.

Create Database

If you have existing Postgres authentication:

createdb datacube

or specify connection details manually:

createdb -h <hostname> -U <username> datacube

Note

You can also delete the database by running dropdb datacube. This step is not reversible.

Create Configuration File

Datacube looks for a configuration file in ~/.datacube.conf or in the location specified by the DATACUBE_CONFIG_PATH environment variable. The file has this format:

[datacube]
db_database: datacube

# A blank host will use a local socket. Specify a hostname (such as localhost) to use TCP.
db_hostname:

# Credentials are optional: you might have other Postgres authentication configured.
# The default username otherwise is the current user id.
# db_username:
# db_password:

Uncomment and fill in lines as required.

Alternately, you can configure the ODC connection to Postgres using environment variables:

DB_HOSTNAME DB_USERNAME DB_PASSWORD DB_DATABASE

See also runtime-config-doc

Initialise the Database Schema

The datacube system init tool can create and populate the Data Cube database schema

datacube -v system init

datacube system

Initialise the database

datacube system [OPTIONS]

Options

--default-types, --no-default-types

Add default types? (default: true)

--init-users, --no-init-users

Include user roles and grants. (default: true)

--recreate-views, --no-recreate-views

Recreate dynamic views

--rebuild, --no-rebuild

Rebuild all dynamic fields (caution: slow)

--lock-table, --no-lock-table

Allow table to be locked (eg. while creating missing indexes)