In this tutorial, we will show you how to install TimescaleDB on Ubuntu 20.04 LTS. For those of you who didn’t know, TimescaleDB is a free, open-source, powerful database system powered by PostgreSQL. It is an extension of PostgreSQL and is specially designed to analyze time-series data with PostgreSQL. TimescaleDB offers the best of both NoSQL and relational database systems.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the TimescaleDB on Ubuntu 20.04 (Focal Fossa). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
- A server running one of the following operating systems: Ubuntu 20.04, 18.04, 16.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install TimescaleDB on Ubuntu 20.04 LTS Focal Fossa
Step 1. First, make sure that all your system packages are up-to-date by running the following
apt commands in the terminal.
sudo apt update sudo apt upgrade
Step 2. Installing PostgreSQL on Ubuntu 20.04.
Install the PostgreSQL package using the
sudo apt install postgresql-14
Once the installation is completed, log in to PostgreSQL and set the Postgres password:
su - postgres psql -c "alter user postgres with password 'your-strong-password'"
Step 3. Installing TimescaleDB on Ubuntu 20.04.
By default, TimescaleDB is not available on Ubuntu 20.04 base repository. Now run the following command to add the TimescaleDB repository on your Ubuntu system:
sh -c "echo 'deb https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -c -s) main' > /etc/apt/sources.list.d/timescaledb.list"
Finally, install TimescaleDB by running the following command:
sudo apt install timescaledb-2-postgresql-14
Once completed the installation, you need to configure your database so that you can use it. The easiest way to do this is to run the
sudo timescaledb-tune --quiet --yes
Next, restart the PostgreSQL service to apply the configuration changes:
sudo systemctl restart postgresql
Step 4. Create New Database TimescaleDB.
Now we create a new database, enable TimescaleDB, and connect the database to it:
su - postgres psql CREATE DATABASE idroot_db;
Next, connect to the
\c idroot_db CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
Finally, we connect to your newly created database:
psql -U postgres -h localhost -d idroot_db
Congratulations! You have successfully installed TimescaleDB. Thanks for using this tutorial for installing the TimescaleDB on Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you check the official TimescaleDB website.