How To Install TimescaleDB on AlmaLinux 9
In this tutorial, we will show you how to install TimescaleDB on AlmaLinux 9. For those of you who didn’t know, TimescaleDB, an open-source time-series database extension for PostgreSQL, is a powerful tool that offers scalability, performance, and flexibility.
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 TimescaleDB on AlmaLinux 9. You can follow the same instructions for CentOS and Rocky Linux or RHEL-based.
Prerequisites
- A server running one of the following operating systems: AlmaLinux 9.
- 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).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for TimescaleDB.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install TimescaleDB on AlmaLinux 9
Step 1. Before diving into the installation process, ensure your AlmaLinux 9 system is up-to-date. Run the following commands in your terminal:
sudo dnf update
Step 2. Installing PostgreSQL.
sudo dnf install postgresql-server postgresql-contrib
Initialize the PostgreSQL database:
sudo postgresql-setup --initdb
Start the PostgreSQL service:
sudo systemctl start postgresql
Enable the PostgreSQL service to start at boot:
sudo systemctl enable postgresql
Verify that PostgreSQL is running:
sudo systemctl status postgresql
You should see a message indicating that PostgreSQL is active and running.
Step 3. Installing TimescaleDB on AlmaLinux 9.
TimescaleDB maintains its own repository for easy installation. Let’s add it to your system:
sudo tee /etc/yum.repos.d/timescale_timescaledb.repo <<EOF [timescale_timescaledb] name=timescale_timescaledb baseurl=https://packagecloud.io/timescale/timescaledb/el/9/$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 EOF
Now install the TimescaleDB package using the following command below:
sudo dnf install timescaledb-postgresql-14
Initialize the TimescaleDB extension:
sudo timescaledb-tune --quiet --yes sudo systemctl restart postgresql sudo -u postgres psql -c "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;"
Verify that TimescaleDB is installed and working:
sudo -u postgres psql -c "SELECT * FROM timescaledb_information.timescaledb_version;"
Step 4. Create Database TimescaleDB.
For example, to create a new database named idroot
, you can run the following command:
createdb -U postgres idroot
Here, createdb
is the command to create a new database, -U postgres
specifies the PostgreSQL user to create the database, and idroot
is the name of the new database.
After running the above command, you can connect to the new database using the psql
command. For example, to connect to the idroot
database, you can run the following command:
psql -U postgres idroot
Here, psql
is the command to connect to a PostgreSQL database, -U postgres
specifies the PostgreSQL user to connect to the database, and idroot
is the name of the database to connect to.
Once you are connected to the new database, you can create tables and perform other operations as you would with any other PostgreSQL database.
Congratulations! You have successfully installed TimescaleDB. Thanks for using this tutorial for installing the TimescaleDB on your AlmaLinux 9 system. For additional help or useful information, we recommend you check the official TimescaleDB website.