Skip to main content

Configuring WLS 12.1.2 as a two server cluster on a single UNIX host

Posted by edburns on April 25, 2014 at 6:00 AM PDT

We've been using TDD for Mojarra for nearly a decade now and after all that time, we have decent number of tests. For historical reasons these tests mostly use GlassFish, but we are naturally migrating them to use WebLogic Server. As part of that work, I had to learn how to set up a simple cluster in WebLogic Server 12.1.2 to validate the fix for this bug that prevents @ViewScoped beans from working in a clustered environment. The process was sufficiently involved that I felt it useful to document here, if nothing else than for my own reference. Please excuse its crudity. The steps below are not exactly in the order in which I executed them, but they are in the order in which they should best be executed.

I was able to glean nearly all of what I needed from the Oracle WebLogic documentation, but there were a few gotchas I encountered.

  • WLS 12.1.2 requires JDK 7. Install that. Then install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 7 into the JRE of that JDK. (For JDK 6 use this link.) This is necessary to enable the client state encryption exercised by my test.

  • Install the wls1213_dev.zip downloaded from OTN. Just follow the README.txt. Take all the defaults. My host is adc00ooo, so that's the hostname you'll see in this blog entry. Obviouly this won't work for you. Allow the install to setup a domain and let it start. Access the admin console at http://adc00ooo:7001/console/. Shut it down by visiting Environment::Servers::Control, checking myserver, and choosing Shutdown::Force Shutdown Now.

  • Restart the server using the startWebLogic.sh script. If this doesn't work, find help elsewhere!

  • Now the cluster-specific stuff begins.

    Create the Cluster

    • Click Home::Environment::Clusters. Click New::Cluster. Set name as cluster1. Click OK. This returns you to the "Summary of Clusters" page.

    • Click on the link for the freshly created cluster1.

    • Set the Cluster Address to be adc00ooo. Click Save.

    Create A Machine

    A Machine is a WLS admin abstraction that lets the wls admin server interact with an important standalone Java program called the NodeManager. More on that later. Think of it as the thing that contains the managed server instances that form the nodes of your cluster.

    • Click Environment::Machines.

    • Click New. Set the name as machine1 and set the Machine OS to UNIX. Click Next.

    • Set the listen address to 10.228.243.134 (the IP address of adc00ooo). For some reason the hostname didn't work, but the IP address did. Leave the rest as is. Click finish. This takes you to the "Summary of Machines" page. Click the link for the newly created Machine.

    • Click the Node Manager tab and verify the Listen Address and Listen Port are as expected. Note them down somewhere.

    Create the Managed Servers for the Cluster

    • Click Environment::Servers. Click New.

    • Fill in server name as server1.

    • Fill in Server Listen Address as adc00ooo.

    • Fill in Server Listen Port as 18080.

    • Select the radio button, "Yes, make this server a member of an existing cluster". Make sure cluster1 is selected in the menu drop down.

    • Click Next.

    • Review the choices and click Finish.

    • Repeat the steps in this section but use server2 and 28080 as the Server Name and Listen Port.

    Add the Managed Servers to the Machine

    • Click Environment::Machines. Select machine1.

    • Click the Servers tab.

    • Click Add.

    • Choose the "Select an existing server and associate it with this Machine" radio button. Ensure server1 is shown in the "Select a server" dropdown.

    • Click next.

    • Repeat the steps in this section but select "server2" this time.

    Ensure the Managed Servers are Enabled for Source Level Debugging

    If you wish to attach a JPDA enabled source level debugger to your server instances, it's easy to do!

  • Click Environment::Servers and select server1.

  • In the "Settings for server1" page, select the "Server Start" tab. In the "Arguments" text area, add this value.

    -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=19009,server=y,suspend=n -Djava.compiler=NONE

  • Click "Save". Repeat the steps in this section for server2, being sure to use 29009 as the address instead of 19009.

  • This concludes the first phase of the WLS server config. For good measure stop and restart WLS before continuing.

  • Start the NodeManager in its own shell

    • Open up a new shell, cd to the MW_HOME (which is defined in the README.txt for the WLS install)

    • Run the "./wlserver/server/bin/setWLSEnv.sh" script.

    • Create a script that sets the following environment variables.

      export LISTEN_ADDRESS=adc00ooo export LISTEN_PORT=5556 export JAVA_OPTIONS="-DDomainsFile=/home/ejburns/Documents/JavaEE/runtimes/wls1212/wls12120/./user_projects/domains/mydomain/nodemanager/nodemanager.domains -DNativeVersionEnabled=false" 
    • Execute this command:

      cp ./user_projects/domains/mydomain/security/DemoIdentity.jks   /scratch/ejburns/Documents/JavaEE/runtimes/wls1212/wls12120/oracle_common/common/nodemanager/security/DemoIdentity.jks
    • Execute ./wlserver/server/bin/startNodeManager.sh

      This should just keep running and not return. You'll have to press Ctrl-C to exit it when you're all done running the cluster.

    • You should see a message similar to this in the window from which you ran the startNodeManager.sh script.

      Secure socket listener started on port 5556, host adc00ooo/10.228.243.134

  • Start Each Node in the Cluster

    Now that NodeManager is running, it's time to start each server in the cluster.

    • Back in the WLS admin web app, Select Environment::Clusters cluster1.

    • In the "Settings for cluster1" page, select the "Control" tab.

    • Check the checkbox next to server1 and press the Start button.

    • You should see TASK IN PROGRESS in the "Status of Last Action" column for the server1 row.

    • Check the checkbox next to server2 and press the Start button.

    • You should see TASK COMPLETED in the "Status of Last Action" column for the server1 row, and TASK IN PROGRESS in the same column for the server2 row.

    • Click Environment::Servers and see that both server1 and server2 are running.

  • Finally, we are able to deploy the app to the cluster!

    • Ensure the app's web.xml has the < distributable / > element. If this is not present, the container will not enable session replication.

    • Click Deployments in the Domain Structure tree browser.

    • Click the Install button.

    • Use the file browser to navigate to the directory containing your .war file that has in its web.xml.

    • Select the radio button next to the war file and press Next.

    • Ensure the "Install this deployment as an application" radio button is selected and click Next.

    • In the "Available targets for test-cluster-javaee6web-viewScoped" area there should be a box labeled Clusters, within which is an entry labled cluster1. Chcek the checkbox next to cluster1. Ensure the radio button next to "All servers in the cluster" is selected. Click Next.

    • On the next page, click Finish.

    • If you are tailing the log files for the individual Managed Servers,

      ./wls12120/user_projects/domains/mydomain/servers/server1/logs/server1.log

      ./wls12120/user_projects/domains/mydomain/servers/server2/logs/server2.log

      You should see a message similar to this:

      Initializing Mojarra 2.2.7 (-SNAPSHOT 20140425-1959 https://svn.java.net/svn/mojarra~svn/branches/MOJARRA_2_2X_ROLLING@13182) for context '/test-cluster-javaee6web-flow-basic_faces_flow_call'

  • You can now test the app.

Related Topics >>

Comments

Save some steps by simply starting NodeManager from the ...

Save some steps by simply starting NodeManager from the domain dir:

$ user_projects/domains/base_domain/bin/startNodeManager.sh

Starting from 12c, the node manager scripts are now part of the domain for easier setup.