Creating and monitoring a Glassfish Cluster

In this post I will detail how to create a basic Glassfish cluster and how to monitor it using JMX. First, download the latest release of Glassfish and extract the archive to a folder of your choice. Then start the asadmin utility from the glassfish4\bin directory. Unless otherwise noted, all of the commands that follow will be executed using this tool.

In order to manage the cluster, we first need to set up a domain administration server (DAS). Delete the default domain:

> delete-domain domain1

Afterwards, create a new domain for the das (replace afqa with a name of your domain):

> create-domain afqa-das
Enter admin user name> admin
Enter the admin password> *****
Enter the admin password again> *****

In general, it is good practice to enable the secure admin feature for your new domain:

> start-domain afqa-das
> enable-secure-admin
Enter admin password for user "admin"> *****
> restart-domain afqa-das
> login
Enter admin user name> admin
Enter admin password> *****

With the DAS running, we can create the cluster and set the properties and options that will enable us to remotely monitor the instances via JMX:

> create-cluster afqa-cluster
> create-node-config --nodehost node01
> create-system-properties --target afqa-cluster-config JMX_REMOTE_PORT=60600
> create-jvm-options --target afqa-cluster-config${JMX_REMOTE_PORT}
> create-jvm-options --target afqa-cluster-config
> create-jvm-options --target afqa-cluster-config

Now, create a couple of instances:

> create-instance --cluster afqa-cluster --node node01 --systemproperties JMX_REMOTE_PORT=60600 node01-1
> create-instance --cluster afqa-cluster --node node01 --systemproperties JMX_REMOTE_PORT=60601 node01-2

Note the HTTP_LISTENER_PORT and JMX_REMOTE_PORT for each instance – we will need these to connect to the instances.

Start up the cluster and verify that we can connect to the instances via HTTP and JMX:

> start-cluster afqa-cluster
> get-health afqa-cluster
node01-1 started since Fir Mar 04 13:45:12 PST 2016
node01-2 started since Fir Mar 04 13:45:11 PST 2016

At this point you should be able to navigate to each instance in a browser:

Finally, verify that you can connect to your instances via JMX by using JVisualVM and providing the service URL:


Leave a Reply

Your email address will not be published.