Introduction
TimescaleDB is an open-source time series database developed by Timescale Inc. It is written in C and extends PostgreSQL.TimescaleDB supports standard SQL queries and is a relational database.
It uses full SQL and is just as easy to use as a traditional relational database. Also, TimeScaleDB multi-node works with distributed hyper tables, which automatically partition your data across multiple data nodes.
In this article, we will show how to install TimeScaleDB on Ubuntu 20.04.
Updating the system package
- Update and upgrade to the latest packages.
$ sudo apt-get update && sudo apt -y full-upgrade
- Ensure all the packages are up-to-date by rebooting the instance and login again.
$ [ -f /var/run/reboot-required ] && sudo reboot -f
Install PostgreSQL
Before installing TimeScaleDB, we need to have PostgreSQL installed.
- Import the repository signing key.
$ sudo curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
- Adding PostgreSQL apt repository.
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
- Update the package index and install PostgreSQL.
$ sudo apt-get update -y
$ sudo apt install postgresql-12 -y
- Setting the PostgreSQL admin user’s password.
$ sudo su - postgres
$ psql -c "alter user postgres with password 'TestDBPassword123'"
$ exit
Install TimescaleDB
- Adding the PPA packages to the system for Ubuntu OS 20.04.
$ sudo add-apt-repository ppa:timescale/timescaledb-ppa
- To re-confirm the repository packages are added, update the package.
$ sudo apt-get update
- Install TimescaleDB for PostgreSQL12.
$ sudo apt install timescaledb-postgresql-12 -y
- To update your config settings for TimescaleDB.
$ sudo timescaledb-tune --quiet --yes
Output
- Restart the PostgreSQL service after making the above changes.
$ sudo systemctl restart postgresql
$ sudo systemctl restart postgresql@12-main.service
- Check the PostgreSQL service by running the below command.
$ sudo systemctl status postgresql@12-main.service
Verify the TimeScaleDB installation
- Connect to PostgreSQL, using the postgres user and create a database by name
test_db_idrive_compute
.
$ sudo su - postgres
$ psql
CREATE database test_db_idrive_compute; -
Connect to the database.
\c test_db_idrive_compute
- Extend the database with TimescaleDB.
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
Output