---
title: "How to Install TimescaleDB on AWS"
published: 2024-07-16T08:36:50.000-04:00
updated: 2024-07-16T08:36:49.000-04:00
excerpt: "A walkthrough on installing TimescaleDB on AWS with hardware sizing recommendations."
tags: Tutorials, AWS, PostgreSQL, Blog
authors: Juan Jose
---

> **TimescaleDB is now Tiger Data.**

[TimescaleDB](https://docs.timescale.com/) is a powerful, open-source database built on top of PostgreSQL to efficiently manage time-series data, events, and analytics. 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. 

This guide will walk you through setting up TimescaleDB on Amazon Web Services (AWS), ensuring you have a scalable and high-performance database ready to handle your time-series data needs.

What you'll learn:

-   How to get started with AWS
-   Setting up your EC2 instance
-   Installing TimescaleDB
-   Configuring PostgreSQL
-   Using TimescaleDB

## Getting Started With AWS and TimescaleDB

First, head over to [AWS](https://aws.amazon.com/) and create your AWS account. Once you've logged into the AWS console, you'll see a dashboard similar to this:

![AWS dashboard](https://timescale.ghost.io/blog/content/images/2024/07/0-aws.png)

### Launching an EC2 instance

**1\. Navigate to EC2**: Click on the 'Services' tab in the top left corner and select 'EC2' from the panel of AWS services.

![Console page that lists AWS services](https://timescale.ghost.io/blog/content/images/2024/07/1-console.png)

**2\. Launch instance:** Click on 'Launch Instance' to open the Amazon Machine Image (AMI) selection page.

![The AWS EC2 dashboard page with the button 'Launch instance' framed by a green box](https://timescale.ghost.io/blog/content/images/2024/07/2-ec2.png)

**3\. Choose an AMI**: Begin by setting up the OS Image you're going to use. In this case, select the 'Ubuntu Server 20.04 LTS' image, as TimescaleDB supports this version.

![The 'Launch an instance' page with a green frame about Ubuntu and the Amazon Machine Image options](https://timescale.ghost.io/blog/content/images/2024/07/3-ami.png)

### Setting up your instance

For this tutorial, we will use a minimal configuration for simplicity, but for production, consider using a `r5.4xlarge` instance with the following EBS volumes:

-   **WAL**: gp2, 350 GB (higher IOPS recommended)
-   **Data:** gp2, 5 TB

**1. Instance type**: Select the `t2.micro` instance type.

![The instance dropdown menu on the AWS console](https://timescale.ghost.io/blog/content/images/2024/07/4-instance-type.png)

**2\. Key pair:** Create a new key pair named `timescale` or use an existing one. Download the key pair and save it securely. The file extension should be `.pem`.

**3\. Launch instance:** Finally, click on ‘Launch Instance’.

**4\. Instance status:** Wait for the instance to initialize. Click on the instance ID to view its details.

![A yellow frame around the instance ID in AWS's Instances page](https://timescale.ghost.io/blog/content/images/2024/07/5-launched.png)

### Connecting to your EC2 instance

1\. Select your instance, and click on the Connect button. A dialog will open.

2\. **SSH command**: Head to the "SSH client" tab. Follow the instructions there. Find the command in the details and copy it to your clipboard. In this case, my full command is: 

```
ssh -i "timescale.pem" ubuntu@ec2-34-202-235-225.compute-1.amazonaws.com
```

![The Connect to instance page](https://timescale.ghost.io/blog/content/images/2024/07/6-ssh.png)

3\. **Set file permissions**: On your local machine, navigate to the directory containing the `.pem` file and set the correct permissions:   

```bash
sudo chmod 400 timescale.pem
```

4\. **Connect via SSH**: Use the copied SSH command to connect to your instance.

```bash
ssh -i "timescale.pem" ubuntu@ec2-34-202-235-225.compute-1.amazonaws.com
```

![The command output](https://timescale.ghost.io/blog/content/images/2024/07/7-console-1.png)

### Installing TimescaleDB

1. **Add TimescaleDB PPA:**

```bash
sudo apt install gnupg postgresql-common apt-transport-https lsb-release wget

sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

echo "deb https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -c -s) main" | sudo tee /etc/apt/sources.list.d/timescaledb.list

wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/timescaledb.gpg

sudo apt update
```

![The command output](https://timescale.ghost.io/blog/content/images/2024/07/8-console-2.png)

2\. **Install TimescaleDB:**

```bash
sudo apt install timescaledb-2-postgresql-16 postgresql-client
```

### Configuring PostgreSQL

1\. **Check the PostgreSQL version (ensure it shows `psql (PostgreSQL) 16.x`):**

```bash
psql --version
```

💡

[If you need help installing psql, here's a step-by-step guide for different operating systems](https://timescale.ghost.io/blog/how-to-install-psql-on-mac-ubuntu-debian-windows/).

![The command output](https://timescale.ghost.io/blog/content/images/2024/07/9-postgre.png)

2\. **Modify configuration:**

```bash
cd /etc/postgresql/16/main
sudo chmod 644 postgresql.conf
nano postgresql.conf
```

![The command output](https://timescale.ghost.io/blog/content/images/2024/07/10-nano.png)

3\. **Update postgresql.conf:**

Set `listen_addresses` to `'*'`:

```plaintext
listen_addresses = '*'
```

Set `shared_preload_libraries` to `timescaledb`:

```plaintext
shared_preload_libraries = 'timescaledb'
```

Save and exit the editor.

![The command output](https://timescale.ghost.io/blog/content/images/2024/07/11-update.png)

4.  **Tune PostgreSQL**:

```bash
sudo timescaledb-tune
```

![The command output](https://timescale.ghost.io/blog/content/images/2024/07/12-tune.png)

💡

[Need more tips to optimize your PostgreSQL performance? Check our guides](https://www.timescale.com/learn/postgresql-performance-tuning-key-parameters).

  

5\. **Restart PostgreSQL:**

```bash
sudo systemctl restart postgresql
```

6\. **Switch to PostgreSQL user:**

```bash
sudo su - postgres
```

## Using TimescaleDB

1\. **Access PostgreSQL:**

```sh
psql -U postgres
```

2\. **Create database:**

```sql
CREATE DATABASE tutorial;
```

3\. **Connect to the database:**

```sh
\c tutorial
```

4\. **Initialize TimescaleDB extension:**

```sql
CREATE EXTENSION IF NOT EXISTS timescaledb;
```

5\. **Create a hypertable:**

```sql
CREATE TABLE conditions (
    time        TIMESTAMPTZ       NOT NULL,
    location    TEXT              NOT NULL,
    temperature DOUBLE PRECISION  NULL,
    humidity    DOUBLE PRECISION  NULL
);
SELECT create_hypertable('conditions', 'time');
```

6\. **Insert data:**

```sql
INSERT INTO conditions(time, location, temperature, humidity)
VALUES (NOW(), 'office', 70.0, 50.0);
```

7\. **Query data:**

```sql
SELECT * FROM conditions ORDER BY time DESC LIMIT 100;
```

![The command output](https://timescale.ghost.io/blog/content/images/2024/07/13-createdb.png)

And you're set up for success!

## Next Steps

You now have TimescaleDB up and running on AWS. Explore more with sample datasets and advanced tutorials available in the [TimescaleDB documentation](https://docs.timescale.com/). If you have any questions, feel free to join our [Slack community](https://slack.timescale.com/) or check out our [GitHub repository](https://github.com/timescale/timescaledb) (GitHub ⭐ are welcome!). 

For smaller teams wanting to focus on application development and not their database or enterprises looking for scale, cost-effectiveness, and the peace of mind of a managed solution (with one-click high availability, forking, connection pooling, a low-cost storage tier for older data, SOC 2 Type 2 compliance, and much more), [try Timescale Cloud](https://console.cloud.timescale.com/signup). It’s free for 30 days (no credit card required).