We provide a variety of services including:

·          Training classes for Spring, Hibernate and Acegi Security

·          Jumpstarts to get your project off to the right start

·          Reviews to improve your architecture, code and development process

For more information visit our website: http://www.chrisrichardson.net

Home > Knowledge > EC2

 

Getting Started with EC2Deploy

EC2Deploy, which is part of Cloud Tools, lets you deploy and test a Java EE application consisting of MySQL master and slaves; one or more Tomcats; and Apache HTTPD.

It launches one or more instances using EC2 images (32 bit and 64 bit AMIs), which are based on CentOS 5 and has Java, Tomcat, MySQL etc. preinstalled.  The starting point for these AMIs were CentOS images created by Rightscale - I installed applications for running enterprise Java applications. Let me know if you would like to use my AMIs and will give you access (as described here I need your AWS account id to do this).

Getting started with Amazon EC2

You first need to sign up for EC2 and S3.

1.       Sign up for Amazon EC2 and S3

2.       Read the EC2 getting started guide

3.       Use EC2UI, which is a firefox plugin – it’s the easiest way to create a keypair and download the keypair file

Creating an AWS properties file

EC2Deploy needs a properties file, which tells it which AMIs to launch, and which Amazon web service ids and keys to use.

Property

description

imageId.m1.small

The 32 bit image to run (currently ami-6f2cc906)

imageId.m1.large

The 64 bit image to run (currently ami-0129cc68)

imageId.m1.xlarge

The 64 bit image to run (currently ami-0129cc68)

accessKey

AWS access key

secretKey

AWS secret key

accountId

AWS account id

keyName The name of the key pair

keyPairFile

The location of the AWS key pair file

sshDir

The directory containing the ssh executable, e.g. c:/cygwin/bin

startupScript An optional startup script

Setup

The easiest way to use Cloud Tools is via the Cloud Tools Maven 2  plugin or the Cloud Tools Grails plugin.

Alternatively, you can use a Maven archetype to create a project with cloud tools. Finally, (not recommended) you can set up the class path manually.

Using the Maven archetype

When using Maven there are three things that you need to do.

First, run this command to generate an example, which you can then edit:

mvn archetype:create -DarchetypeGroupId=net.chrisrichardson \

      -DarchetypeArtifactId=ec2deploy-archetype \

      -DarchetypeVersion=1.0-SNAPSHOT \

      -DgroupId=net.chrisrichardson  \

      -DremoteRepositories=http://www.pojosinaction.com/repository \

      -DartifactId=myexample

[Note: -DremoteRepositories requires a version of Maven 2 later than 2.0.4]

Second, you need to manually install the synchronize-0.5.0.jar from Jets3t (http://jets3t.s3.amazonaws.com/index.html) in your local maven repository so that it matches:

mvn install:install-file \

  -DgroupId=net.java.dev.jets3t \

  -DartifactId=synchronize \

  -Dversion=0.5.0 \

  -Dpackaging=jar \

  -Dfile=<<pathTo jets3t-0.5.0/jars/synchronize-0.5.0.jar>>

 

Really slow - Manually setting the classpath

TBD

Writing a script

The maven archetype above created an example script (in the form of a GroovyTestCase). The easiest thing to do is to edit that code to match your application and point it at your aws.properties file. There is a skeleton aws.properties file located in src/test/resources

Using EC2Deploy with your own AMI

EC2Deploy makes certain assumptions about the AMI including the location of Java, MySQL, Tomcat, Apache, Jets3t, and Jmeter. It also overwrites the MySQL my.cnf and Tomcat server.xml with it's own versions of those files. However, it should be very straightforward to extend EC2Deploy to work with your AMI. Please send me email.