Installing TimescaleDB
A guide to installing TimescaleDB for financial data on an Ubuntu server. TimescaleDB official docs: https://docs.timescale.com/
Fresh Install
If you want to install postgres by combining multiple drives into a logical volume (useful for cloud block storage, or large local database), please skip to the If using Block Storage (AWS / Digital Ocean / Etc) section. If you are installing locally, using a single drive, continue below:
Install PostgreSQL-14
Update apt, find latest version of Postgres and install
sudo apt update && sudo apt upgrade
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt -y update
sudo apt -y install postgresql-14
systemctl status postgresqlInstall TimescaleDB
sudo sh -c "echo 'deb [signed-by=/usr/share/keyrings/timescale.keyring] https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -c -s) main' > /etc/apt/sources.list.d/timescaledb.list"
wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/timescale.keyring
sudo apt-get update
sudo apt install timescaledb-2-postgresql-14
#Update Conf file to include Timescale parameters
sudo timescaledb-tune
#Restart postgres
sudo service postgresql restartEditing Configurations Files
Adding users and passwords
If using Block Storage (AWS / Digital Ocean / Etc)
Ignore this section if you don't want to combine multiple drives into one (useful for cloud block storage such as EBS).
Installing to existing PostgreSQL instance
Add the TimescaleDB third party repository and install TimescaleDB. This command downloads any required dependencies from the PostgreSQL repository:
There are a variety of settings that can be configured for your new database. At a minimum, you need to update your postgresql.conf file to include shared_preload_libraries = 'timescaledb'. The easiest way to get started is to run timescaledb-tune, which is installed by default when using apt:
Creating a Hypertable
Create a new hypertable with the same index and structure of an existing Postgres table, copy over the data, and set a compression policy:
Last updated