GlassFish 3.1: Clusters Without SSH

GlassFish 3.1 has the ability to use SSH to centrally administer some basic instance lifecycle operations (such as creating and starting an instance). But in some cases you may not want to deal with SSH, and would rather just create and start those instances directly yourself. GlassFish 3.1 supports that too. This blog describes how to set up a two instance cluster across three machines without using SSH.

As part of this procedure you will be enabling secure admin on the GlassFish Domain Admin Server. You can read more about secure admin at Tim's blog.

1) Install GlassFish 3.1

First download install GlassFish 3.1 on three machines. One machine will run the Domain Admin Server (DAS) and the other two machines will each run one GlassFish instance. Let's call these systems dashost, host1 and host2.

Some things to keep in mind:

  1. Install JDK 6 Update 24 or later on each system. You absolutely will have problems if you run GlassFish with anything earlier than update 22.
  2. If you run the installer make sure to choose this JDK to use. If you use the zip distribution of GlassFish you can configure GlassFish to use a particular JDK by adding a line like this to glassfish3/glassfish/config/asenv.conf (asenv.bat for windows):  AS_JAVA="/opt/jdk/jdk1.6.0_24" (make sure to specify the correct path for your system).

2) Start the DAS, enable secure admin and create the cluster

On the system dashost start the domain and verify your JDK version:

dashost$ asadmin start-domain
dashost$ asadmin version --verbose
Version = GlassFish Server Open Source Edition 3.1 (build 43), JRE version 1.6.0_24
Command version executed successfully.

Verify that the JRE version is 1.6.0_24 or newer. If it isn't, make sure asenv.conf has AS_JAVA set to the correct path and restart the domain.

Next, enable secure admin and verify it is working:

dashost$ asadmin enable-secure-admin
dashost$ asadmin stop-domain
dashost$ asadmin start-domain 
dashost$ asadmin version --verbose
. . .
0070: 38 67 51 0D F8 AF 3E 6F C7 58 02 DB 3B 70 22 66 8gQ...>o.X..;p"f
Do you trust the above certificate [y|N] --> y
Version = GlassFish Server Open Source Edition 3.1 (build 43), JRE version 1.6.0_24
Command version executed successfully.

Note that you are prompted to accept a certificate. This happens the first time you connect to the DAS from a host after enabling secure admin. Answer 'y' and you should see the version information reported.

If you get an error about the server not accepting a secure connection, or if the command hangs then odds are you are not running with JDK 1.6 update 24 or newer.

Next, create the cluster that the instances will be in:

dashost$ asadmin create-cluster cluster1

3) Create instances on the remote systems

Now log into your remote systems and create the instances. We will once again verify the JDK version first. It should look something like this:

$host1 asadmin version --local --verbose
Using locally retrieved version string from version class.
Version = GlassFish Server Open Source Edition 3.1-b43 (build 43)
asadmin Java Runtime Environment version: 1.6.0_24
Command version executed successfully.

The --local option says to report the version of the JDK from the local GlassFish installation that asadmin is running out of and not the version information from the DAS. Now run the version command one more time against the DAS to ensure secure admin is working when we connect from host1:

host1$ asadmin --host dashost version --verbose
. . .
0070: 38 67 51 0D F8 AF 3E 6F C7 58 02 DB 3B 70 22 66 8gQ...>o.X..;p"f
Do you trust the above certificate [y|N] --> y
Version = GlassFish Server Open Source Edition 3.1 (build 43), JRE version 1.6.0_24
Command version executed successfully.

Once again you may need to accept the certificate if you are connecting from the host for the first time. Now we're ready to create and start the instance:

host1$ asadmin --host dashost create-local-instance --cluster cluster1 instance1
. . .
Command create-local-instance executed successfully.
host1$ asadmin start-local-instance instance2
. . .
Admin Port: 24849
Command start-local-instance executed successfully.

Now repeat this on host2, and your cluster is up and running.

4) Inspect your setup

Now that the cluster is up and running you can take a look at a few things:

dashost$ asadmin list-clusters
cluster1 running
dashost$ asadmin list-instances --long
instance1 host1 24848 17744 cluster1 running
instance2 host2 24848 21768 cluster1 running
Command list-instances executed successfully.
dashot$ asadmin list-nodes --long
localhost-domain1 CONFIG localhost /export/glassfish3
host1 CONFIG host1 /export/glassfish3 instance1
host2 CONFIG host2 /export/glassfish3 instance2

Note that in addition to the instances being created, a node was created for each remote GlassFish installation where create-local-instance was run from. This is a feature of create-local-instance -- it will auto-create a node for you when the first instance on the system is created.

If you rather name the nodes yourself (instead of having create-local-instance use the host name as the node name) you can run create-node-config nodename to create an empty node, and then pass this node to create-local-instance using the --node option. Create-local-instance will then populate the node with the correct information.

The third node listed, localhost-domain1, is a built-in node that is used when creating instances local to the DAS (on the same host and using the same GlassFish installation as the DAS).

5) Starting the Instances

Since the instances are remote from the DAS, and SSH is not being used, the DAS can't start the instances. That means the commands start-instance and start-cluster will not work on these instances. Instead you must always use start-local-instance directly on the instance system to start the instance.

A second option is to install the instance as a native OS service, and use the OS service framework to start and stop the instance. See the asadmin create-service command. For more information see Byron's blog on OS services and GlassFish.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.