Here is simple script that:
- Installs GlassFish
- Creates a new domain using 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.
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 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 Open Solaris 2008/11, Windows Vista, and Mac OSX 10.5.x.
The cluster and instance creation can be easily done using the web-based admin console as 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 recorded webinar!
TOTD #69 explains how to use Sun Web Server and Load-Balancer Plugin for the load balancer + clustering setup on Windows Vista. TOTD #67 explains the same steps for Apache + mod_jk on Mac OSX.
Technorati: glassfish cli asadmin clustering highavailability
Related posts:- TOTD #142: GlassFish 3.1 – SSH Provisioning and Start/Stop instance/cluster on local/remote machines
- TOTD #67: How to front-end a GlassFish Cluster with Apache + mod_jk on Mac OSX Leopard ?
- TOTD #11: Setup Mongrel cluster for JRuby-on-Rails applications on Unix
- TOTD #69: GlassFish High Availability/Clustering using Sun Web Server + Load Balancer Plugin on Windows Vista
- TOTD #92: Session Failover for Rails applications running on GlassFish
AVCHD Converter is a top-rated and professional high-definition video program which provides you a good solution to convert hd videos.
Comment by AVCHD Converter — April 24, 2009 @ 12:06 am
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
Comment by Alex — April 28, 2009 @ 2:58 am
Alex,
The discussion is happening at:
http://rubyforge.org/forum/message.php?msg_id=68249
Comment by Arun Gupta — April 28, 2009 @ 1:16 pm
[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…
Comment by Arun Gupta's Blog — August 12, 2009 @ 6:10 am
[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…
Comment by Arun Gupta's Blog — August 12, 2009 @ 9:14 am