GlassFish 3.1 and create-local-instance
By Jennifer Chou on Feb 28, 2011
GlassFish Server Open Source Edition 3.1 is just released with clustering capability! If you have SSH setup on your machines, you can create the clusters and instances just from the DAS (Domain Administration Server) machine using the asadmin commands: create-cluster and create-instance. However, if you don't have SSH setup, you can still create a cluster. You will need to go to each machine and run the create-local-instance command locally.
The create-local-instance command is actually a hybrid command, meaning it's a local command which creates the local filesystem structure, then calls a remote hidden command (_register-instance) to register the instance with the DAS. Registering the instance with the DAS entails creating a server element in the DAS domain.xml.
For example if you want to setup a clustered instance on machine B with the DAS on machine A,
0. Make sure you can ping machine A from machine B. Note the host name or IP address you use for this.
1. Install GlassFish on each machine, machine A and machine B.
Machine A = DAS
Machine B = remote instance
2. Start DAS on Machine A
3. On DAS (machine A) create cluster1
glassfish3/glassfish/bin/asadmin create-cluster cluster1
4. On machine B create instance1 (The default das port is 4848. Specify --port to use a different port.)
glassfish3/glassfish/bin/asadmin --host machineA create-local-instance --cluster cluster1 instance1
A few things will happen...
1. This will create a node, machineB.
a) On machine B, a directory for machineB is created under
glassfish3/glassfish/nodes/machineB (if the instance is on the same machine as DAS this will be localhost-domain1).
b) A node element for machineB is created in DAS domain.xml.
2. The DAS connection properties for node machineB is created
Under directory machineB is agent and instance1. Under agent is the config/das.properties. The das.properties holds the DAS host and port information used by the node, machineB, to connect to the DAS.
The das.properties is created the first time an instance is created for a particular node. The node machineB will now always connect to the DAS using this das.properties. Any instance which uses this node machineB, will talk to the same DAS using the same host and port. If you want to connect to a different DAS, you can either edit das.properties manually (all instances under that node would be affected), or create a new node using create-node-config and calling create-local-instance with a different DAS host/port.
3. A directory for instance is created under node machineB.
The directory for instance 1 is created at glassfish3/glassfish/nodes/machineB/instance1. The instance1/config will contain the keystore information. Once you start the instance using start-local-instance, this instance1 directory will get synchronized with the DAS.
4. The instance1 is registered on DAS.
In DAS domain.xml:
5. The instance1 is also registered to all the other instance within the cluster.
The instance1 is also registered to all the other instances in the cluster if they are up and running. All the instances in the cluster will know about each other.
Now you can start the newly created instance1 on machineB
asadmin start-local-instance instance1