Install PostgreSQL for Linux
Overview
You can install an official PostgreSQL installation:
- either direct on your Linux server
- or via a Docker image.
See the installation instructions below.
When installing CAST Imaging on Linux via Docker, CAST provides a database instance as a Docker image - see What the the database requirements? By default, this instance will be used by CAST Imaging for both analysis data and persistence data storage needs. However, you can alternatively choose to use your own PostgreSQL instance instead via the DB_MODE variable (see Installation variables) in the configuration.conf installation file. You are also free to install additional database instances post-install, for example to separate the storage of persistence data and analysis data on two separate instances.
Supported PostgreSQL releases
See What are the database requirements?
Installation
Direct install on Linux server
Your chosen Linux distribution may include a specific release of PostgreSQL by default but that may not be the latest available release nor one that is supported by CAST (see What are the database requirements?). CAST recommends PostgreSQL 18.x. You can use the official PostgreSQL repository for your distribution’s package manager system to install the specific release you need:
| Distribution | Instructions |
|---|---|
| Ubuntu via APT | PostgreSQL for Ubuntu |
| Debian via APT | PostgreSQL for Debian |
| Red Hat (RHEL/Rocky/Alma/CentOS) via Yum or DNF | PostgreSQL for Red Hat family distributions |
Server encoding
CAST Imaging requires the UTF8 encoding (see Requirements for the database user and encoding). On Linux, PostgreSQL takes the encoding from the environment locale when the cluster is created (LC_ALL, then LC_CTYPE, then LANG): a *.UTF-8 locale gives UTF8, but the C / POSIX locale, or no locale at all (common on minimal and cloud images), gives SQL_ASCII. Databases inherit the cluster encoding, so check it immediately after installation:
$ sudo -u postgres psql -c "SHOW server_encoding;"
If the result is not UTF8, recreate the cluster with an explicit encoding before it holds any data:
-
Debian/Ubuntu:
$ sudo pg_dropcluster --stop <version> main $ sudo pg_createcluster <version> main --encoding=UTF8 --locale=C --start -
Red Hat family (empty the data directory first if a cluster was already initialized):
$ sudo PGSETUP_INITDB_OPTIONS="--encoding=UTF8 --locale=C" /usr/pgsql-<version>/bin/postgresql-<version>-setup initdb
Install via a Docker image
See https://hub.docker.com/_/postgres for more information about how to install an official PostgreSQL image on Docker.