Atlantic.Net Blog

How to Install TimescaleDB on Ubuntu 18.04

Hitesh Jethva
by Atlantic.Net (85posts) under VPS Hosting
0 Comments

There are two types of database systems: relational databases and NoSQL databases. Relational databases are used to store data and cannot process a large amount of time series data. NoSQL databases are especially useful for working with large sets of distributed data.

TimescaleDB is a free and open-source time-series database specially designed for scale, ease-of-use, and complex queries. TimescaleDB is an extension of PostgreSQL offering the best of both NoSQL and relational database systems. You can write millions of data points per second and store 100s of billions of rows and 10s of terabytes of data with TimescaleDB.

In this tutorial, we will explain how to install TimescaleDB on Ubuntu 18.04.

Prerequisites

  • A fresh Ubuntu 18.04 VPS on the Atlantic.Net Cloud Platform.
  • A root password configured on your server.

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server.  Create a new server, choosing Ubuntu 18.04 as the operating system with at least 1GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged into your Ubuntu 18.04 server, run the following command to update your base system with the latest available packages.

apt-get update -y

Step 2 – Install PostgreSQL

TimescaleDB is powered by PostgreSQL and used to analyze time-series data with a PostgreSQL query language, so you will need to install the PostgreSQL server 9.6 or later in your server.

You can install it by running the following command:

apt-get install postgresql-10 -y

After installing the PostgreSQL server, start the PostgreSQL service and enable it to start after system reboot with the following command:

systemctl start postgresql
systemctl enable postgresql

You can now verify the status of the PostgreSQL service with the following command:

systemctl status postgresql

You should see the following output:

By default, PostgreSQL is configured to login without a password, so it is recommended to set a password for the Postgres user.

To do so, log in with PostgreSQL user with the following command:

su - postgres

Next, set a password for the Postgres user with the following command:

psql -c "alter user postgres with password 'new-password'"

Next, exit from the PostgreSQL shell with the following command:

exit

Once you are done, you can proceed to the next step.

Step 3 – Install and Configure TimescaleDB

By default, TimescaleDB is not available in the Ubuntu 18.04 default repository, so you will need to add the repository for TimescaleDB. You can add it with the following command:

add-apt-repository ppa:timescale/timescaledb-ppa -y

Once the repository has been added, update the repository with the following command:

apt-get update -y

Finally, install TimescaleDB by running the following command:

apt-get install timescaledb-postgresql-10 -y

Once installed, you will need to edit your postgresql.conf file and include the TimescaleDB library.

nano /etc/postgresql/10/main/postgresql.conf

Add the following line at the end of the file:

shared_preload_libraries = 'timescaledb'

Save and close the file when you are finished. Then, restart the PostgreSQL service to apply the changes:

systemctl restart postgresql

Step 4 – Verify TimescaleDB Installation

At this point, TimescaleDB is installed and configured. It’s time to test the TimescaleDB database.

To do so, log in to PostgreSQL shell with the following command:

su - postgres
[email protected]:~$ psql

Next, create a new database named testdb with the following command:

postgres=# CREATE DATABASE timedb;

Next, connect to your database with the following command:

postgres=# \c timedb

Output:

You are now connected to database “timedb” as user “postgres”.

Finally, enable the TimescaleDB extension with the following command:

timedb=# CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;

You should get the following output:

The above output clearly indicates that the TimescaleDB is enabled with PostgreSQL.

Next, exit from the PostgreSQL shell with the following command:

\q
exit

Conclusion

Congratulations! You have successfully installed TimescaleDB on Ubuntu 18.04 server. You can now take advantage the key benefits TimescaleDB offers over traditional relational database systems. For more information, refer to the official documentation at TimescaleDB Doc. Get started with TimescaleDB today on Atlantic.Net VPS Hosting!

Get A Free To Use Cloud VPS

Free Tier Includes:
G2.1GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G2.1GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources