Oct 30, 2017

How to Set up Java EE GlassFish Cluster

After you configure one machine to have a GlassFish domain, open the admin console at localhost:4848 and select “Clusters” and create a new one for example i88caCluster. Once that’s created, click the cluster you’ve just created, go to the “Instances” tab and create a new server instance such as i88caSrv1. Now we have a cluster with an instance, we can start the cluster from the cluster’s “General” tab.

On the second machine, make sure GlassFish is installed and create another server as follows:

asadmin --host <machine1> --port <admin port> create-local-instance --cluster i88caCluster i88caSrv2

When you invoke this command, the asadmin tool on the local machine doesn’t actually execute the command; it simply asks the asadmin tool on the remote machine you specify to execute it. So if you were to type “asadmin list-instances” afterwards on machine 2, the list would be empty even though a server instance physically resides on the machine.

Running the same command on the machine where the domain is located lists all instances in the domain, whether they are physically on the machine or not.

If you want to keep your admin server separate to your server instances, you would follow the same procedure up to creating the cluster, but then create both your server instances remotely like this.

If you were to use the admin console to start the new server now, you’ll find that it won’t start. We first need to configure the new node. Select the new node in the “Nodes” and make sure the “Type” is set to SSH, Node Host is either the correct IP address or URL and the authentication settings are correct. SSH user authentication is done by default through a key file.

If you encounter communication problems, check your firewall settings etc.