This is a step-by-step guide to using the Amazon Web Services EC2 Management Console to set up a simple Cassandra cluster using the DataStax Community Edition AMI (Amazon Machine Image). Installing via the AMI allows you to quickly deploy a Cassandra cluster within a single availability zone. When you launch the AMI, you can specify the total number of nodes in your cluster.
The DataStax Cassandra AMI does the following:
In your Amazon EC2 Console Dashboard, select Security Groups in the Network & Security section.
Click Create Security Group. Fill out the name and description and click Yes, Create.
Click Inbound and add rules for the following ports.
| Port | Rule Type | Description |
|---|---|---|
| 22 | SSH | Default SSH port |
| 7000 | Custom TCP Rule | Cassandra intra-node port (source is the current security group) |
| 9160 | Custom TCP Rule | Cassandra client port |
| 7199 | Custom TCP Rule | Cassandra JMX monitoring port |
| 1024+ | Custom TCP Rule | JMX reconnection/loopback ports (source is the current security group) |
| 8888 | Custom TCP Rule | OpsCenter website port |
| 61620 | Custom TCP Rule | OpsCenter intra-node monitoring port (source is the current security group) |
| 61621 | Custom TCP Rule | OpsCenter agent port (source is the current security group) |
| 8983 | Custom TCP Rule | DataStax demo application website port |
After you are done adding the above port rules, click Apply Rule Changes. Your completed port rules should look something like this:
Note
This security configuration shown in this example opens up all externally accessible ports to incoming traffic from any IP address (0.0.0.0/0). If you desire a more secure configuration, see the Amazon EC2 help on Security Groups for more information on how to configure more limited access to your cluster.
After you have created your security group, you are ready to launch an instance of Cassandra using the DataStax Community Edition AMI.
From your Amazon EC2 Console Dashboard, click Launch Instance. Select Launch Classic Wizard and Continue.
On the Choose an AMI page, Select the Community AMIs tab. Find the DataStax AMI, version 2.1, and then click Select to launch it.
On the Instance Details page, enter the total number of nodes you want in your cluster in the Number of Instances field and select the Instance Type.
Click Continue.
Under Advanced Instance Options add the following options to the User Data section depending on the type of cluster you want. Option parameters cannot have spaces.
For new Cassandra clusters the available options are:
Option
Description
-c | --clustername <name>
Required. The name of the cluster.
-n | --totalnodes <num_nodes>
Required. The total number of nodes in the cluster.
-v | --version [enterprise | community]
Required. The version of the cluster. Use community to install the latest version of DataStax Community Edition.
-o | --opscenter [no]
Optional. By default, DataStax OpsCenter will be installed on the first instance unless you specify this option with no.
-e | --email <smtp>:<port>:<email>:<password>
Optional. Sends logs from AMI install to this email address. For example: -e smtp.gmail.com:587:ec2@datastax.com:pa$$word
![]()
Click Continue.
On the Tags page, give a name to your instance. This can be any name you like (For example: cassandra-node). Click Continue.
On the Create Key Pair page create a new key pair or select an existing key pair and click Continue. You will need this key (.pem file) to log in to your Cassandra nodes, so save it to a location on your local machine.
On the Configure Firewall page, select the security group you created earlier and click Continue.
On the Review page, review your cluster configuration and then click Launch.
Go to the My Instances page to see the status of your instance. Once a node has a status of running, you are able to connect to it.
You can connect to your new Cassandra EC2 instance using any SSH client (PuTTY, Terminal, etc.). To connect, you will need a private key (the .pem file you created earlier) and the public DNS name of a node. Connect as user ubuntu rather than as root.
If this is the first time you are connecting, copy your private key file (<keyname>.pem) you downloaded earlier to your home directory, and change the permissions so it is not publicly viewable. For example:
chmod 400 datastax-key.pem
From the My Instances page in your AWS EC2 Dashboard, select the node you want to connect to. Since all nodes are peers in Cassandra, you can connect using any node in the cluster. However, the first node is typically the node running the OpsCenter service (and is also the Cassandra seed node).
To get the public DNS name of a node, select Instance Actions > Connect
This will open a Connect Help - Secure Shell (SSH) page for the selected node. This page will have all of the information you need to connect via SSH. If you copy and paste the command line, change the connection user from root to ubuntu.
The AMI image configures your cluster and starts the Cassandra and OpsCenter services. After you have logged in to a node, run the nodetool ring command to make sure your cluster is up and running. For example:
For next steps, see Running the Portfolio Demo Sample Application.
Note
If you are installing OpsCenter with your Cassandra cluster, allow about 60 to 90 seconds after the cluster has finished loading for OpsCenter to start. You can launch OpsCenter using the URL: http://<public-dns-of-first-instance>:8888. After OpsCenter loads, you must install the OpsCenter agents if you want to see cluster performance data (click Install Agents). When prompted for credentials for the agent nodes, use the username ubuntu and copy/paste the entire contents from your private key file ( the .pem file you downloaded earlier).