Start a cluster - dehora/parsel GitHub Wiki
Creating a cluster
Parsel uses Priam for node management. Priam is designed to run C* clusters created via an auto-scaling group and a launch configuration. In summary to create a cluster -
- Add Priam cluster properties to Simple DB
- Define a launch configuration
- Create auto-scaling groups
Add Priam Cluster Properties to SDB
Priam expects to find properties in Simple DB. You should at least set the clustername, backup bucket, and zones -
Item name: cass_c0002.clustername
attribute-value: appId=cass_c0002
attribute-value: property=priam.clustername
attribute-value: value=cass_c0002
Item name: cass_c0002.s3.bucket
attribute-value: appId=cass_c0002
attribute-value: property=priam.s3.bucket
attribute-value: value=cassandra-archive-viscis
Item name: cass_c0002.zones.available
attribute-value: appId=cass_c0002
attribute-value: property=priam.zones.available
attribute-value: value=eu-west-1a,eu-west-1b,eu-west-1c
Priam Naming Convention
Priam uses the ASG name to create a query for properties stored in SimpleDB. It splits the ASG name using '-' as a delimiter -
- 'cluster name'-'availability zone'
This means you may get unexpected results with an ASG that uses multiple hyphens (see PriamConfiguration.java). To avoid surprises the example ASG names here only use one hyphen, eg cass_c0001-euwest1a
.
Define a Launch Configuration
You need -
- An AMI created via Parsel. See creating an AMI.
- A security group. See [creating an EC2 security group] (http://www.datastax.com/docs/1.1/install/install_ami) from DataStax for details
- A region to launch in.
- An instance type - m1.xlarge is recommended.
- The name of a keypair.
Example command -
as-create-launch-config lc_cass_c0001 \
--image-id ami-xxxxxxx \
--instance-type m1.xlarge \
--region eu-west-1 \
--group "sg-cass" \
--key eu-west-1 \
--block-device-mapping "/dev/sdb=ephemeral0,/dev/sdc=ephemeral1,/dev/sdd=ephemeral2,/dev/sde=ephemeral3"
The message should be -
OK-Created launch config
The C* AMI needs some user data passed to it as well.
Don't forget to set a key pair in the --key
parameter, or ssh won't work.
The --block-device-mapping
defines ephemeral drives used by each EC2 instance. The C* servers created by Parsel use instance storage instead of EBS for predictable performance and fault-tolerance. For an m1.xlarge instance type (the default), you may define up 4 eph drives. When an instance starts up, Parsel will create a RAID0 array from the emphemeral drives (providing about 1.7TB if 4 devices are defined).
User-Data configuration
Instance configuration uses getopt syntax and supports once parameter -
--release
[optional]: Specifies the Cassandra release: supports 1.0, 1.1, 1.2. Default is 1.1 (which is bound to 1.1.9).
Create Auto-Scaling Groups
Creating an ASG per AZ instead of a single multi-AZ ASG is a Priam feature. Priam does this because AWS doesn't guarantee an even spread of instances in a multi-AZ autoscaler. Priam detects which ASG servers belong to which cluster is via the naming convention described above.
Example
Create one ASG for each AZ in the EU region using a pre-defined launch configuration -
as-create-auto-scaling-group cass_c0001-euwest1a \
--availability-zones eu-west-1a \
--launch-configuration lc_cass_c0001 \
--min-size 1 \
--max-size 1
as-create-auto-scaling-group cass_c0001-euwest1b \
--availability-zones eu-west-1b \
--launch-configuration lc_cass_c0001 \
--min-size 1 \
--max-size 1
as-create-auto-scaling-group ccass_c0001-euwest1c \
--availability-zones eu-west-1c \
--launch-configuration lc_cass_c0001 \
--min-size 1 \
--max-size 1
Each message should be -
OK-Created AutoScalingGroup
Once the ASGs are created, the instances will configure themselves by installing Cassandra, Priam and a RAID0 disk using instance storage. Priam will start the C* processes and bootstrap the cluster.
Removing a Cluster
First size down the ASGs to 0:0, which will cause the instances in each ASG to be terminated. Terminating instances directly will just mean replacements are spun up, and you can't remove an ASG with running instances. For example -
as-update-auto-scaling-group cass_c0001-euwest1a --max-size 0 --min-size 0
as-update-auto-scaling-group cass_c0001-euwest1b --max-size 0 --min-size 0
as-update-auto-scaling-group cass_c0001-euwest1c --max-size 0 --min-size 0
This also deletes the data on the instance. Remember the instances are configured to use instance storage. If you need a backup (eg are moving nodes around or are shutting test nodes down but want to keep the test data), do that via Priam before resizing the ASGs.
Use as-delete-auto-scaling-group
to remove the ASGs. For example to remove the ASGs described in 'Create Auto-Scaling Groups' above -
as-delete-auto-scaling-group cass_c0001-euwest1a
as-delete-auto-scaling-group cass_c0001-euwest1b
as-delete-auto-scaling-group cass_c0001-euwest1c
The launch configuration can optionally removed with as-delete-launch-config
. For example to remove the ASGs described in 'Define a Launch Configuration' above -
as-delete-launch-config lc_cass_c0001