Download & Run: WebSynergy - Demonstrating AMI update from ZIP on S3

In this type of AMI image use, I will send a control data in form of ZIP file to AMI on instance start which will download from S3 prepackaged and zipped application stack, this way we don't need to rebuild AMI and we can update it on boot time.

This entry is part of 'OpenSolaris on Amazon EC2' Workshop

As as prepackaged and zipped application stack I select already build platform neutral Java based demo of WebSynergy, its sized around 120MB so it have size close to your real application stack.

WebSynergy is Sun's next generation web aggregration and presentation platform containing OpenPortal components.
This platform demo includes developer tooling and an enterprise grade presentation runtime based on Liferay Portal Server, GlassFish v3, and MySQL.

Project WebSynergy - Liferay and GlassFish Deliver a Modern Web Portal

Project WebSynergy details

Installing and Using Project WebSynergy

First: Make data zip file accessible locally and create control scrip, zip it
(I prepare this step for you)

1. Get WebSynergy demo and save it locally into S3

Note: Reason is then we need to have download time under our control , S3 to EC2 give 12MB/s !!!

Got glassfish-synergy.zip

Make it available as S3 download under link:

Note: Current early access of WebSynergy use embeded Java based database, not MySQL server.

  http://sun-osol-sw.s3.amazonaws.com/glassfish-synergy.zip

2. Create control scrip

cat syncer.run
#!/bin/bash

# !!! You need to use full path to bins in SMF scrips !!!
# More info about composite AMI images tips see blog http://blogs.sun.com/VirtualGuru

echo "syncer.run got $1"
. /opt/ec2ify/rundata/ec2envs.run
case $1 in

 'start')
   echo "Downloading glassfish-synergy zip image "

/usr/bin/curl --connect-timeout 1100 --retry 5 --retry-delay 2 \\
 http://sun-osol-sw.s3.amazonaws.com/glassfish-synergy.zip -o /tmp/glassfish-synergy.zip

 if [ $? -eq 0 ] ; then
   echo "Got OK receive glassfish-synergy zip image "
   curr_dir=$PWD
   cd /opt
   /usr/bin/unzip /tmp/glassfish-synergy.zip

     if [ $? -eq 0 ] ; then

      echo "Unpack OK glassfish-synergy zip image"
      rm -f /tmp/glassfish-synergy.zip
      /opt/glassfish/bin/asadmin start-domain

     else
      echo "Can't unpack glassfish-synergy zip image"
    fi
   cd $curr_dir
  else
   echo "Can't receive glassfish-synergy zip image"
  fi
;;
esac
exit 0

3. Create control file zip

  zip load-gf-websynergy.zip syncer.run 

Second: Run JeOS AMI instance with control ZIP file to load and start app stack

1. Download control ZIP file

 http://sun-osol-sw.s3.amazonaws.com/load-gf-websynergy.zip

2. Find JeOS Solaris instance

ec2-describe-images | grep JeOS
IMAGE   ami-7b49ac12    sun-osol/2008.05_JeOS_32_1.0.img.manifest.xml   327216928991    available       private         i386    machine

3. Open ports for WebSynergy demo

ec2-authorize default -p 8585

GROUP               default
PERMISSION              default ALLOWS  tcp     8585    8585    FROM    CIDR    0.0.0.0/0

ec2-authorize default -p 8686

GROUP               default
PERMISSION              default ALLOWS  tcp     8686    8686   FROM    CIDR    0.0.0.0/0

4. Run AMI instance with control file

 ec2-run-instances -k myec2-keypair ami-8142a7e8 -f ./load-gf-websynergy.zip

RESERVATION     r-71e92d18      327216928991    default
INSTANCE        i-24e42a4d      ami-8142a7e8                    pending myec2-keypair    0               m1.small        
2008-05-16T15:07:40+0000                        aki-b57b9edc    ari-b47b9edd

5. Check then instance is running (Start booting)

 ec2-describe-instances i-24e42a4d
RESERVATION     r-71e92d18      327216928991    default
INSTANCE        i-24e42a4d      ami-8142a7e8    ec2-67-202-55-40.compute-1.amazonaws.com        ip-10-251-67-69.ec2.internal    
running ec2-rk159669-keypair    0               m1.small        2008-05-16T15:07:40+0000                        aki-b57b9edc    ari-b47b9edd

6. Login and check update process

 ssh -i id_rsa-myec2-keypair root@ec2-67-202-55-40.compute-1.amazonaws.com

 svcs -l svc:/ec2ify/me:default
fmri         svc:/ec2ify/me:default
name         Amazon EC2 ec2ify me script - updating Solaris image for Amazon AWS infrastruture
enabled      true
state        online
next_state   none
state_time   Fri May 16 17:19:00 2008
logfile      /var/svc/log/ec2ify-me:default.log
restarter    svc:/system/svc/restarter:default
dependency   require_all/none svc:/system/filesystem/local (online)
dependency   require_all/none svc:/network/service (online)

cat  /var/svc/log/ec2ify-me:default.log | more

  inflating: glassfish/bin/startserv
  inflating: glassfish/bin/stopserv
Unpack OK glassfish-synergy zip image
Command start-domain executed successfully.
[ May 16 22:54:45 Method "start" exited with status 0. ]

7. Check Glassfish server is fully start

tail -f /opt/glassfish/domains/domain1/logs/server.log

You will a lot of deploy lines, start is finished when you see:

[#|2008-05-16T21:46:57.779-0500|SEVERE|GlassFish10.0|null|_ThreadID=13;
 _ThreadName=Thread-5;| INFO [DefaultQuartzScheduler_Worker-5] 
 (PluginPackageUtil.java:1140) - Reloading repositories
\^C

8. Go to Dynamic URL

http://ec2-67-202-55-40.compute-1.amazonaws.com:8585/

9. Load of main page will take while, jsp are compiled

You can monitor system load to se when page will come to browser

top
q for quit top

10. Login with one of predefined user roles

See more about predefined roles at:

Installing and Using Project WebSynergy

If you are interesting this AMI updates approach, drop me note, I can create another samples.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Hands-on experience with Virtualization

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today