Session clustering

Building a cluster using GlassFish is a little tricky and involves using both command line and the admin panel, but it is completely doable! Let's check it out.

First, you need two or more instances (called nodes) up and running. You can do it in any way you like—each one running in a different machine, using virtual machines or containers (my favorite option). Either way you choose, the way of getting the cluster up is the same:

  1. So, get your first node and open its admin panel:

https://[hostname]:4848

  1. Click on the Clusters option in the left menu and then click on the New button.  Name the cluster myCluster and click on the OK button.
  2. Select your cluster from the list. In the opened page, select the Instances option in the tab and then click on New. Name the instance node1 and click on OK.
  3. Now, go the General tab and click on the Start Cluster button. Voilá! Your cluster is up and running with your first node.
  4. Now, go to the second machine (VM, container, other server, or any server) with GlassFish already installed and run this command:
$GLASSFISH_HOME/bin/asadmin --host [hostname_node1] --port 4848 create-local-instance --cluster myCluster node2

This will set the second machine as a member of the cluster. If you refresh the Cluster page on the first machine, you will see the new member (node2).

  1. You will notice that node2 has stopped. Click on it and in the new page click on the Node link (it will usually show the hostname of node2).

 

  1. In the opened page, change the Type value to SSH. Some new fields will show up in a SSH section.
  2. Change SSH User Authentication to SSH Password and fill the SSH User Password field with the proper password.
  3. Click on the Save button. If you run some SSH error (usually connection refused), set the Force option to Enabled, and click on Save button again.
  4. Go back to the command line on the machine hosting node2 and run this command:
$GLASSFISH_HOME/glassfish/lib/nadmin start-local-instance --node [node2_hostname] --sync normal node2

If everything went well, your node2 should be up and running and you should now have a real cluster. You can repeat these steps how ever many times you need to add new nodes to your cluster.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.58.194