GlassFish 3.1 Milestone 2 was released this week, download the zip file.
TOTD #138 provide simple instructions to get you started with Milestone 1 and you can follow similar steps to get started with Milestone 2 as well. A more detailed blog on the new functionality (SSH Provisioning and Dynamic App Deployment) is coming as well.
In order to test the newly added clustering capabilities of GlassFish 3.1, I decided to run Milestone 2 build on a Ubuntu 10.04 instance on Amazon EC2. My host operating system is Mac OS X and even though the steps are defined at multiple locations (mentioned below) but complete set of steps were missing. This Tip Of The Day (TOTD) shows how get started with running a GlassFish 3.1 build on Ubuntu 10.04 instance on Amazon EC2.
This TOTD consulted the following blogs:
- Starting Amzon EC2 with Mac OS X
- EC2 Starters Guide on Ubuntu
- Ubuntu 10.04 LTS Daily Build – Amazon Published EC2 AMIs
- Ubuntu Linux Install Sun JDK and JRE
- How to install Sun Java on Ubuntu 10.04 LTS
Twitterverse was very helpful and Divyen helped smoothen the rough edges!
Lets get started!
- In your home directory, create a new ".ec2" directory.
- Generate SSH Key & X.509 certificates
- Generate X.509 certificates key
- Go to your AWS account and click on "Security Credentials".
- In "Access Credentials" section, click on "X.509 Certificates" and click on "Create a new Certificate". Make sure to download the private key file and X.509 certificate in ".ec2" directory as "cert-xxxxxx.pem" and "pk-xxxxxxx.pem".
- SSH key – Public AMIs can be accessed using an ssh key. Give the following command in ".ec2" directory:
ec2-add-keypair ec2-keypair > ec2-keypair.pem
This will generate the SSH key in the file "ec2-keypair.pem".
- Generate X.509 certificates key
- EC2 API Tools
- Download Amazon EC2 API Tools from here and unzip them in ".ec2" directory.
- Move "lib" and "bin" directory from the extracted directory to ".ec2" directory.
- Create ".ec2.profile" file in ".ec2" directory and add the contents:
export EC2_HOME=~/.ec2 export PATH=$PATH:$EC2_HOME/bin export EC2_PRIVATE_KEY=`ls $EC2_HOME/pk-*.pem` export EC2_CERT=`ls $EC2_HOME/cert-*.pem` export EC2_URL=https://ec2.us-west-1.amazonaws.com
The last line sets the default zone to US-West-1. The AMI id used later is from this region. Source this file by giving the following command in ".ec2" directory:
source ".ec2.profile"
- On your firewall, authorize port 22 for SSH and 8080 for HTTP access for GlassFish on your firewall as:
ec2-authorize default -p 22
ec2-authorize default -p 8080
- Run the instance as:
ec2-run-instances ami-c597c680 -k ec2-keypair
- Obtain the public IP address of Ubuntu instance as:
ec2-describe-instances RESERVATION r-XXXXXXXX XXXXXXXXXXXX default INSTANCE i-XXXXXXXX ami-c597c680 ec2-XX-XX-XX-XX.us-west-1.compute.amazonaws.com ip-XX-XX-XX-XX.us-west-1.compute.internal running ec2-keypair 0 m1.small 2010-06-24T16:23:44+0000 us-west-1a aki-XXXXXXXX monitoring-disabled XX-XX-XX-XX XX-XX-XX-XX
The address "ec2-XX-XX-XX-XX.us-west-1.compute.amazonws.com" is the public IP address and will be used for ssh next.
- SSH to the ready Ubuntu instance as:
ssh -i ec2-keypair.pem [email protected]
- Install JDK 6 on Ubuntu
- Add the Ubuntu partner repository as:
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
- Update the list of packages as:
sudo apt-get update
- Install JDK 6 as:
sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk
- Make sure the recently added JDK is at the top of JVM search order by giving the command:
sudo update-java-alternatives -s java-6-sun
This command adds "/usr/lib/jvm/java-6-sun" to the top of "/etc/jvm" file.
- Add the Ubuntu partner repository as:
- Install "unzip" package as:
sudo apt-get install unzip
- Download & start GlassFish 3.1
- Download GlassFish 3.1 Milestone 2 as:
wget http://dlc.sun.com.edgesuite.net/glassfish/3.1/promoted/glassfish-3.1-b06.zip
- Unzip the downloaded zip file as:
unzip glassfish-3.1-b06.zip
- Start GlassFish as:
./glassfishv3/glassfish/bin/asadmin start-domain --verbose
- And now your default web page is accessible at "http://ec2-XX-XX-XX-XX.us-west-1.compute.amazonws.com:8080".
- Download GlassFish 3.1 Milestone 2 as:
- Finally terminate the instance as:
ec2-terminate-instances i-XXXXXXXX
How are you using GlassFish in the cloud ?
Technorati: totd glassfish ubuntu amazon ec2 cloud osxtips
Related posts:- TOTD #142: GlassFish 3.1 – SSH Provisioning and Start/Stop instance/cluster on local/remote machines
- TOTD #92: Session Failover for Rails applications running on GlassFish
- TOTD #21: Metro 1.1 with GlassFish v2 UR1 and NetBeans 6
- TOTD #18: How to Build The GlassFish v3 Gem for JRuby ?
- TOTD #152: GlassFish Installer – Typical and Custom installation
Good stuff, but I’d recommend a small change: Instead of manually updating the /etc/jvm file in step 9.4, you should use the following: "sudo update-java-alternatives -s java-6-sun", which is documented here: https://help.ubuntu.com/community/Java.
Comment by Chad S — June 25, 2010 @ 5:10 am
Thanks for the tip Chad,
Updated the blog with that change.
Comment by Arun Gupta — June 25, 2010 @ 11:21 am
The installation is the real sticking point for me; is there really still no .dpkg or .rpm for Glassfish v3 yet?
Untarring binaries is not fun at cloud scale.
Comment by Dick Davies — July 19, 2010 @ 3:29 am
I wondered why you need to get the Sun Java6 from a non-standard repository instead of the OpenJDK which is available in the default repositories?
Found an incompatability?
Comment by Thorbjørn Ravn Andersen — September 24, 2010 @ 4:16 am