Now that you have gained an understanding of the types of clustering architectures you can employ with the WebLogic cluster, the next logical step is to create an actual WebLogic cluster. To methodically assist you in this process, the following sections focus on
The Tools for Creating and Configuring a WebLogic ClusterThe primary tools you have available to create or configure a WebLogic cluster are the Domain Configuration Wizard and the Administration Console. Which tool you use depends on the type of clustering architecture you want to employ and the capabilities of these tools to support your efforts. The Domain Configuration Wizard is an excellent tool if you are creating a WebLogic cluster from scratch. This tool presents you with options on the type of WebLogic domain you want to create. One such option is a domain with an administration server and one or more managed servers that are clustered. However, this option creates the administration server and the clustered WebLogic Server instances on the same single server machine. The Administration Console is a tool that you can use to configure a WebLogic cluster from existing managed servers in a domain. For example, if your clustering architecture warrants the clustered servers to be on separate server machines, the best approach would be to create the administration server and managed servers independently on each of those machines using the Domain Configuration Wizard. After the managed servers are created and registered with the domain's administration server, you could use the Administration Console to graphically configure a cluster from the existing managed servers. You can also use the Administration Console to do the following:
Guidelines for Configuring Your WebLogic ClusterBefore you start creating your WebLogic cluster, it is worth reviewing the following guidelines for creating a cluster:
Tip As a general rule, the administration server should not handle incoming client requests because this will obstruct administration tasks from occurring in a timely fashion. Configuring a Cluster Using the Administration ConsoleThis section provides a step-by-step guide showing how you can configure a WebLogic cluster using the Administration Console. The assumptions for this exercise are that you already have a WebLogic domain set up with two managed servers, and the network configuration for the WebLogic domain adheres to the clustering guidelines discussed in the preceding section. The name of the WebLogic domain, cluster and managed servers, and their network configurations can differ from those used in the example because the steps to configure the WebLogic cluster still remain the same. To learn how to set up and configure a WebLogic domain, see "Understanding WebLogic Domains," p. 777 , "Creating and Extending WebLogic Domains," p. 785 , and "Configuring the Network Resources for a WebLogic Domain," p. 798 . As illustrated in Figure 25.8, the WebLogic cluster to be configured (mycluster) will be hosted on a single, non-multihomed server machine, which implies that the same IP address will be used for each managed server, with differing listen port numbers. The attributes of the managed servers that will be used to form the mycluster WebLogic cluster are described in Table 25.1. Figure 25.8. The mycluster WebLogic cluster on a single, non-multihomed server machine.
Tip It is good practice to visualize and document the attributes of your cluster before you create it. Table 25.1. The Attributes of the Managed Servers in the mycluster WebLogic Cluster
Tip If your server machines are dynamically assigned IP addresses, you should use the server DNS names as the listen addresses. To configure the mycluster WebLogic cluster using the Administration Console, follow these steps:
This completes the tasks related to configuring a WebLogic cluster using the Administration Console. The next section describes how you can now start your WebLogic cluster. Starting Your WebLogic ClusterYou can start a WebLogic cluster using the following methods :
To start any clustered managed server, you first need to start the administration server for the domain, which will copy the clustered configuration information to the clustered managed servers upon startup. The general steps for starting an administration server are as follows:
The following sections describe how to start the mycluster WebLogic cluster created previously using both of these methods. Starting a WebLogic Cluster Using the Command ShellYou start managed servers that participate in a WebLogic cluster in the same manner as you would start them if they were not clustered. The command syntax for starting a managed server is StartManagedWebLogic server_name address:port where
For example, to start the clustered managed servers in mycluster, you enter the following commands in separate command shells : StartManagedWebLogic NodeA EINSTEIN:7001 StartManagedWebLogic NodeB EINSTEIN:7001 As shown in Figure 25.12, during the startup process, a clustered managed server joins its WebLogic cluster and tries to synchronize information with other online managed servers in the cluster. Figure 25.12. Starting the WebLogic cluster using the command shell.
Starting a WebLogic Cluster Using the Administration ConsoleThe primary advantage of using the Administration Console to start a WebLogic cluster is that you can start all constituent clustered managed servers at the same time. Alternatively, you can start the clustered managed servers individually, if required. The Administration Console can, by default, be used to kill managed servers without the Node Manager. However, the Administration Console can only start managed servers in conjunction with the Node Manager. For this reason, even if the clustered managed servers are located on the same machine as the administration server, you need to perform the following tasks to enable the Administration Console to start a clustered managed server or a cluster of managed servers:
Even though these procedures may appear to be very complicated, they are relatively easy to perform and are methodically explained in Chapter 4. After you configure your administration server to remotely start managed servers using the Node Manager, you can follow these steps to start a WebLogic cluster:
As shown in Figure 25.13, this procedure initiates WebLogic tasks to start all the managed servers assigned to your WebLogic cluster. Figure 25.13. The Tasks screen in the Administration Console illustrating the startup of all clustered managed servers in the mycluster WebLogic cluster.
Monitoring Server Participation in Your WebLogic ClusterAfter you set up a WebLogic cluster, the next administration task is to adopt a technique that allows you to monitor the number of active servers participating in it. This task is important because in a production environment the capability to provide performance-based high availability and workload load balancing is directly influenced by the number of active managed servers that constitute a WebLogic cluster. The most immediate technique to accomplish this task is via the Administration Console using the following steps:
Alternatively, you can create a servlet or JavaServer Page to access WebLogic Server's Runtime MBeans to display customized and consolidated information about your WebLogic domain and its managed resources, including nonclustered and clustered servers. To programmatically retrieve information about a WebLogic cluster, you must access the APIs of an instance of the ClusterRuntimeMBean, which are hosted only on those managed servers actively participating in a WebLogic cluster. To assist you in creating such a servlet or JavaServer Page, Listing 25.1 provides the fully commented Java code for the infoCluster servlet, which performs the following tasks:
Listing 25.1 The infoCluster Servlet for Accessing Runtime Information about Your WebLogic Domain and Clusterimport javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.Set; import java.util.Iterator; import javax.naming.*; import weblogic.jndi.Environment; import weblogic.management.MBeanHome; import weblogic.management.configuration.ServerMBean; import weblogic.management.runtime.ClusterRuntimeMBean; import weblogic.management.WebLogicObjectName; public class infoCluster extends HttpServlet { public void service(HttpServletRequest req, HttpServletResponse res) throws IOException { // Declare MBean and other variables MBeanHome home = null; ServerMBean server = null; ClusterRuntimeMBean clusterRuntime = null; String name=""; String[] aliveServerArray = null; // Initialize Set mbeanSet = null; Iterator mbeanIterator = null; // Set the content type for the response res.setContentType("text/html"); // Obtain a PrintWriter to insert HTML into PrintWriter out = res.getWriter(); // Setup the start of the HTML page out.println("<HTML><HEAD><TITLE>infoCluster Servlet Example</TITLE>"); out.println("<BODY><H1><strong><font size=5>Your WebLogic Cluster" + "Information:</font></strong></H1>"); // Set the initial context try { Environment env = new Environment(); Context ctx = env.getInitialContext(); // Get the Administration MBeanHome home = (MBeanHome) ctx.lookup("weblogic.management.adminhome"); } catch (Exception e) { out.println("<br>Exception caught: " + e); } try { out.println("<p><BR><strong><u>Your Active Domain is " + "<font color=#000000>"+ home.getActiveDomain().getName() + "</font></u></strong></p>"); } catch (Exception e) { out.println("<br>Exception: " + e); } out.println("<p><strong> <u>The WebLogic Servers in your Domain are:" + "</u></strong></p>"); try { mbeanSet = home.getMBeansByType("Server"); mbeanIterator = mbeanSet.iterator(); while(mbeanIterator.hasNext()) { server = (ServerMBean)mbeanIterator.next(); out.println("<p><strong> <u> Server Name</u>:" + "<font color =#000000>" + server.getName() + "</font> <BR>"); out.println("ListenAddress: " + server.getListenAddress() + "<BR>"); out.println("ListenPort: " + server.getListenPort() + "<BR>"); } } catch (Exception e) { out.println("<br>Exception: " + e); } // Retrieving a list of ClusterRuntime MBeans in the domain. out.println("<p><strong><u>Your WebLogic Clustering Information:" + "</u> <BR>"); try { mbeanSet = home.getMBeansByType("ClusterRuntime"); mbeanIterator = mbeanSet.iterator(); while(mbeanIterator.hasNext()) { // Retrieving one ClusterRuntime MBean from the list. clusterRuntime = (ClusterRuntimeMBean)mbeanIterator.next(); // Get the name of the ClusterRuntime MBean. name = clusterRuntime.getName(); out.println("Cluster information retrieved from the " + "ClusterRuntime MBean on server " + name + "<BR>"); // Using the current ClusterRuntimeMBean to retrieve the number // of servers in the cluster. out.println("Number of active servers in the cluster: " + clusterRuntime.getAliveServerCount() + "<BR>"); // Retrieving the names of servers in the cluster. aliveServerArray = clusterRuntime.getServerNames(); break; } } catch (Exception e) { out.println("<br>Exception: " + e); } if(aliveServerArray == null) { out.println("<br>There are no running servers in the cluster"); } else { out.println("The running Managed Servers in the cluster are: "); for (int i=0; i < aliveServerArray.length; i++) { out.println("("+ aliveServerArray[i] + ")" +" "); } } out.println("</strong> </p></BODY></HTML>"); } } Note You can find the full list of APIs for the ClusterRuntimeMBean in WebLogic Server's JavaDoc documentation, which you can download from e-docs.bea.com . The infoCluster servlet should be deployed to your administration server to ensure you are monitoring your WebLogic cluster from an external server. The output of the infoCluster servlet is shown in Figure 25.15. Figure 25.15. The output of the infoCluster servlet in a browser.
|