Follow these steps to run a Terracotta clustered application on the Amazon Elastic Compute Cloud (EC2).
What You Will See:
An enterprise web application deployed in the cloud using Terracotta's configuration-driven cloud deployment automation
•
Ehcache distributed cache for scaling the application tier without database bottlenecks.
•
Web session replication for seamless user experience and high availability in an elastic cluster.
•
Spin up and tear-down application servers on the fly for elastic compute power on demand
•
Spin up and tear-down Terracotta server stripes for elastic throughput and data management on demand.
•
What You Will Need:
An Amazon AWS account with S3 and EC2 activated.
•
Familiarity with starting EC2 instances. If you have never used EC2 before, the AWS EC2 getting started guide is a good place to start.
•
Terracotta's cloud tools.
•
Terracotta installed on your local computer.
•
A system with that can run shell and perl scripts. This tutorial was prepared on Mac OS X and tested on Linux.
•
Download Terracotta Cloud Tools
Download the Terracotta cloud tools code. This project contains the bootstrap tooling to package your application and deploy it, clustered with Terracotta, in the cloud:
cloud-tools-v0.9a1.tar.gz Unpack The Cloud Tools
%> tar xfvz var="cloud-tools-binary-name"-->
We'll refer to the cloud tools directory in the following tutorial steps as <cloud-tools>.
Install Perl Modules
You may need to install some perl modules required by the cloud tools—specifically, Config::Tiny and Net::Amazon::EC2.
On MacOS X, these can be installed by running following (and accepting defaults to questions asked):
sudo /usr/bin/perl -MCPAN -e 'install Config::Tiny' sudo /usr/bin/perl -MCPAN -e 'install Net::Amazon::EC2'
See the CPAN documentation for details on installing perl modules using CPAN.
Start Bootstrap Instance
The bootstrap instance is the only EC2 instance that you need to start manually in the cloud. This is the instance to which the configuration is pushed from your local machine, and the node that provisions the other instances and the load balancer.
For the purposes of keeping the number of required EC2 instances as low as possible for this tutorial, the bootstrap instance is also used as a node of the Terracotta Server Array and also the default database location. However, the topography of the cloud is fully configurable to suit the individual needs of your applicaiton.
Using the AWS Management Console, locate and start an instance of the Terracotta-provided AMI called 'ami-2f8d6246'.
Start The "Launch Instance" Wizard
Search For Terracotta's AMI
Click on the "Community AMIs" tab and search for the Terracotta-provided AMI called ami-2f8d6246:
Select The Terracotta AMI Click the "Select" button.
Note: as of this writing, the "Select" button is hidden on some browsers. It seems to work properly in Google Chrome on some operating systems.
Download Terracotta Cloud Tools
Continue Past The Next Two Instance Details Screens Click "Continue" on the first screen using the default values:
Then, click "Continue" on the next screen, also using the default values:
Select Or Create A Key Pair
A key pair is a security credential similar to a password, which you use to securely connect to EC2 instances once they are running. If you haven't already generated one, you can create a new one.
Detailed instructions for creating a keypair may be found in Amazon's EC2 getting started guide.
Start Bootstrap Instance
Important. You will need access to the key pair file later in this tutorial, so be sure to keep that file handy.
Create A Security Group For Terracotta
A "Security Group" in EC2 is a way of specifying firewall rules for a group of EC2 instances. This tutorial will require a few ports to be opened to work properly. To do this, create a new security group called 'l2securitysettings' and configure it to allow SSH connections.
To create the security group, choose the "Create a new Security Group" option in the "Configure Firewall" page:
Name the security group 'l2securitysettings'. Then, add SSH to the list of allowed connections.
Start Bootstrap Instance
Note: Since this AWS EC2 administration wizard offers only a few options for allowed connections, we will add the rest of the allowed connections later in the tutorial.
Continue past the firewall configuration page:
Review the launch configuration, then press "Launch":
Start Bootstrap Instance
Important. Once you launch an instance, you will be charged by Amazon as long as it is running. BE SURE TO SHUT DOWN YOUR INSTANCES WHEN YOU ARE NOT USING THEM.
Click the link to view the status of your new instance:
When the instance status says "running," it is ready for use.
Start Bootstrap Instance
Finish Security Group Configuration
When setting the bootstrap instance, we created a security group, but we still need to allow a few more connections.
To do this, open the "Security Groups" configuration page in the AWS Management Console:
Select The l2securitysettings Security Group
Note: You may need to click the "Refresh" button to make the new security group show up in the list.
Allow Connections To The Following Ports 22 (ssh)
•
9092 (hypersonic database)
•
9510 (terracotta server)
•
9520 (terracotta server)
•
9530 (terracotta server)
•
Start by allowing port 9092:
Start Bootstrap Instance
Allow the rest of the ports in the same way. When you are done, your configuration should look like this:
Check Default Security Group
Your default security group should already be configured properly, but to make sure, see that all of the following entries are in your default security group:
Copy AWS Files To The Cloud Tools Directory
You must copy three of your AWS-generated files to the cloud tools directory. The cloud tools scripts are very sensitive to the names and locations of these files, so make sure you put them in the proper places and use the right names.
Copy Your Key Pair File
Locate the keypair file for the key pair that you used to start the bootstrap instance. Copy that keypair file to the top-level <cloud-tools> directory.
Copy Your X.509 Certificate And Private Key
If you don't already have valid X.509 credential files, see the "Security Credentials" section of your account at AWS.
Start Bootstrap Instance
Once you have the credential files, copy both the certificate file (its name should start with cert-) and the private key file (its name should start with pk-) to the <cloud-tools>/etc directory.
Configure Cloud Tools
The main configuration file for the cloud tools scripts is <cloud-tools>/terracotta-cloud.cfg
There are a number of configuration lines you must edit with the particulars of your AWS account and your running bootstrap instance, as follows.
Configure The DNS Name Of The Bootstrap Node
Copy the public DNS name of the bootstrap node you started from the AWS administration console:
Paste the public DNS name of the bootsrap node into the cloud tools configuration file.
Also paste the name of the keypair file that you copied into the top-level cloud-tools directory. This will have a name like 'gsg-keypair.pem':
Configure AWS Access Key and Secret Key Start Bootstrap Instance