How to Install TimescaleDB on Ubuntu

Ubuntu

Wondering how to install TimescaleDB on your Ubuntu system?

Data has always been a key element in computing and is constantly generated since the start of the computer age. When we use our electronic devices, the collected data is stored and used for different purposes by companies and businesses. 

However, the volume of data being generated these days is much more massive compared to the previous years. As you can imagine, managing and storing large amounts of data can be very difficult, thus, a number of different software are available for this purpose. 

When storing data, adding a timestamp to each packet can be helpful to keep track of data records and info. All software have their own sets of features and advantages but not all provide the timestamp feature. 

TimescaleDB is a type of database application that fortunately comes with this feature. If you are using Ubuntu and you want to know how to install TimescaleDB on Ubuntu 20.04 LTS, you have come to the right place as this tutorial will guide you through all the steps you need to take to achieve just that. 

So, let’s get started!

Step 1: Update your System.

Before you start installing TimescaleDB, you need to update your system repositories to get the latest versions of the software. To update, use the following command:

$ sudo apt upgrade 

Or

$ sudo apt update
Install TimescaleDB on Ubuntu

After your system is updated, you can move on to the next step. 

Step 2: Install PostgreSQL.

TimescaleDB is powered by PostgreSQL and is basically an extension of the said software. PostgreSQL (or Postgres in short) is a database management system that comes under the relational database category. 

Although relational database systems are slower in managing large amounts of sequential data, the extension TimescaleDB is specifically designed keeping timestamped data in mind.

For TimescaleDB to work, you need to install PostgreSQL 9.6 or a later version. As you have already updated your repository, you will get the latest version on installing. Do the following steps to successfully install the software.

  1. Start by opening the Command Terminal. You can achieve this by pressing Ctrl + Alt + T on your keyboard. 
  2. Next, import the PostgreSQL signing key by typing the following:
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
Install TimescaleDB on Ubuntu
  1. Once that’s done, add the repository using the following command.
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
Install TimescaleDB on Ubuntu
  1. In the next step, you will install the software by running the following command.
$ sudo apt install postgresql-12
installing the software
  1. After PostgreSQL is installed, you will need to set up a password to access it. You can do that using the following command.
$ sudo su - postgres
$ psql -c “alter user postgres with password your new password”

Now, the next step is to install TimescaleDB on your system.

Step 3: Install TimescaleDB.

TimescaleDB is not available in the Ubuntu repositories. You need to first add the repository in order to install the software. This can be achieved using the following command:

$ sh -c "echo 'deb https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -c -s) main' > /etc/apt/sources.list.d/timescaledb.list"
echo command

After adding TimescaleDB, install it by running the following command.

$ sudo apt install timescale-2-postgresql-12
Install TimescaleDB on Ubuntu

When you press Enter, you should see the progress of the installation process. When the installation is complete, run the following command to enable the configuration of the TimescaleDB database. 

$ sudo timescaledb-tune --quiet --yes

Restart PostgreSQL to apply the changes you just made.

$ sudo system restart postgresql

If you followed the steps correctly, then congratulations! You have learned how to install TimescaleDB on your system. In the next step, we’ll take a look at how you can add a new TimescaleDB database. 

Step 4: Add a New TimescaleDB Database.

With TimescaleDB installed on your system, all that’s left is to learn how to use it. Adding a TimescaleDB database will need the Command Terminal.

It should be noted that the commands can be very tricky to write and execute. It is advised that you carefully look at each command so that you do not make any syntax errors. Considering these are very large software, it might take some time to install them so please be patient. 

The following are the steps to create a new database:

  1. First, open the Command Terminal by pressing Ctrl + Alt + T on your keyboard.
  2. Next, to add a new TimescaleDb database, run the following commands.
$ su - postgres
$ psql
$ CREATE DATABASE idroot_db;
  1. Once that’s done, connect to the “idroot_db” database.
$ \c idroot_db
$ CREATE EXTENSION IFNOT EXISTS timescaledb CASCADE;
  1. Upon pressing Enter, you should see “TimescaleDB” written on your Terminal screen.
  2. Lastly, use this command to connect the newly created database.
$ psql -U postgres -h localhost -d idroot_db  

With this, you are done with installing and doing the basic configuration of TimescaleDB on your Ubuntu system. Speaking of timestamps, did you know that there is a $time command in Linux? 

While using the Command Terminal on Linux, users usually carry out multiple tasks and processes using commands. In case there is a process being repeated, writing the same commands over and over is time-consuming. To make life easier, users make use of scripts. 

Scripts are files that contain commands being executed sequentially. You can use these scripts instead of writing the same commands. To check the optimization of these scripts, we use the $time command. $time tells us the duration in which the script will be executed. 

If you want to know how it works in more detail, click on the link above. It will lead you to a comprehensive guide on $time

This was a tutorial on how to install TimesaleDB on Ubuntu. PostgreSQL and TimescaleDB, are both powerful software that can surely fulfill your needs. We hope that we were able to help you out and now you are enjoying the utilities of TimescaleDB. If you have any queries, let us know in the comment section below.

If this guide helped you, please share it. 🙂

Leave a Reply

Your email address will not be published.

Previous Post
Ungroup Icons in Taskbar on Windows 11

How to Ungroup Icons in Taskbar on Windows 11

Next Post
ubuntu

How to Install Liquorix Kernel on Ubuntu 20.04

Related Posts