To properly load balance Oracle Applicaiton Servers, WebMux needs to check the health status of the Oracle database.
Place the following Perl based CGI code on your servers, then enable the custom-health-check on WebMux. For
Apache or IIS servers, the instruction is little different:
To install under Linux or Windows/Apache:
- We assume that the Oracle client libraries (available from
http://www.oracle.com/technology/tech/oci/) are already installed
under directory ORADIR.
- Building and install the DBD::Oracle and Sys::SigAction Perl modules.
- Move the CGI script to the desired directory.
- If the Oracle client libraries are not in the default load path,
configure Apache with the correct path, e g. by adding
SetEnv LD_LIBRARY_PATH ORADIR
to the appropriate section, and reload Apache.
--------------------------------------------------------------
To install under Windows/IIS:
- We assume that the Oracle client libraries (available from
http://www.oracle.com/technology/tech/oci/) are already installed
under directory ORADIR.
- Building and install the DBD::Oracle and Sys::SigAction Perl modules.
- Move the CGI script to the desired directory.
- If the Oracle client libraries are not in the default load path,
configure IIS with the correct path, e g. by setting the
LD_LIBRARY_PATH system variable to ORADIR as described in
http://www.microsoft.com/technet/prodtechnol/
windows2000serv/technologies/iis/maintain/
optimize/autoadm2.mspx.
The CGI code following is written in Perl:
#!/usr/bin/perl -Tw
#########################################
# (c)Copyright 2006 CAI Networks, Inc.
# index.cgi: CGI page to show status of an Oracle instance
# $Id: index.cgi,v 1.2 2006/10/23 12:00:04 jason Exp $
#########################################
use strict;
use Sys::SigAction qw(set_sig_handler);
use DBI;
# N.B.: Oracle client libraries:
# remember to put "SetEnv LD_LIBRARY_PATH <oracle-client-lib-path>" in
# Apache config
my $timeout = 5;
my $server = 'host=localhost;sid=XE';
my $dsn = "dbi:Oracle:$server";
my $status = 'OK'; # OK status
my $rv;
eval { # guard connect attempt with timeout alarm
my $h = set_sig_handler('ALRM',sub {die "TIMEOUT\n"});
alarm($timeout);
$rv = DBI->connect($dsn,"test","test");
alarm(0);
};
alarm(0);
if ($@ eq "TIMEOUT\n") { # connect timed out
$status = 'TIMEOUT';
print STDERR "TIMEOUT\n";
}
else { # connect didn't timeout
unless ($rv) {
my $code = 'ORA-' . $DBI::err;
$status = $code + see http://$code.ora-code.com/;
}
}
print <<EOS;
Content-Type: text/plain
$status
$server
EOS
|