X

GlassFish asadmin CLI-driven Cluster Setup

Guest Author


Here is simple script that:
  • Installs GlassFish
  • Creates a new domain using style="font-style: italic;">cluster profile
  • Create 2 instances
    in the cluster
  • Deploys a sample application to verify the cluster setup

Everything in just one simple script!



This script can be used on a virtual (Virtual
Box
, EC2 instance, etc.) or a physical image of an Operating
System.



style="text-align: left; background-color: rgb(204, 204, 255); width: 100%;"
cellpadding="2" cellspacing="2">echo A | java -Xmx256m -jar
~/Downloads/glassfish-installer-v2.1-b60e-darwin.jar -console

cd $GLASSFISH_HOME

chmod +x ./lib/ant/bin/ant

./lib/ant/bin/ant -f setup.xml

cd $GLASSFISH_HOME

echo 'AS_ADMIN_ADMINPASSWORD=adminadmin' > password

echo 'AS_ADMIN_PASSWORD=adminadmin' >> password

echo 'AS_ADMIN_MASTERPASSWORD=changeit' >> password

./bin/asadmin
create-domain --user admin --passwordfile ./password --savelogin=true
--portbase 5000 --interactive=false --profile cluster cloud

./bin/asadmin start-domain cloud

./bin/asadmin create-node-agent --user admin --port 5048
--interactive=false --passwordfile ./password cloud-nodeagent

./bin/asadmin start-node-agent --interactive=false --passwordfile
./password cloud-nodeagent

./bin/asadmin create-cluster --port 5048 wines

./bin/asadmin
create-instance --port 5048 --nodeagent cloud-nodeagent
--systemproperties HTTP_LISTENER_PORT=58080 --cluster wines cabernet

./bin/asadmin
create-instance --port 5048 --nodeagent cloud-nodeagent
--systemproperties HTTP_LISTENER_PORT=58081 --cluster wines merlot

./bin/asadmin deploy --target wines --port 5048
--availabilityenabled=true samples/quickstart/clusterjsp/clusterjsp.ear

./bin/asadmin start-cluster --port 5048 --interactive=false
--passwordfile ./password wines



After
the script execution is complete, open up
"http://localhost:58080/clusterjsp". The page shows it is served from
the "cabernet" instance. Enter some session data by adding values in
the text box placed towards end of the page. Then
stop the "cabernet" instance as explained in href="http://blogs.sun.com/arungupta/entry/totd_67_how_to_front">TOTD
#67 after the string "OK, now show time!".



Now load the page "http://localhost:58081/clusterjsp" and it shows that
the page is served from "merlot" instance. And the exact same session
data is displayed towards the bottom of the page.



It basically shows that the session data added in one instance is
replicated to the "buddy instance" ("merlot" in this case)
automatically.



This scipt is tested on href="http://opensolaris.org/os/downloads/">Open Solaris
2008/11, href="http://www.microsoft.com/windows/windows-vista/default.aspx">Windows
Vista, and Mac
OSX 10.5.x
.



The cluster and instance creation can be easily done using the
web-based admin console as href="http://blogs.sun.com/jclingan/entry/glassfish_clustering_in_under_10">described
here. But this TOTD also shows the power of scriptability for
common GlassFish administration commands - asadmin is your hidden gem
and learn more about it in this href="http://wikis.sun.com/display/TheAquarium/ASAdmin">recorded
webinar!



href="http://blogs.sun.com/arungupta/entry/totd_69_glassfish_high_availability">TOTD
#69 explains how to use Sun Web Server and Load-Balancer
Plugin for the load balancer + clustering setup on Windows Vista. href="http://blogs.sun.com/arungupta/entry/totd_67_how_to_front">TOTD
#67 explains the same steps for Apache + mod_jk on Mac OSX.



Technorati: href="http://technorati.com/tags/glassfish">glassfish
cli href="http://technorati.com/tags/asadmin">asadmin href="http://technorati.com/tags/clustering">clustering
highavailability

Join the discussion

Comments ( 5 )
  • AVCHD Converter Friday, April 24, 2009

    AVCHD Converter is a top-rated and professional high-definition video program which provides you a good solution to convert hd videos.


  • Alex Tuesday, April 28, 2009

    Hi, thanks for all your highly valuable information.

    I'd love to use the asadmin tool, but we deploy our rails app with the glassfish gem. Afaik the tool is not included in the latest gem release (0.9.3). Do you know of any way I can install and use this tool? One of the things we are not able to do at the moment is to create a jdbc connection pool, for instance.

    Thanks!

    Alex


  • Arun Gupta Tuesday, April 28, 2009

    Alex,

    The discussion is happening at:

    http://rubyforge.org/forum/message.php?msg_id=68249


  • Arun Gupta's Blog Wednesday, August 12, 2009
    [Trackback] The GlassFish High Availability allows to setup a cluster of GlassFish instances and achieve highly scalable architecture using in-memory session state replication. This cluster can be very easily created and tested using the "clusterjsp" sample bundl...
  • Arun Gupta's Blog Wednesday, August 12, 2009
    [Trackback] The GlassFish High Availability allows to setup a cluster of GlassFish instances and achieve highly scalable architecture using in-memory session state replication. This cluster can be very easily created and tested using the "clusterjsp" sample bundl...
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.