Sun GlassFish Enterprise Server 2.1 Quick Start Guide

Chapter 2 Setting Up a Cluster

This chapter describes how to create and set up clusters. A cluster is a group of server instances (typically on multiple hosts) that share the same configurations, resources, and applications. A cluster facilitates load balancing across server instances and high availability through failover. You can create clusters spanning multiple machines and manage them with the help of the node agent process on each machine.

This chapter assumes that you are running a domain with cluster profile or enterprise profile. This chapter has the following sections:

Creating a Cluster

This section explains how to create a cluster that contains two Enterprise Server instances, both residing on a single machine.

ProcedureTo Set Up a Cluster

This procedure creates the sample cluster one the same host on which the DAS is running.

Before You Begin

It is assumed that you have already started the node agent. When you specify instances during cluster creation, associate the instance with a running node agent for the machine on which you want the instance to run. If the node agent is not running, the instance will not start. Node agent and instance names must be unique across clusters that are created in a domain.

  1. Log in to the Administration Console at http:// hostname:portnumber if you have not already done so.

    Replace the hostname variable with the name of the system that the Domain Administration Server is running on. Replace portnumber with the port number of the cluster domain, domain1.

  2. On the left pane, click the Clusters tab.

  3. To create a cluster, do one of the following:

    • On the right-hand pane, click new and type cluster1 as the name. Click OK.

    • Use the following command: asadmin create-cluster --user admin --passwordfile adminpassword.txt --host hostname -port 4848 cluster1

  4. Click cluster1 . The General Information for this cluster appears.


    Note –

    In the General tab on the right hand pane, ensure that the Heartbeat Enabled checkbox is selected. You need GMS service to be running to be able to use the converged load balancer.


  5. On the right pane, click the Instances tab. Click the New button to create two entries to specify two instances for the cluster.

  6. Type instance1. In the Node Agent field, nodeagent1 is selected by default.

  7. Type instance2. In the Node Agent field, nodeagent1 is selected by default. Click Save.

    Instead of steps 4,5, and 6 you can use the following asadmin commands:

    • asadmin create-instance --user admin --passwordfile adminpassword.txt --host hostname -port 4848 --cluster cluster1 --nodeagent nodeagent1 --systemproperties "JMX_SYSTEM_CONNECTOR_PORT=8687:IIOP_LISTENER_PORT=3330:IIOP_SSL_LISTENER_PORT=4440:IIOP_SSL_ MUTUALAUTH_PORT=5550:HTTP_LISTENER_PORT=1110:HTTP_SSL_LISTENER_PORT=2220" instance1

    • asadmin create-instance --user admin --passwordfile adminpassword.txt --host hostname -port 4848 --cluster cluster1 --nodeagent nodeagent1 --systemproperties "JMX_SYSTEM_CONNECTOR_PORT=8688:IIOP_LISTENER_PORT=3331:IIOP_SSL_LISTENER_PORT=4441:IIOP_SSL_ MUTUALAUTH_PORT=5551:HTTP_LISTENER_PORT=1111:HTTP_SSL_LISTENER_PORT=2221" instance2

  8. To start the cluster,

    • Click the General tab and click the Start Cluster button.

    • Start the cluster and its instances by running the following command:

      asadmin start-cluster --user admin --passwordfile adminpassword.txt --host hostname --port 4848 cluster1

    The two instances are started by default when you start the cluster.

Creating a Cluster that Spans Multiple Machines

ProcedureTo Create a Cluster With Instances On Different Machines

The following procedure demonstrates how to create a cluster that has two instances, instance3 and instance4, each running on different machines. The two machines are called schumi and sr115. schumi is the machine that is denoted as the administrative node and is called the Domain Administration Server (DAS).

Before You Begin

You must have already installed Enterprise Server on both machines.

  1. Create and start a node agent (nodeagent2) on the DAS machine.

    Use the following command: asadmin create-node-agent --user admin --host schumi nodeagent2

  2. Start the node agent on the DAS machine.

    Use the following command: asadmin start-node-agent --user admin --host schumi nodeagent2. For more information, see start-node-agent(1) command.

  3. Create a start a node agent on another machine.

    This example uses a second machine called sr115. On the second machine, at the invoke the asadmin utility and use the following command: asadmin create-node-agent --user admin --host schumi nodeagent3


    Note –

    You need to provide the DAS machine name in the --host option.


  4. Start the node agent on the second machine.

    Use the following command: asadmin start-node-agent --user admin --host schumi nodeagent3. For more information, see start-node-agent(1) command.

  5. Log in to the Admin Console of the DAS machine at http:// das-machine-name:portnumber.

    You can see that the two node agents are running if you click Node Agents on the left-hand tree on the Admin Console.

  6. On the left pane, click the Clusters tab and click New.

  7. Specify a name for the cluster.

    This example creates a cluster with the name, mycluster.

  8. In the Server Instances to be Created section, click New.

  9. Type the instance name as instance3 and choose node agent, nodeagent3.

    nodeagent3 was created on the machine called sr115 in step 2 of this procedure.

  10. Type the instance name as instance4 and choose node agent, nodeagent2.

    nodeagent2 was created on the DAS machine called schumi in step 1 of this procedure.

  11. Click OK.

    The cluster gets created.

  12. In the left pane, click Clusters.

  13. In the right pane, select the checkbox next to mycluster and click the Start Cluster button,

    The cluster and the two instances start.

    The two instances in mycluster are running on different machines and are controlled by different node agents. You can view the two node agents and see each instance associated with it.

    If you deploy an application on mycluster, the application is accessible from two machines.

Viewing Ports for Clustered Server Instances

ProcedureTo View Ports for Clustered Server Instances

You can view the ports numbers and override the default values for the clustered server instance you created in the previous section, Creating a Cluster . By default, the HTTP ports are 38081 for instance1 and 38080 for instance2. If these ports were busy on your machine when you created these clusters, or if you had already assigned these ports to other instances and clusters, different port numbers were assigned.

To view the port numbers and optionally override the default values, follow these steps:

  1. In the left pane, expand Clusters and click cluster1 to display the General Information page for clusters.

  2. Click the Instances tab to display instance1 and instance2, the instances that you created.

    1. Click instance1 to examine this instance.

      The HTTP and HTTPS ports assigned to the instance are displayed in the HTTP Ports field. The SIP and SIPS Ports are displayed in the SIPS field.

Next Steps

In this section you have created a simple cluster on a single machine. You can also create clusters spanning multiple machines using the same basic steps (as long as you have the software installed and a node agent running on each machine).