PostgreSQL + TimescaleDB Install (Alongside Existing Versions)
This documents the exact steps performed to install PostgreSQL 18 alongside an existing PostgreSQL 13 instance, configure it to use /dbdrive, run on port 5433, and enable TimescaleDB.
While this doc is specific to PSQL 18 and 13, you can use it for any version.
Initial State
Existing clusters:
sudo pg_lsclusters
Output:
13 main 5432 online /dbdrive/postgresql/13/main
14 main 5433 down,binaries_missing
18 main 5433 down /var/lib/postgresql/18/main
Desired Version Not Found
If the desired version (i.e. 18) isn't shown in the ls clusters output, then you should install it with the following commands:
sudo apt update
sudo apt install postgresql-18 postgresql-client-18
1. Remove Broken PostgreSQL 14 Cluster (if applicable)
sudo pg_dropcluster 14 main --stop
Verify:
sudo pg_lsclusters
2. Remove Default PostgreSQL 18 Cluster (Wrong Data Directory)
The default PG18 cluster was using /var/lib/postgresql/18/main.
It was removed to recreate it on /dbdrive.
sudo pg_dropcluster 18 main --stop
Verify only PG13 remains:
sudo pg_lsclusters
3. Create PostgreSQL 18 Cluster on /dbdrive
Create directory:
sudo mkdir -p /dbdrive/postgresql/18/main
sudo chown -R postgres:postgres /dbdrive/postgresql/18
Create cluster with custom data directory and port 5433:
sudo pg_createcluster 18 main \
--datadir=/dbdrive/postgresql/18/main \
--port=5433
Start PostgreSQL 18:
sudo pg_ctlcluster 18 main start
Verify:
sudo pg_lsclusters
Expected result:
13 main 5432 online /dbdrive/postgresql/13/main
18 main 5433 online /dbdrive/postgresql/18/main
4. Install TimescaleDB for PostgreSQL 18
sudo apt install timescaledb-2-postgresql-18
5. Enable TimescaleDB Preload Library
Edit PostgreSQL 18 configuration:
sudo nano /etc/postgresql/18/main/postgresql.conf
Set:
shared_preload_libraries = 'timescaledb'
Save and exit.
6. Restart PostgreSQL 18
sudo pg_ctlcluster 18 main restart
Verify:
sudo pg_lsclusters
7. TimescaleDB Tune
sudo timescaledb-tune
8. Create GQC User
CREATE ROLE gqc WITH LOGIN PASSWORD 'your_password_here' CREATEDB;
Final Architecture
| Version | Port | Data Directory |
|---|---|---|
| 13 | 5432 | /dbdrive/postgresql/13/main |
| 18 | 5433 | /dbdrive/postgresql/18/main |
PostgreSQL 18 is now:
- Installed side-by-side with PostgreSQL 13
- Running on port 5433
- Using
/dbdrive - TimescaleDB installed
shared_preload_librariesconfigured- Restarted and operational