How To Install TimescaleDB on Ubuntu 20.04

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

In this guide, we will show you how to install TimescaleDB on Ubuntu 20.04

TimescaleDB is an open-source time series database developed by Timescale Inc. It written in C (programming language) and extends PostgreSQL. 

Timescale is the open-source relational database for time-series and analytics.

TimescaleDB supports standard SQL queries and is a relational database.

Additional SQL functions and table structures provide support for time series data oriented towards storage, performance, and analysis facilities for data-at-scale. Time-based data partitioning provides for improved query execution and performance when used for time oriented applications.More granular partition definition is achieved through the use of user defined attributes.

Install TimescaleDB

Just follow the steps below to get start with Timescaledb installation:

  • Update your system packages
sudo apt update && sudo apt upgrade
  • TimescaleDB requires PostgreSQL database. So We need to import  the postgresql repository signing key
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
  • Add PostgreSQL repository as shown:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
  • Then install postgresql
sudo apt update && sudo apt install postgresql-12
  • Set user password for PostgreSQL admin as shown below:
sudo su - postgres 
psql -c "alter user postgres with password 'Your_password_here'"
  • Add PPA repo of TimescaleDB
sudo add-apt-repository ppa:timescale/timescaledb-ppa
  • So Install TimescaleDB for PostgreSQL 12 as follows:
sudo apt install timescaledb-postgresql-12 -y
  • Then update your PostgreSQL configurations for TimescaleDB by running:
sudo timescaledb-tune --quiet --yes
  • OR update edit postgresql.conf file to load TimescaleDB libraries manually with :
vim /etc/postgresql/12/main/postgresql.conf

Then find the line below and change the value as shown below:

shared_preload_libraries = 'timescaledb'
  • Restart PostgreSQL
sudo systemctl restart postgresql 
  • Then verify if postgresql service was restarted successfully
sudo systemctl status postgresql 
  • Test TimescaleDB installation by connecting to PostgreSQL then create a test database called (e.g unixcop)
su - postgres
psql 
postgres=# CREATE database unixcop_db; 
CREATE DATABASE
  • Add timescaleDB by connecting to the test database we have created
\c unixcop_db
  • Also Extend the database with TimescaleDB by running the following command:
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;

Finally if you want to connect to your new database, run the command below:

psql -U postgres -h localhost -d unixcop_db

Conclusion

That’s it

In this article, we illustrated how to install TimescaleDB on Ubuntu 20.04

thanks

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
MQ-Jr
MQ-Jr
unixcop Admin

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook