Recent

Saturday, January 20, 2018

Installing TimescaleDB on AWS

TimescaleDB is an open-source time-series database optimized for fast ingest and complex queries. It speaks "full SQL" and is correspondingly easy to use like a traditional relational database, yet scales in ways previously reserved for NoSQL databases.


I want to experiment with the database to see what performance benefits I could gain for real-time finance and IoT use cases.

Timescale offers a Docker container image but I wanted to deploy it to an AWS EC2 instance running Ubuntu Server 16.04. Timescale's official Linux installs had gaps that prevented me from successfully installing.

Here are the steps I took:

To prevent getting sudo: unable to resolve host ip<IP address> errors. Ensure the selected VPC has DNS hostnames enabled. Go to the "VPC Dashboard", select the VPC and click the "Action" button and select "Edit Hostnames". Select "Yes".


Manual Installation

1) SSH into the Ubuntu instance.

2) Add the Timescale Personal Package Archive to the repository:
sudo add-apt-repository ppa:timescale/timescaledb-ppa

3) TimescaleDB is dependant on Postgre 9.6, to prevent this installation error:
The following packages have unmet dependencies:
 timescaledb : Depends: postgresql-9.6 but it is not going to be installed
               Depends: postgresql-server-dev-9.6 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Add Postgre 9.6 to the repository do:
sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

4) Update the repositories:
sudo apt-get update

5) Everything is now setup for an error install:
sudo apt install timescaledb


Scripted Install

To fully script the installation you can run the following script on your EC2 instance.

#!/bin/bash

# Add the TimescaleDB Personal Package Archive
sudo add-apt-repository ppa:timescale/timescaledb-ppa

# Add Postgre 9.6 respository
sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

sudo apt-get update
sudo apt install timescaledb

#Modify permission of Postgre
sudo chmod 644 /etc/postgresql/9.6/main/postgresql.conf


Scripted Install as part the EC2 Launch Procedure

To install TimescaleDB as part of the EC2 launch procedure add the above script to the "User Data" in the "Advanced Details" during the "Configure Instance" stage. 

To complete the TimescaleDB setup follow the official guide: http://docs.timescale.com/v0.8/getting-started/installation/linux/installation-apt

4 comments: