main website home
  • About this blog

    This blog features updates, opinions, and technical notes from Caucho engineers about Caucho products, the enterprise Java industry, and PHP. Caucho Technology is the creator of the Resin Application Server and the Quercus PHP in Java engine. A leader in Java performance since 1998, Caucho is a Sun JavaEE licensee with over 9000 customers worldwide.
  • Tags

    ajaxworld bam candi cdi cloud cluster comet configuration deploy devoxx eclipse ejb embedded flash flex google app engine hessian hmtp ioc java ee 6 javaone javazone jms messaging newsletter nyjug osgi php pomegranate quercus resin resin 4.0 REST servlet sfjug silicon valley code camp spring testing training tssjs watchdog webbeans web profile websockets wordpress
  • Meta

    • Register
    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
« Resin Cloud Deployment with Amazon WS (EC2)
Paul Cowan’s JavaOne Interview on Resin’s Cloud Support »

Resin Cloud deployment with Amazon WS EC2 and Euca Tools

We have seen consistently growing interest in running Resin on Amazon EC2. EC2 is an Infrastructure as a Service (IaaS). It provides hardware, networking, load balancing, connectivity, storage and virtualized OS hosting. Resin 4 includes cloud support features that make deploying to EC2 simple and painless. Resin offers dynamic clustering, load balancing and versioned deployment. A comprehensive health monitoring system provides visibility into the status of your entire application stack. Furthermore, comparing Resin to PaaS providers, Resin is really a PaaS-ready application server; one that will run well on an IaaS service like Amazon EC2.

This is part two of a tutorial on using Amazon EC2 and Resin to do cloud deployment. This tutorial is going to cover the basics of using Resin with Amazon Web Services for cloud deployment. If you are new to cloud computing and IaaS, follow along and you will soon be deploying Java web applications in the cloud.

Running Euca Tools to launch Amazon EC2 instances.

Make sure to complete part 1 first.
This is an extension of this tutorial Resin Cloud Deployment with Amazon EC2.

Setup Euca Tools on Ubuntu local box

Install tools:

$ sudo apt-get install -y euca2ools

Create ~/.eucarc file

In home dir create .eucarc file with the following contents. To get the EC2_ACCESS_KEY and the EC2_SECRET_KEY go to the Amazon WS home then go to the Account Tab then go to Security Credentials. You should access key and the secret key. Click around. It is there.

rick@ubuntu:~$ cat .eucarc
EC2_PRIVATE_KEY=/home/rick/.ec2/pk-6HWBZZZZZZZZZZZPKCWWPTR.pem
EC2_CERT=/home/rick/.ec2/cert-6HWBPKCWWPTRZZZZZZZZ3AL6.pem
EC2_ACCESS_KEY=AKIAZZZZZZZZZZZZZZ
EC2_URL=http://ec2.amazonaws.com
EC2_SECRET_KEY=OTbf8mwYC6PFphdAjdCZZZZZZZZZ

Create a new Amazon Linux instance

We are going to create an Amazon Linux instance, which we can describe as follows:

$ euca-describe-images | grep "ami-1b814f72"

IMAGE     ami-1b814f72     amazon/amzn-ami-2011.09.2.x86_64-ebs     \
137112412989     available     public          x86_64     machine     aki-825ea7eb           ebs

Now we need to import the resin2 key. Your key pair might be named different as you set this up with Amazon as part of the initial trail setup (documented in the first tutorial linked to the Amazon documentation).

$ euca-add-keypair resin2 > priv.ec2.key
$ chmod 600 priv.ec2.key

Create properties file as follows user-data.properties in the home directory.

log_level     : info
dev_mode      : true
resin_doc     : true

app_tier      : 127.0.0.1
web_tier      :
cache_tier    :

setuid_user   : resin
setuid_group  : resin

http          : 8080
https         : 8443

admin_user : admin
admin_enable : true
admin_password : {SSHA}BGBKQdCr0a5orH99eqIFwR/fffffffff
admin_external : true
admin_remote_enable : true
session_store : true

Now startup a new instance with the above user properties.

$ euca-run-instances ami-1b814f72 -t t1.micro -k resin2 --user-data-file user-data.properties
RESERVATION     r-c3c326a2     972637075895     default
INSTANCE     i-577b5834     ami-1b814f72               pending     resin2     0         \
 t1.micro     2011-11-30T00:53:06.000Z     us-east-1a     aki-825ea7eb

The instance id is i-577b5834.

$ euca-create-tags i-577b5834 --tag Name=resinserver
TAG     i-577b5834     Name     resinserver

To get the instance you just ran do the following:

$ euca-describe-instances --filter "instance-state-name=running" --filter \
"image-id=ami-1b814f72" | grep INSTANCE | awk '{print $2, $4, $10}'
i-577b5834 ec2-107-22-145-5.compute-1.amazonaws.com 2011-11-29T23:28:18.000Z

The first column is the instance identifier. The second column is the public IP address. The third column is the timestamp the instance started.

The instance id is i-577b5834. You can use the instance id to get a copy of the public DNS for this instance.

$ euca-describe-instances i-577b5834 | grep INSTANCE | awk '{print $4}'
ec2-107-22-97-101.compute-1.amazonaws.com

Install Resin on the Amazon AMI instance we just started

Once you know the URL you can log into the box with ssh.

$ ssh -i resin2.pem ec2-user@ec2-107-22-97-101.compute-1.amazonaws.com

Installed Resin on Remote Amazon box.

$ sudo rpm --import http://caucho.com/download/rpm/RPM-GPG-KEY-caucho
$ sudo yum install http://caucho.com/download/rpm/4.0.24/x86_64/resin-pro-4.0.24-1.x86_64.rpm

Create Create an amazon.xml on the Amazon AMI instance. Add the below to /etc/resin/local.d/amazon.xml

<resin xmlns="http://caucho.com/ns/resin"
      xmlns:resin="urn:java:com.caucho.resin">

  <resin:properties path="http://169.254.169.254/latest/user-data"
                    optional="true"/>

</resin>

Deploy the Roo example from the example dir

On Local Ubuntu box

$ resinctl deploy target/blog-0.1.0.BUILD-SNAPSHOT.war -name blog -address 107.22.97.101 -port 8080 -user admin -password roofoo

Deployed production/webapp/default/blog from target/blog-0.1.0.BUILD-SNAPSHOT.war to admin@aaa.app_tier.admin.resin/133f37dc81f

Now your app should be ready to go.

http://107.22.97.101:8080/blog

This entry was posted on Wednesday, November 30th, 2011 at 2:50 am and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

You must be logged in to post a comment.


Caucho Technology is proudly powered by WordPress and Quercus®
Entries (RSS) and Comments (RSS).

  • HOME |
  • CONTACT US |
  • DOCUMENTATION |
  • BLOG |
  • WIKI 4 |
  • WIKI 3 |
  • Resin: Java Application Server
Copyright (c) 1998-2012 Caucho Technology, Inc. All rights reserved.
caucho® , resin® and quercus® are registered trademarks of Caucho Technology, Inc.
resin® is a cloud optimized, java® application server that supports the java ee webprofile ®