How to Install TimescaleDB on AWS
TimescaleDB 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 and create your AWS account. Once you've logged into the AWS console, you'll see a dashboard similar to this:
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.
2. Launch instance: Click on 'Launch Instance' to open the Amazon Machine Image (AMI) selection page.
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.
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.
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.
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
3. Set file permissions: On your local machine, navigate to the directory containing the .pem
file and set the correct permissions:
4. Connect via SSH: Use the copied SSH command to connect to your instance.
Installing TimescaleDB
1. Add TimescaleDB PPA:
2. Install TimescaleDB:
Configuring PostgreSQL
1. Check the PostgreSQL version (ensure it shows psql (PostgreSQL) 16.x
):
2. Modify configuration:
3. Update postgresql.conf:
Set listen_addresses
to '*'
:
Set shared_preload_libraries
to timescaledb
:
Save and exit the editor.
- Tune PostgreSQL:
5. Restart PostgreSQL:
6. Switch to PostgreSQL user:
Using TimescaleDB
1. Access PostgreSQL:
2. Create database:
3. Connect to the database:
4. Initialize TimescaleDB extension:
5. Create a hypertable:
6. Insert data:
7. Query data:
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. If you have any questions, feel free to join our Slack community or check out our GitHub repository (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. It’s free for 30 days (no credit card required).