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 explain how to install TimeScaleDB on CentOS 7.
Setup firewalld
- Installing firewalld.
# sudo yum install firewalld
- Starting the firewalld service.
# sudo systemctl start firewalld
- Enabling the firewalld service.
# sudo systemctl enable firewalld
- Verify the status of firewalld.
# sudo systemctl status firewalld
Output
Install PostgreSQL
- Create a repository configuration file and find the
[base]
and[updates]
sections, add theexclude=postgresql*
line in both sections.
After adding the above configuration line, save and close the file.# sudo vi /etc/yum.repos.d/CentOS-Base.repo
Output
- Install the pgdg redhat repository.
# sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
- Install the PostgreSQL server using the following command.
# sudo yum -y install postgresql14-server
- Create a new PostgreSQL database cluster with
initdb
.
# sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
- Start PostgreSQL using
systemctl
command.# sudo systemctl start postgresql-14
- Enable PostgreSQL by running the below command.
# sudo systemctl enable postgresql-14
- Verify the PostgreSQL status.
# sudo systemctl status postgresql-14
Output
Install TimescaleDB
- Create a new repository file to install Timescale DB.
After adding the above configuration line, save and close the file.# sudo vi /etc/yum.repos.d/timescaledb.repo
Output
[timescale_timescaledb]
name=timescale_timescaledb
baseurl=https://packagecloud.io/timescale/timescaledb/el/7/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/timescale/timescaledb/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300 - Install TimescaleDB.
# sudo yum -y install timescaledb-2-postgresql-14
- Configuring the TImescaleDB.
# sudo timescaledb-tune --pg-config=/usr/pgsql-14/bin/pg_config --quiet --yes
Output
- Restart the PostgreSQL service after making the above changes.
# sudo systemctl restart postgresql-14.service
Verify the TimeScaleDB installation
- Connect to PostgreSQL, using the postgres user and create a database by name
test_db_idrive_compute
.
# sudo -u 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