Weblogic‎ > ‎

Cluster

http://www.theserverlabs.com/blog/2009/05/29/setting-up-a-load-balanced-oracle-weblogic-cluster-in-amazon-ec2/





Creating the Weblogic domain

The Weblogic domain is the basic configuration building-block so one of our first steps is to create a domain.

Open an SSH session to machine-0. How you do this will depend on your environment - windows or linux/unix. On linux, I run the following to access a machine, where FirstKeyPair.pem is a keypair that I created in AWS management console and saved to my local machine (replace [machine-0] with the public DNS for machine-0]:

local:~$ ssh -i $HOME/keypair/FirstKeyPair.pem root@[machine-0]

Once logged in, accept the Oracle license. On the jumpstart menu which appears, select option 2; Launch the WebLogic Configuration Wizard and:

  1. Enter 1 to create a new Weblogic Domain
  2. Enter 1 - “Choose Weblogic Platform components”
  3. Type “Next” on the “Application Template Selection” ’screen’
  4. Enter weblogic for username and password
  5. Select “Development mode” when prompted
  6. Select “JRockit SDK 1.6.0_05 @ /opt/oracle/jrockit” when prompted for the “Java SDK Selection”
  7. Select No when asked “Do you want to modify any of the preconfigured settings or defaults in your template?”
  8. For the “Target Location”, select “/mnt/domains”
  9. On the “Domain Information” screen, enter “test_domain” as the domain name

Starting the Weblogic Administration Server and configuring the cluster

Now that we have a domain, we start up the administration server. This will allow us to further configure the domain using a nice web interface instead of the command line. Start up the newly created weblogic server by executing the following on machine-0:

/mnt/domains/test_domain/startWebLogic.sh

Go to http://[machine-0]:7001/console (make sure port 7001 is open in your security group) and perform the following steps to create the two Managed Servers which form the cluster:

  1. Log in with the credentials weblogic/weblogic
  2. Click on the Servers link
  3. Click on the New button
  4. For Server Name, enter “server-0″
  5. Set the server listen address to the machine-0 name i.e the Amazon public DNS for machine-0
  6. Set the port to 7002
  7. Select “Create a new cluster for this server” and click next
  8. call the cluster “cluster-0″
  9. Select messaging mode “unicast” (the default)
 10. click Finish

Create “server-1″ using similar steps:

  1. Click on the Servers link
  2. Click on the New button
  3. For Server Name, enter “server-1″
  4. Set the server listen address to the machine-1 name i.e the Amazon public DNS for machine-1
  5. Set the port to 7002
  6. Select “Add to an existing cluster”, select cluster-0 and click finish

At the end of this process, the cluster and server configuration should look like this:

ec2-wls-cluster

Click on Clusters and then click on cluster-0. In the General > Configuration tab, expand the “advanced” option and tick the “WebLogic Plug-In Enabled” option. This means that we can later use the Weblogic Apache proxy plugin to do load balancing in later sections of this post. Copying the managed server configuration

The domain configuration currently only exists in the administration server domain. We have to copy it to a separate folder on machine-0 and a new folder on machine-1. These copies of the domain configuration will be used by the Managed Servers.

Open up another SSH console window to machine-0. Pack up the domain configuration by executing:

cd /mnt/domains/ /opt/oracle/weblogic/common/bin/pack.sh -managed=true -domain=test_domain -template=test.jar -template_name="test"

Create a new domain folder on machine-0 for managed-server-0:

cd /mnt/domains /opt/oracle/weblogic/common/bin/unpack.sh -domain=test_domain_server0 -template=/mnt/domains/test.jar

Start server-0. Supply weblogic/weblogic as the username/password when prompted.

/mnt/domains/test_domain_server0/bin/startServer-0.sh

Copy the test.jar configuration over to machine-1. To do this, I had to upload my private key from my local machine to machine-0 (how you do this will depend on your OS, instructions below for linux/unix):

local:-$ scp $HOME/keypair/FirstKeyPair.pem root@[machine-0]:/mnt

Then, on machine-0 execute:

chmod 700 /mnt/FirstKeyPair.pem scp -i /mnt/FirstKeyPair.pem test.jar root@[machine-1]/mnt

On machine-1 execute:

cd /mnt/domains/ /opt/oracle/weblogic/common/bin/unpack.sh -domain=test_domain_server1 -template=/mnt/test.jar

Then, start up the server for machine-1 entering weblogic/weblogic as the username/password when prompted.

/mnt/domains/test_domain_server1/bin/startServer-1.sh

After a short while, you should see all the servers shown as available in the “servers” view in the weblogic admin console (http://[machine-0]:7001/console). Checking that the servers work OK

Now that we have the servers set up, we can upload a sample application that will be deployed in the cluster. You can download the app from here and the source code from here. Upload the sample web app EAR file to the admin server. This will depend on your machine configuration. On linux the command is:

scp -i $HOME/keypair/FirstKeyPair.pem clustered-ear-1.0-SNAPSHOT.ear root@[machine-0]:/mnt

In the weblogic administration console (http://[machine-0]:7001/console), execute the following steps to deploy the application to all members of cluster-0:

  1. Click on the deployments link
  2. Click on the install button
  3. Go to /mnt/ and select the file clustered-ear-1.0-SNAPSHOT.ear and click next
  4. Select “Install this deployment as an application” and click next
  5. On the targets page, tick the “All servers in the cluster” box and click next
  6. On the following page, accept the defaults and click ‘finish’

Check that you have enabled port 7002 in the security configuration. Go to port 7002 on each of the 2 machines to check that you get the JSP welcome page:

http://[machine-0]:7002/clustered-webapp/ http://[machine-1]:7002/clustered-webapp/

You should get a different IP returned in the web page for each different server.

Comments