Self-Hosted TimescaleDB Installation & Configuration Guide This document provides step-by-step instructions to install and configure TimescaleDB on your self-hosted PostgreSQL server. We'll walk you through the necessary configurations to ensure a smooth setup.
Introduction TimescaleDB is an open-source PostgreSQL extension designed for running real-time analytics on time-series data. It provides automatic partitioning of data across time, making it ideal for IoT data, application metrics, financial data, and other time-series use cases.
This guide assumes you have already installed and configured PostgreSQL. If you need to install PostgreSQL first, refer to the PostgreSQL Database Setup Guide (opens new window) .
Prerequisites Before installing TimescaleDB, ensure you have:
PostgreSQL 14, 15, 16, 17, or 18 installed and running Root or sudo access (Linux/macOS) psql command-line client available Internet connection for package downloads Step 1: Install TimescaleDB Select your operating system below to see the installation instructions.
Install PostgreSQL (if not already installed) Update the package list and install prerequisites: sudo apt update
sudo apt install gnupg postgresql-common apt-transport-https lsb-release wget
1 2
Run the PostgreSQL package setup script: sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
1
Add the TimescaleDB repository: echo "deb https://packagecloud.io/timescale/timescaledb/ubuntu/ $( lsb_release -c -s ) main" | sudo tee /etc/apt/sources.list.d/timescaledb.list
1
Install the TimescaleDB GPG key: wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/timescaledb.gpg
1
Update your local repository list: Install TimescaleDB: sudo apt install timescaledb-2-postgresql-17 postgresql-client-17
1
Note
Replace 17 with your PostgreSQL version (14, 15, 16, or 18).
Tune your PostgreSQL instance for TimescaleDB: Restart PostgreSQL: sudo systemctl restart postgresql
1
Set the password for postgres user: Install PostgreSQL (if not already installed) Install the PostgreSQL repository: sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-$( rpm -E %{ rhel} ) -x86_64/pgdg-redhat-repo-latest.noarch.rpm
1
Add the TimescaleDB repository: sudo tee /etc/yum.repos.d/timescale_timescaledb.repo << EOL
[timescale_timescaledb]
name=timescale_timescaledb
baseurl=https://packagecloud.io/timescale/timescaledb/el/$( rpm -E %{ rhel} ) /\$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/timescale/timescaledb/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOL
1 2 3 4 5 6 7 8 9 10 11 12
Update your local repository list: Disable the built-in PostgreSQL module (RHEL 8+): sudo dnf -qy module disable postgresql
1
Install TimescaleDB: sudo yum install timescaledb-2-postgresql-17 postgresql17
1
Initialize the PostgreSQL instance: sudo /usr/pgsql-17/bin/postgresql-17-setup initdb
1
Tune your PostgreSQL instance for TimescaleDB: sudo timescaledb-tune --pg-config= /usr/pgsql-17/bin/pg_config
1
Enable and start PostgreSQL: sudo systemctl enable postgresql-17
sudo systemctl start postgresql-17
1 2
Set the password for postgres user: Install PostgreSQL (if not already installed) Install Homebrew (if not installed): /bin/bash -c "$( curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh) "
1
Install and start PostgreSQL: brew install postgresql@17
brew cleanup --prune-prefix
brew services start postgresql@17
1 2 3
Add PostgreSQL to your PATH: echo 'export PATH="/opt/homebrew/opt/postgresql@17/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
1 2
Add the TimescaleDB Homebrew tap: Install TimescaleDB: brew install timescaledb
1
Configure your database: timescaledb-tune --quiet --yes
1
Run the setup script to complete installation: $( brew --prefix ) /Cellar/timescaledb/$( brew list --versions timescaledb | awk '{print $2}' ) /bin/timescaledb_move.sh
1
Start the PostgreSQL service: brew services restart postgresql@17
1
Verify PostgreSQL is running: brew services list | grep postgresql
1
Set the password for your database user: Prerequisites OpenSSL v3.x installed Visual C++ Redistributable for Visual Studio 2015 or later Install PostgreSQL Download PostgreSQL from the official download page (opens new window) .
Run the installer and follow the installation wizard.
In the "Select Components" dialog, ensure Command Line Tools is checked.
Verify that pg_config is available in your PATH:
TIP
If not found, add C:\Program Files\PostgreSQL\<version>\bin to your system PATH.
Install TimescaleDB Download the latest TimescaleDB installer for your PostgreSQL version:
Unzip the downloaded file to your installation directory.
Navigate to the extracted folder, right-click setup.exe, and select Run as Administrator .
Complete the installation wizard. Accept the option to run timescaledb-tune when prompted.
Restart the PostgreSQL service:
Restart-Service postgresql-x64-17
1
Set the password for postgres user: Note
TimescaleDB HA (High Availability) is the most complete Docker image, including TimescaleDB Toolkit, PostGIS support, and Patroni.
Pull the Docker image: docker pull timescale/timescaledb-ha:pg17
1
Run the container: docker run -d \
--name timescaledb \
-p 5432 :5432 \
-v /your/local/data:/pgdata \
-e PGDATA = /pgdata \
-e POSTGRES_PASSWORD = your_password \
timescale/timescaledb-ha:pg17
1 2 3 4 5 6 7
WARNING
If port 5432 is in use, change to -p 5433:5432 and update connection strings accordingly.
Connect to PostgreSQL: psql -d "postgres://postgres:your_password@127.0.0.1:5432/postgres"
1
Or connect using the container's psql:
docker exec -it timescaledb psql -U postgres
1
Verify installation: Security: Bind to localhost only:
docker run -d \
--name timescaledb \
-p 127.0 .0.1:5432:5432 \
-v /your/local/data:/pgdata \
-e PGDATA = /pgdata \
-e POSTGRES_PASSWORD = your_password \
timescale/timescaledb-ha:pg17
1 2 3 4 5 6 7
Note
TimescaleDB Light is a lightweight Alpine-based image without TimescaleDB Toolkit or PostGIS support.
Pull the Docker image: docker pull timescale/timescaledb:latest-pg17
1
Run the container: docker run -d \
--name timescaledb \
-p 5432 :5432 \
-v /your/local/data:/pgdata \
-e PGDATA = /pgdata \
-e POSTGRES_PASSWORD = your_password \
timescale/timescaledb:latest-pg17
1 2 3 4 5 6 7
WARNING
If port 5432 is in use, change to -p 5433:5432 and update connection strings accordingly.
Connect to PostgreSQL: psql -d "postgres://postgres:your_password@127.0.0.1:5432/postgres"
1
Verify installation: Step 2: Enable TimescaleDB Extension After installation, enable TimescaleDB on your database:
Connect to your database: psql -d "postgres://username:password@host:port/database_name"
1
Add TimescaleDB to the database: CREATE EXTENSION IF NOT EXISTS timescaledb;
1
Check that TimescaleDB is installed: Expected output:
List of installed extensions
Name | Version | Default version | Schema | Description
---------------------+---------+-----------------+------------+---------------------------
plpgsql | 1.0 | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | 2.24.0 | 2.24.0 | public | Enables scalable inserts...
1 2 3 4 5
Step 3: Verify Installation Check TimescaleDB version SELECT * FROM timescaledb_version( ) ;
1
Check installed extensions SELECT extname, extversion FROM pg_extension WHERE extname = 'timescaledb' ;
1
Create a sample hypertable
CREATE TABLE sensor_data (
time TIMESTAMPTZ NOT NULL ,
sensor_id INTEGER NOT NULL ,
temperature DOUBLE PRECISION ,
humidity DOUBLE PRECISION
) ;
SELECT create_hypertable( 'sensor_data' , 'time' ) ;
INSERT INTO sensor_data ( time , sensor_id, temperature, humidity)
VALUES
( NOW ( ) , 1 , 22.5 , 45.0 ) ,
( NOW ( ) - INTERVAL '1 hour' , 1 , 21.8 , 46.2 ) ,
( NOW ( ) - INTERVAL '2 hours' , 1 , 20.5 , 48.1 ) ;
SELECT * FROM sensor_data ORDER BY time DESC ;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Post-Installation Configuration Tune PostgreSQL settings Run the TimescaleDB tuning tool:
This will optimize PostgreSQL settings for TimescaleDB workloads, including:
shared_preload_libraries shared_buffers work_mem maintenance_work_mem And other performance-critical parameters If timescaledb-tune did not add TimescaleDB to shared_preload_libraries, manually edit postgresql.conf:
shared_preload_libraries = 'timescaledb '
1
Restart PostgreSQL sudo systemctl restart postgresql
1
brew services restart postgresql@17
1
Restart-Service postgresql-x64-17
1
Troubleshooting Common Issues "extension timescaledb does not exist"
Ensure shared_preload_libraries = 'timescaledb' is set in postgresql.conf and restart PostgreSQL.
"could not load library timescaledb.dll" (Windows)
Ensure OpenSSL v3.x is installed and in your PATH.
Connection refused
Verify PostgreSQL is running:
sudo systemctl status postgresql
1
Permission denied
Ensure the PostgreSQL user has CREATEDB privileges:
ALTER USER postgres CREATEDB;
1
References Component Version TimescaleDB 2.24.0+ PostgreSQL 14, 15, 16, 17, 18 Docker Images pg14, pg15, pg16, pg17, pg18