Creating J2EE Cluster Using File Based Repository
Creating J2EE Cluster
by Using File-Based Repository
This tutorial describes how to create a cluster, configure,
and enable stateless and stateful failover of applications by using the cluster.
In addition, you learn to manage application server clusters
by using Oracle Enterprise Manager Application Server Control. You use file-based
repository for configuring the clusters.
Approximately 40 minutes
This tutorial covers the following topics:
Place the cursor over this icon to load and view
all the screenshots for this tutorial. (Caution: Because this action loads all
screenshots simultaneously, response time may be slow depending on your Internet
connection.)
Note: Alternatively, you can place the cursor over
each individual icon in the following steps to load and view only the screenshot
associated with that step.
An Oracle Application Server cluster is a set of application
server instances configured to act together to deliver greater scalability and
availability than a single instance can provide. Whereas a single application
server instance can leverage the operating resources of only a single host,
a cluster can span multiple hosts thereby distributing application execution
over a greater number of CPUs. Whereas a single application server instance
is vulnerable to the failure of its host and operating system, a cluster continues
to function despite the loss of an operating system or host, hiding any such
failure from clients. Oracle Application Server clusters managed using a file-based
repository designate an application server instance as the repository host.
The repository host uses its file system to store the metadata repository that
contains the metadata and configuration information for the cluster.
Back to Topic List
Before starting this tutorial, you should:
| 1. |
Install two J2EE and WebCache type mid-tier instances
on either two different machines or on one machine but in two different
<ORACLE_HOME> directories. For this OBE, the first instance named
j2ee1has been installed on the machine edrsr1p1and the second
instance named j2ee23 has been installed on the machine edrsr23p1.
|
| 2. |
Ensure that the two machines recognize each other by name (not just the
IP address) if the repository is on a different machine. You should enable
this name resolution suitably at the DNS or locally at each machine. For
this OBE, you use two different machines (edrsr1p1 and edrsr23p1).
|
| 3. |
Download the zip
file and extract it to your working directory. After extracting it, you
should have hademo.ear and Kill.exe in your working directory.
Kill.exe is to be used for simulating failure of processes on Windows
platform. |
Back to Topic List
| 1. |
Open your browser and enter the following URL:
http://<hostname>.<domain>:port/
where
<hostname>.<domain> is the host name and domain of the machine where the first instance is running (for example, edrsr1p1)
port is the port number where Oracle Enterprise Manager 10g Application Server Control is running (for example, 1810)
Note: 1810 is the default port that is automatically assigned while installing Application
Server. However, if another instance is already running on 1810, then the next port may be assigned during installation. You can check the port assignments for components of Oracle Application Server installation in the setupinfo.txt file located in <ORACLE_HOME>/install folder.
The Oracle Enterprise Manager 10g Application Server Control's Instance Home page is displayed.
Log in as ias_admin/<admin password you specified during install> and click OK.
|
| 2. |
Application Server Control displays the j2ee1
instance page. Also note that the page does not mention anything about
farm.

|
| 3. |
Open another browser window and log in to the second
instance. For this OBE, the second instance (j2ee23) is running
on server edrsr23p1, and the Application Server Control is on port
1810.

|
| 4. |
The second instance (j2ee23) page is displayed.
Also note that the page does not mention anything about farm.

|
Back to Topic List
| 1. |
Switch back to the browser window that is displaying
the Application Server Control for instance j2ee1. Application
server instance j2ee1 on edrsr1p1 has been chosen to host
the file-based repository. Click the Infrastructure link to navigate
to the infrastructure property page.

Notice that the Farm Repository is not configured.
Click Configure in the OracleAS Farm Repository Management region
to begin creating the repository.

|
| 2. |
The repository creation wizard appears. Notice that
the appropriate host name appears under Configure Oracle Farm Repository:
Source. Select the New file-based repository and click Next.

|
| 3. |
Because you are creating a new repository, the wizard
jumps to the last step of validation. Click Finish to create the
repository.

|
| 4. |
You return to the infrastructure page. Observe that
the page now has details about the file-based repository. Make a note
of the File-based Repository ID. This is necessary to add other
instances to this repository or farm.

|
| 5. |
Now to ensure that the file-based repository is in sync
with the distributed configuration manager, shut down and start the Application
Server Control and the application server instance. Log in to the machine
on which the first instance is running. Open a command window and issue
the following commands:
emctl stop iasconsole
opmnctl stopall
opmnctl startall
emctl start iasconsole
Note: emctl is under <ORACLE_HOME>/bin.
opmnctl is under <ORACLE_HOME>/opmn/bin.

|
| 6. |
Log in to Application Server Control for the instance
j2ee1 and notice that it now includes the farm page.

|
Back to Topic List
| 1. |
Switch to the browser window that is displaying the
Application Server Control for the second instance j2ee23. Click
the Infrastructure link to navigate to the infrastructure property
page.

Notice that the Farm repository is shown as Not Configured.
Click Configure in the OracleAS Farm Repository Management region.

|
| 2. |
You see the wizard. In the Source page of the wizard,
select Existing file-based repository and click Next.

|
| 3. |
The wizard then displays the Location page. Enter the
repository ID you noted in an earlier step and click Next. If the
repository is on a different machine (as in this case), you must ensure
that the two machines recognize each other by name (not just the IP address).
So you must enable this through a suitable name resolution method at the
DNS or locally at each machine.

|
| 4. |
The Validation page appears. Click Finish to
join the instance to the farm.

|
| 5. |
After the wizard completes, you return to the Infrastructure
property page. Notice that the farm repository is now configured.

|
| 6. |
Log in to the machine on which the second instance is
running. Open a command prompt and stop and start the Application Server
Control and the instance to synchronize with Distributed Configuration
Management (DCM.)

|
| 7. |
Switch back to the machine on which the first
instance is running. Reload the browser that is displaying the Application
Server Control of instance j2ee1. Observe that it displays the
farm page and that both the instances are listed in the Standalone Instances
table. You can check this for instance j2ee23
also.

|
Back to Topic List
| 1. |
Click Create Cluster in the Clusters region.

|
| 2. |
The Create Cluster page appears. Enter the name
for the cluster and click Create.

|
| 3. |
You see the confirmation page. Click OK.

|
| 4. |
You return to the Farm page. The newly created cluster
appears in the Clusters table.

|
Back to Topic List
| The order you join instances to the cluster is very important.
The first instance that joins the cluster imposes the structure (Oracle
HTTP Server and OC4J components, deployed applications, and configuration)
of the cluster. Any instance that joins the cluster inherits the structure.
So if the second and subsequent instances have applications that are not
in the first instance that is in the cluster, then such applications will
be dropped out of the cluster. So you must perform one of the following
tasks: |
- Deploy such applications to the cluster before the instances
join the cluster.
- Take a backup of the application
and deploy the application after joining the cluster.
In this OBE, you first join the instance j2ee1
to the cluster.
| 1. |
Select the instance j2ee1 from the Standalone
Instances table and click Join Cluster.

|
| 2. |
The Join Cluster page appears. Select the cluster to
join from the list of clusters (in this case, there is just one cluster)
and click Join.

|
| 3. |
Application Server Control displays the confirmation
that the instance has been added to the cluster.
Click OK.

Similarly, add the second instance j2ee23 to
the cluster.
|
| 4. |
The Farm page shows the cluster, but the two instances
do not appear in the table of Standalone Instances.

|
Back to Topic List
Clusters provide ways to simplify management of application
server instances in addition to providing scalability and security.
| 1. |
When a cluster is created, the cluster is not started.
Similarly, when an instance joins a cluster, the instance remains shut
down. Click cluster123.

Observe that the instances are shut down.

|
| 2. |
Click Start All to start all the instances.
You can however choose to start individual instances if you do not want
all the instances of the cluster to be up.


|
| 3. |
After the cluster (or instance) has started, the confirmation
page appears. Click OK.

|
| 4. |
Observe that the instances are all started.

|
Back to Topic List
| 1. |
You can add the OC4J component to any instance of the
cluster, and all the other instances will inherit this component. Click
the first instance.

You see the home page of the first instance. Click
Create OC4J Instance in the System Components table.

|
| 2. |
Enter demo123 for OC4J Instance Name and
click Create.

|
| 3. |
The confirmation page appears. Click OK.

|
| 4. |
The newly created component demo123 appears in
the System Components table. Note that the newly created component is
not yet started.

|
| 5. |
Verify whether this component has also been created
in the other application server instance of the cluster. Click the Cluster:
cluster123 breadcrumb.
Click the second instance.


|
| 6. |
Go back to the first instance (j2ee1) in the cluster. Start the
demo123 OC4J component. To start the component, select the checkbox
in the Select column and click Start. This starts the demo123
component in the application server instance in which you performed the
start operation.

You see the confirmation page.

Observe that the demo123 component is started.
Note that the OC4J component demo123 is not started on the second
instance (j2ee23).
|
Back to Topic List
| 1. |
To deploy an application, access the home page of the
OC4J component. Click demo123.

You see the home page of the demo123
component. Click the Applications tab to access the application
page.

|
| 2. |
Click Deploy EAR file. This displays
the Deploy Application Wizard.

|
| 3. |
Click Browse and select the hademo.ear
file from your working directory. Enter HA_Demo for the Application
Name. Observe that the application is deployed to all the application
server instances in the cluster. Click Continue.

|
| 4. |
The URL Mappings page appears. Enter the URL access
path for the application. In this case, /hademoweb is used as the URL
mapping. So the application is to be accessed using the URL: http://<server:http-port>/hademoweb.
Because it is not intended to use user management features in the application,
click Finish.

|
| 5. |
The Review page appears. Verify the details you have
entered and click Deploy.

The confirmation page appears indicating that the application
is deployed to all the instances in the cluster. Click OK to continue.
|
| 6. |
Access the application on this instance. Though the application got deployed
automatically on the second instance, remember that the OC4J component
demo123 on the other instance is not yet started. Open
a browser window and access the application with the following URL:
http://<hostname>.<domain>:http-port/hademoweb/index.jsp
where
<hostname>.<domain> is the host name and domain of
the machine where the first instance is running
(for example, edrsr1p1)
http-port is the port where Oracle HTTP Server is running (for
example, 7777)
Click the Here link, enter values for Name and Last Name, and
click Update.



|
Back to Topic List
| 1. |
Now test the process management (death-detection and
auto-restart) capabilities of this application without having enabled
the replication properties. Get the process ID of the demo123 component.
You can use either the Topology Viewer or the command-line utility
opmnctl. In this case, the Topology Viewer is used. Switch back
to the Application Server Control window and click the Topology
link on the top right of the page.

Click the Hide Navigator link. The farm appears
with the instances.


|
| 2. |
Navigate using the arrows at the border to display the
process ID for demo123 component of the j2ee1 instance.

|
| 3. |
In this case, the process ID for the demo123 component is 9793.
To simulate failure, kill this process at the OS level. Open a command
window, change directory to your working directory that contains Kill.exe
and type the following command:
kill 9793
|
| 4. |
If you access the application, you get the Internal
Server Error.

|
| 5. |
Very quickly, however, OPMN detects the failed (killed)
process and restarts the OC4J component with a new process ID.

|
| 6. |
You can access the application again. Click Refresh
on the browser window that showed the Internal Server Error and the application
page is displayed. But as you can see the application state is lost. It
starts a new session. However, if the host or machine that was serving
this request failed, OPMN would have also failed and you would not have
been able to access the application until the host or machine is started.

|
Back to Topic List
| 1. |
While the application is running, enter some values
in the application.

|
| 2. |
Using the Topology viewer, note the process ID for the
demo123 component of the j2ee1 instance.

|
| 3. |
Using the Application Server Control, start the demo123
component on the second instance (j2ee23). Click Return to OC4J: demo123.

Click the breadcrumb Cluster:cluster123.

|
| 4. |
Click the second instance in the Instances table. Enter
User Name and Password and start the demo123 component in the second instance
(j2ee23).



|
| 5. |
After the second demo123 component has started,
simulate the failure for the first instance by killing the process on
the first instance (process ID obtained in step 2).
kill <process id>
|
| 6. |
Immediately, switch to the other browser window that
is running the application and enter some values and update. Now instead
of the Internal Server Error, you get the new values. The old values are
lost. So your application has failed over to an available (second) demo123
component, but it has not retained the state.

|
Back to Topic List
| 1. |
Using the Application Server Control, access the home
page for demo123.

Note: Ensure that the demo123 component
is running in both the instances before commencing to setup replication
properties.
|
| 2. |
Click the Administration tab to make configuration
changes to the component.

|
| 3. |
Click the Replication Properties link in the
Administration page.

The Replication Properties page appears. Select the
Replicate session state in the Web Applications region and click Apply.
The OC4J component assigns the appropriate IP and port for you.

You see the confirmation page. Click OK.

|
| 4. |
After replication is enabled, ensure that just one
demo123 component is running by stopping the other component by
using Application Server Control. This is to ensure that you know to which
demo123 component the application is routed. Stop the
demo123 component of the instance j2ee23. Click the breadcrumb
for this instance.

Select demo123 and click Stop.


|
| 5. |
Now access the application by using a browser window
and enter some values.

|
| 6. |
Using the Topology viewer, get the process ID for the
demo123 component.

|
| 7. |
Start the demo123 component on the other instance
(j2ee23).

|
| 8. |
Use the browser window that you are accessing the application
and add some more values.

|
| 9 |
Now using the command window, kill the demo123
process that was running the application (the process ID obtained in step
6).
kill <process id>
|
| 10. |
Access the browser window that was accessing the application
and enter some more values. New values are added. Old values are also
available and not lost. The session state has been preserved across the
failure.

|
In this lesson, you've learned how to:
|
Create a cluster
|
|
Configure and enable stateless and stateful failover
|
 |
To ask a question about this OBE tutorial, post a query on the OBE
Discussion Forum |
Place the cursor on this icon
to hide all screenshots.
'images/view_image.gif','deploy13','','images/view_image.gif','deploy14','','images/view_image.gif','deploy15','','images/view_image.gif','deploy16a','','images/view_image.gif','deploy17','','images/view_image.gif','deploy18','','images/view_image.gif','enable1','','images/view_image.gif','enable2','','images/view_image.gif','enable3','','images/view_image.gif','enable4','','images/view_image.gif','enable5','','images/view_image.gif','enable6','','images/view_image.gif','enable7','','images/view_image.gif','enable8','','images/view_image.gif','enable9','','images/view_image.gif','enable10','','images/view_image.gif','enable11','','images/view_image.gif','enable12','','images/view_image.gif','enable13','','images/view_image.gif','enable14','','images/view_image.gif','enable15','','images/view_image.gif','enable16','','images/view_image.gif','enable17','','images/view_image.gif','enable18','','images/view_image.gif','enable19','','images/view_image.gif','enable20','','images/view_image.gif','enable21','','images/view_image.gif','noscreenshot','','images/view_image.gif',1)">
Place the cursor on this icon
to hide all screenshots
|