GlassFish v2 Offline Configuration
By Byronnevins-Oracle on Feb 15, 2010
Review of Clustering Features in GlassFish v2
A typical GlassFish v2 enterprise installation consists of one administration domain controlled by the Domain Administration Server (DAS) which handles all of the administration duties of the domain. The domain provides a common authentication and administration point for a collection of Java EE server instances.
Each JavaEE server instance gets it's configuration from DAS and has its lifecycle controlled by a Node Agent. A Node Agent is a very light-weight process that DAS interacts with. Node Agents and remote Java EE server instances synchronize with DAS during startup to get the latest configuration from the central repository managed by DAS.
GlassFish v2 supports the concept of cluster where multiple Java EE server instances can be grouped for horizontal scalability. Each Java EE server instance in a cluster shares the same set of applications and configuration information.
Say you have a running DAS (Domain Administration Server) and you wish to add a cluster, a few instances and a Node Agent running on a separate machine. Here is how you would do an online configuration:
- Login to the new Node Agent machine
- asadmin create-node-agent NA-Name
- asadmin create-cluster
- asadmin create-instance (probably need to run this command a few times)
- asadmin start-node-agent
You can see how if you have a lot of machines this can become a headache. Note that create-instance has many required parameters that I'm not showing here.
Offline Configuration lets you do all of the configuration right from the DAS machine. On each Node Machine you run two very simple commands:
- asadmin create-node-agent NA-Name
- asadmin start-node-agent NA-Name
There are several good reasons for developing scripts for offline configuration of complex GlassFish installations:
- You can develop scripts that will exactly recreate your system from scratch. I'm talking about deploying your applications, setting complicated jvm-options, configuring database connections, setting up multiple clusters and instances -- the works! This is very powerful. I have a personal website that has been running v2 for 4 years or so. I can recreate the entire site anytime I like on any new machine that has v2 installed. It has a ton of applications, a database, etc.
- You need the complicated configuration information to be used on just one machine, DAS, in a multiple machine installation.
- You can replace a Node easily at any time
- No restarts are needed during the creation of the instance, cluster and node-agent configuration since it is all being done offline. Once ALL of the configuration is complete everything is started at once and no restarts will be needed. This is a key difference with online configuration.
- Faster to automate a multi-node GlassFish cluster setup with desired configuration.
- It works!
Example Offline Configuration Session
Generally one would want to edit a script and run the script. Here is a an example session to show you how to do it from a command line:
(For clarity the credentials such as --user and --passwordfile are left out of the commands)
- asadmin start-domain
- asadmin create-cluster c1
- asadmin create-node-agent-config na1
- asadmin create-node-agent-config na2
- asadmin create-instance --cluster c1 --node-agent na1 i1_1
- asadmin create-instance --cluster c1 --node-agent na2 i2_1
- asadmin create-instance --cluster c1 --node-agent na2 i2_2
We didn't start anything. All of the commands changed the configuration in the domain.xml. Namely it created 1 new cluster with 2 node agents and a total of 3 instances.
To get everything running we do this:
- For each machine (in this case 2 separate remote machines with v2 binaries installed)
- asadmin create-node-agent na1 or na2
- asadmin start-node-agent na1 or na2
- note: the Node Agent name must match exactly the name in create-node-agent-config above. Otherwise you will get a new Node Agent created!