Start a CitusDB Cluster on AWS EC2 Using CloudFormation

Written by Marco Slot
April 2, 2015

CitusDB scales out PostgreSQL across commodity servers and processes queries in parallel. Many CitusDB users deploy it on Amazon Web Services (AWS) using Elastic Compute Cloud (EC2), which allows them to easily scale out the number of nodes. However, installing and configuring software on a large cluster in the cloud can be a painstaking chore.

Today we are releasing a CloudFormation template for Amazon EC2 users that will let you start a CitusDB cluster on AWS in just a few clicks, with [pg_shard](/citus-products/pg-shard), for real-time transactional workloads, [cstore_fdw](/citus-products/cstore-fdw), for columnar storage, and many other extensions pre-installed.

CloudFormation is an Amazon service that lets you create a "stack" of AWS resources, such as EC2 instances and security groups, from a template defined in a JSON file. You can create multiple stacks from the same template without conflict, as long as they have unique stack names.

The button below will take you directly to the AWS CloudFormation console to start your CitusDB cluster on Amazon EC2. The template automatically tunes the system configuration for CitusDB and sets up RAID on the SSD drives where appropriate, making it a great starting point for both first-time users and production systems.

Launch CitusDB on Amazon EC2 Using CloudFormation

Getting started with CloudFormation

The remainder of this post will guide you through the steps of creating a CitusDB cluster using the CloudFormation console. The cluster will consist of a master node that keeps track of where data is stored and coordinates queries, and one or more worker nodes that store shards of the data and process the queries in parallel. Users can create distributed tables and perform queries by connecting to the master node using thepsql command or any other PostgreSQL client.

In the CloudFormation console, pick a unique name for your stack:

Enter a name for your stack

Next, set the your key pair name in the Parameters screen. If you don't have one yet, you can create it in the EC2 console. You can also change the number of workers, the instance types and the availability zone. You can skip the Options screen and proceed directly to the Review screen by pressing Next twice.

Enter your EC2 key pair name

Before pressing Create in the Review screen, acknowledge the IAM capabilities, which are used to give the master node limited access to the EC2 APIs to obtain the list of worker IPs. Your AWS account needs to have IAM access to perform this step.

After about 10 minutes, stack creation completes and the hostname of the master node will appear in the Outputs tab. You can immediately connect to it using SSH with username ec2-user and the EC2 keypair you filled in.

Stack creation completed

CitusDB will be up and running and ready to take queries. To get started using CitusDB, you can now follow the examples guide.

You typically want to avoid making changes to resources created by CloudFormation, such as terminating EC2 instances. To shut the cluster down, simply delete the stack in the CloudFormation console.

More information about Citus is available on our Citus product overview page.

Marco Slot

Written by Marco Slot

Former lead engineer for the Citus database engine at Microsoft. Speaker at Postgres Conf EU, PostgresOpen, pgDay Paris, Hello World, SIGMOD, & lots of meetups. Talk selection team member for Citus Con: An Event for Postgres. PhD in distributed systems. Loves mountain hiking.

@marcoslot marcocitus