Resin Cloud deployment with Amazon WS EC2 and Euca Tools

From Resin 3.0

Jump to: navigation, search

Running Euca Tools to launch Amazon EC2 instances.

This is an extention of this tutorial [Resin Cloud Deployment with Amazon EC2].

Contents

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


Using Botto To Run and Manage Amazon AMI Instances

Personal tools