If you are looking for a database for analyzing time series data, TimescaleDB might be the best option. TimescaleDB is based on PostgreSQL, but is tuned for speed and scalability when it comes to analyze time series data. It is an open source and free database system provided by the PostgreSQL developers. This database system is very useful when using a real-time monitoring system and a system that requires time series data. In this article we will learn how to install and configure TimescaleDB with PostgreSQL on Ubuntu 20.04.
To install and configure the TimescaleDB on Ubuntu 20.04, follow the steps below.
Before starting the setup, update ubuntu using the following command
$ sudo apt update
Before installing the TimescaleDB, we need to install postgresql. TimescalDB supports postgresql 9.6 or later. In this example, postgresql-12 is being installed. You can change the version as per your requirement.
$ sudo apt install postgresql-12
To verify the installation, connect to the postgresql with the user postgres as:
$ sudo su - postgres
To install timescaledb, you need to add timescaledb-ppa in the apt repository.
$ sudo add-apt-repository ppa:timescale/timescaledb-ppa
Now update the system to reflect the changes
$ sudo apt-get update
Now it's time to install timescaledb. In this example, I have used postgresql-12 for demonstration. You can select the version of postgresql available on your system.
$ sudo apt install timescaledb-postgresql-12
One the installation is completed, postgresql configuration setting needs to be updated for TimeScaleDB. For the valid configuration settings, press ‘y’ and hit enter.
$ sudo timescaledb-tune --quiet --yes
Restart the postgresql to reflect the changes.
$ sudo systemctl restart postgresql
If you want to make the configuration manually for TimescaleDB, edit the postgresql.conf file with an editor like vim.
$ sudo vim /etc/postgresql/12/main/postgresql.conf
Find the following line and make the changes as below.
shared_preload_libraries = ‘timescaledb’
Restart the postgresql service to update the changes.
$ sudo systemctl restart postgresql
Now the TimescaleDB installation can be confirmed by creating a new database or by using the existing PostgreSQL database.
Connect to postgresql and enter the psql shell using the command below.
$ sudo su - postgres
$ psql
Create an empty postgresql database. In this example, vitux_test_db is being used for a time series database. You can select the db name accordingly.
CREATE database vitux_test_db;
To add the TimescaleDB, connect to the database created previously.
postgres=# \c vitux_test_db
Now extend the postgreSQL database with TimescaleDB as:
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
The output shows that the TimescaleDB has been installed and working fine.
In this article, we learned how to install and configure TimescaleDB with PostgreSQL for time series data. Thank you for reading.
Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…
ISPConfig is an open-source control panel that allows users to manage multiple servers from a…
As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…
Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…
Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…
phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…