Search This Blog

Sunday, December 10, 2006

How to set up squid proxy for testing the HTTPS-ORMI Connections and other autheticating proxy problems

How to set up squid proxy for testing the HTTPS-ORMI Connections.

This small write up should help if some one is trying to configure the squid proxy with the authentication.

How to set up squid proxy for testing the HTTPS-ORMI Connections.

open the file /etc/squid/squid.conf

Step 1.
======================
Add the following after this line

#Default:
http_port 9090

This is the port you need to specify for the proxyPorts.

Step 2.
===========================

Append the SSL ports to the list of the SSL ports , in this case I added port
8888.

acl SSL_ports port 443 563 8888

Step 3
=============

Add the following after this line ,
here I added the proxy_auth as required , and my IP address wher I am going to
access the proxy ports.

# And finally deny all other access to this proxy



http_access allow localhost
acl pass proxy_auth REQUIRED
http_access allow pass
acl allowed_clients src 152.69.168.138 152.69.168.139
http_access allow allowed_clients

#http_access deny all


Step 4
==========

Here I need to use the Authentication program that I will be using for the passwords.


And make sure you have the following lines in , after this line

#auth_param basic program


auth_param basic program /usr/lib/squid/ncsa_auth /etc/squidusers
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours

Step 5
=========

Create the /etc/squidusers file ,

/usr/bin/htpasswd -c /etc/squidusers ravi

Give the password as ravi

/usr/bin/htpasswd /etc/squidusers test

Give the password as test


Start the squid proxy servers using the commands ,

service squid restart

After this write the RMI client , for the EJB's


SessionEJBClient.java
======================



package mypackage7;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import mypackage7.SessionEJB;
import mypackage7.SessionEJBHome;
import javax.naming.NamingException;
import java.util.Hashtable;
import HTTPClient.*;

public class SessionEJBClient
{
public static void main(String [] args)
{
SessionEJBClient sessionEJBClient = new SessionEJBClient();
try
{

System.setProperty("http.proxyHost", "incq128ad.idc.oracle.com");
System.setProperty("http.proxyPort","9090");
System.setProperty("http.proxyUser", "ravi");
System.setProperty("http.proxyPassword", "ravi");

DefaultAuthHandler.setAuthorizationPrompter(new MyAuthPrompter(System.getProperty("http.proxyUser"),System.getProperty("http.proxyPassword") ));

Context context = getInitialContext();
SessionEJBHome sessionEJBHome = (SessionEJBHome)PortableRemoteObject.narrow(context.lookup("SessionEJB"), SessionEJBHome.class);
SessionEJB sessionEJB;

// Use one of the create() methods below to create a new instance
sessionEJB = sessionEJBHome.create();

// Call any of the Remote methods below to access the EJB
System.out.println( sessionEJB.sayHello());

}
catch(Throwable ex)
{
ex.printStackTrace();
}

}

private static Context getInitialContext() throws NamingException
{
Hashtable env = new Hashtable();
// Standalone OC4J connection details
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "welcome1");
env.put(Context.PROVIDER_URL, "https:ormi://indl224ad.idc.oracle.com:8888/ejb1");

return new InitialContext(env);
}
}

class MyAuthPrompter implements AuthorizationPrompter
{
private String pa_name, pa_pass;


MyAuthPrompter(String pa_name, String pa_pass)
{
this.pa_name = pa_name;
this.pa_pass = pa_pass;
}


public NVPair getUsernamePassword(AuthorizationInfo challenge, boolean forProxy) {
if (forProxy && pa_name != null)
{
return new NVPair(pa_name, pa_pass);
}

return null;

}
}

Wednesday, November 29, 2006

How to find which file is opened on windows (similar to fuser in linux)

Download the tool from

http://www.microsoft.com/technet/sysinternals/utilities/handle.mspx

Ever wondered which program has a particular file or directory open? Now you can find out. Handle is a utility that displays information about open handles for any process in the system. You can use it to see the programs that have a file open, or to see the object types and names of all the handles of a program.

handle.exe > dd.txt will get all the files

handle AppEvent.evt

Handle v3.2
Copyright (C) 1997-2006 Mark Russinovich
Sysinternals - www.sysinternals.com

services.exe pid: 1224 2D0: C:\WINDOWS\system32\config\AppEvent.evt

Monday, November 27, 2006

How to test the x-forwarded-for with the Apache

1. Create the file AdjustRemoteAddrAccordingToHeader.pm
with the following ,

package Apache::AdjustRemoteAddrAccordingToHeader;

sub handler
{
my $r = shift;
my $configuredValue = $r->dir_config ("UseIPFromHeader");
if ($configuredValue)
{
my $ip = $r->header_in($configuredValue);
if ($ip)
{
$r->connection->remote_ip($ip);
}
}
else
{
print STDERR "AdjustRemoteAddrAccordingToHeader: PerlSetVar UseIPFromHeader is not set, so I did not do anything\n";
}

# Adjust for Oracle HTTP Server and REMOTE_ADDR
# Remove this line if not necessary
$r->header_in("ClientIP", $r->connection->remote_ip());

return OK;
}

return 1;

2. Open the httpd.conf file and add the following lines to the end ,

PerlRequire /home/ias/AdjustRemoteAddrAccordingToHeader.pm
PerlPostReadRequestHandler Apache::AdjustRemoteAddrAccordingToHeader
PerlSetVar UseIPFromHeader X-Forwarded-For

3. Run the command to validate whether this works or not ,

apachectl configtest

4. Use some tool , like say ProtocolExplorer.jar and add the following ,

GET /j2ee/examples/jsp/snp/snoop.jsp HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*
Accept-Language: en-us,et;q=0.9,cs;q=0.7,de;q=0.6,fi;q=0.4,ja;q=0.3,fr;q=0.1
Accept-Encoding: gzip, deflate
Host: incq128ad.idc.oracle.com:7779
x-forwarded-for: 123.111.22.15
Connection: Keep-Alive

Check the following output ,



Remote address: 123.111.22.15


Remote host: 123.111.22.15



The same addredd will appear in the Apache access log's also as we are replacing the
remotehost with the header for the X-Forwarded-For header.

Using Apache DERBY

http://db.apache.org/derby/integrate/SQuirreL_Derby.html

http://db.apache.org/derby/papers/DerbyTut/ns_intro.html

Wednesday, November 22, 2006

How to redirect to an URL with out the quesry string

When ever you want to access the URL

/j2ee/examples/jsp/num/numguess.jsp?guess=500 you want to redirect to http://indl224ad.idc.oracle.com:7777/j2ee/examples/jsp/jsp2/el/basic-arithmetic.jsp
without the query string parameters

RewriteEngine on
RewriteLog "c:\rewrite.log"
RewriteLogLevel 9
RewriteCond "%{REQUEST_URI}" "/j2ee/examples/jsp/num/numguess.jsp"
RewriteCond "%{QUERY_STRING}" "^guess=500"
RewriteRule ^/(.*) http://indl224ad.idc.oracle.com:7777/j2ee/examples/jsp/jsp2/el/basic-arithmetic.jsp? [L,R=permanent]

Tuesday, November 07, 2006

Lost Windows in JDeveloper 10.1.3 Preview

Lost Windows in JDeveloper 10.1.3 Preview



Ran
across a silly problem this morning with the log window in JDev. I'd
been plugged in at the office running across both my laptop screen and
an extra crt that happened to be lying around, with my desktop extended
onto that extra screen. Whilst working I'd undocked the log window and
pushed it onto the other screen.

This morning in the hotel room I was unplugged from the external crt of
course and when I ran JDev, you guessed it the log window was still in
the same place, about 4 inches above the top of my laptop screen.
Fortunately this one's pretty easy to recover from, just rename or
delete the /jdev/system/oracle.ide.10.1.3.[some number]/windowinglayout.xml and JDev will restore to the default layout again



powered by performancing firefox



powered by performancing firefox

Thursday, October 19, 2006

High CPU Usage Java

Add this variable to opmn.xml file

ias-instance id="j2ee2.asdtbde.idc.oracle.com"
environment
variable id="TMP" value="/tmp"
variable id="LD_ASSUME_KERNEL" value="2.4.1"
variable



Find out the java process using the command
opmnctl status
and not down the PID

opmnctl status

Processes in Instance: j2ee2.asdtbde.idc.oracle.com
-------------------+--------------------+---------+---------
ias-component | process-type | pid | status
-------------------+--------------------+---------+---------
DSA | DSA | N/A | Down
LogLoader | logloaderd | N/A | Down
dcm-daemon | dcm-daemon | N/A | Down
OC4J | home | 28370 | Alive
WebCache | WebCache | 28380 | Alive
WebCache | WebCacheAdmin | 28371 | Alive
HTTP_Server | HTTP_Server | 28373 | Alive

Use this command to find out the actual process ID , In this case the actual java process is ,
28377.

ps -ef | grep 28370
rac 28370 28354 0 11:23 ? 00:00:01 /home/rac/j2ee2/jdk/bin/java
rac 28377 28370 0 11:23 ? 00:00:00 /home/rac/j2ee2/jdk/bin/java

Run the command ,

watch "ps -eLo pid,ppid,tid,pcpu,comm | grep 28377"

Find out the therad ID which taking lot of CPU time ,
i.e it should be there in the first column

Now take the thread dump

kill -3 28370 (process-id-from-opmn-status-output)

Convert the Thread ID you got from the command ,
ps -eLo pid,ppid,tid,pcpu,comm | grep 28377
hexadecimal and then search for this value in the thread dump.

For the JDK 5.0 you do not need to the LD_ASSUME_KERNEL etc.

Please also check the Article

http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_18339

Tuesday, October 10, 2006

SSH Tunneling for DB Connections

This is actually very simple ,

I want to connect to my db "infra2" running on machine asdtbde.idc.oracle.com
with the listner port as say 1521.

To use the connect string as my local machine and port 1621 I need to set the following ,

for example ,

SECURED_SERVER =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1621))
)
(CONNECT_DATA =
(SID = infra2)
)
)

From my local machine run the following from the root user ,

ssh -NfL 1621:localhost:1521 asdtbde.idc.oracle.com
--
output :
ssh -NfL 1621:localhost:1521 asdtbde.idc.oracle.com
The authenticity of host 'asdtbde.idc.oracle.com (152.69.168.61)' can't be established.
RSA key fingerprint is 7b:ee:40:82:f9:7e:1e:24:e9:00:cf:e9:e8:b5:c4:c4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'asdtbde.idc.oracle.com' (RSA) to the list of known hosts.
root@asdtbde.idc.oracle.com's password:
---

Now from the local machine connect using

sqlplus scott/tiger@SECURED_SERVER

Wednesday, September 27, 2006

Enabling sql trace in OC4J

Create a new dummy user in DB say test. Create a Connection in the
data-source.xml file with the min-connections="1" and max-connections="1".

On the DB side create a login trigger ,
CREATE OR REPLACE TRIGGER test_user_trg_after_logon
AFTER LOGON ON DATABASE
BEGIN
IF (user = 'TEST') THEN
DBMS_SESSION.SET_SQL_TRACE(true);
END IF;
END;

The sql trace files will be generated in the USER_DUMP_DESTINATION for the
database.

To check the sql's run the command
tkprof sys=no

The above procedure will not give you the bind variables. To get the bind variable , please
perform the following steps.

cd $OH/rdbms/admin/
connect / AS SYSDBA
dbmssupp.sql
SQL> GRANT execute ON dbms_support TO ;
SQL> CREATE PUBLIC SYNONYM dbms_support FOR dbms_support;

Create the stored procedure ,

CREATE OR REPLACE TRIGGER test_user_trg_after_logon
AFTER LOGON ON DATABASE
BEGIN
IF (user = 'SCOTT') THEN
dbms_support.start_trace (binds=>true);
END IF;
END;

The above steps will have the bind variables in the trace files.

To disable the tracing , perform the step as ,
drop trigger test_user_trg_after_logon;

Set the event 942 to capture ORA-942 errors

alter system set events '942 trace name errorstack level 12';
Try to find the udump directory

show parameters user_dump
user_dump_dest string /home/ias/infra101202/admin/ias1012/udump
cd /home/ias/infra101202/admin/ias1012/udump and find out the latest file.

Use SYS.DBMS_SYSTEM.SET_EV() procedure. Here is the specification for this procedure:

PROCEDURE SET_EV
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
SI BINARY_INTEGER IN
SE BINARY_INTEGER IN
EV BINARY_INTEGER IN
LE BINARY_INTEGER IN
NM VARCHAR2 IN
SID: V$SESSION.SID
SE: V$SESSION.SERIAL#
EV: Event number. For example:
10046: SQL traces.
10053: Optimizer traces.
NNN : ORA-NNN errors.
65535: IMMEDIATE traces.
LE: Event level. For Event 10046 events:
0: Disable event.
1: PARSE, FETCH, EXEC, EXECUTION PLAN
4: Level 1 + BINDS
8: Level 1 + WAITS
12: Level 4 + Level 8
NM: Event name. For example:
ERRORSTACK.......: For error stack traces.
PROCESSSTATE...: For process states
SYSTEMSTATE.......: For System states.
''..................................: For CONTEXT FOREVER.
Sample:
Dumps PROCESSSTATE trace IMMEDIATELY in LEVEL 10:

SQL> exec dbms_system.set_ev(8,1056,65535,10,'PROCESSSTATE');
Dumps ERRORSTACK trace in LEVEL 3 on ORA-942 error:

SQL> exec dbms_system.set_ev(8,1060,942,3,'ERRORSTACK');
Dumps Event 10046 trace in LEVEL 8 for CONTEXT FOREVER:

SQL> exec dbms_system.set_ev(8,1060,10046,8,'');

Tuesday, September 12, 2006

How to Convert JDeveloper CMT Application to Sun Application Server

Create the EJB using the Jdeveloper , say based on the Emp table
from Scott schema.
Change the following methods , so that they throw the CreateException
For example ,
public Long ejbCreate() throws CreateException {
return null;
}
public Long ejbCreate(Long empno) throws CreateException {
setEmpno(empno);
return empno;
}
Create the JAR file and open the Sun Deploy tool ,
File -> Open and select the jar file created by the previous method.
here select Emp Entity object , here click on the General TAB
And Click on Sun Specific Settings , select the View as CMP DataBase
Create DataBase Mappings , and select the DataSource Vendor as Oracle and select OK.
Now Click on the Table Generation Settings and unselect Create Table and Drop Table check boxes.
Change the JNDI name to jdbc/OracleDS.
Now Click on Tools -> Deploy menu option , and select the
option return Client Jar in some directory. After this deploy the application.
This creates the file empClient.jar in the directory you have specified in the above step.
Create the file EmpClient.java file ,
package project2;
import java.util.Collection;
import java.util.Iterator;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
public class EmpClient {
public static void main(String [] args) {
try {
final Context context = getInitialContext();
final EmpHome empHome =
(EmpHome) PortableRemoteObject.narrow( context.lookup( "Emp" ), EmpHome.class );
Emp emp;
// Use one of the create() methods below to create a new instance
// emp = empHome.create( );
// emp = empHome.create( empno );
// Retrieve all instances using the findAll() method (CMP Entity beans only)
final Collection coll = empHome.findAll();
final Iterator iter = coll.iterator();
while ( iter.hasNext() ) {
emp = ( Emp ) iter.next();
System.out.println( "empno = " + emp.getEmpno() );
System.out.println( "ename = " + emp.getEname() );
System.out.println( "job = " + emp.getJob() );
System.out.println( "mgr = " + emp.getMgr() );
System.out.println( "hiredate = " + emp.getHiredate() );
System.out.println( "sal = " + emp.getSal() );
System.out.println( "comm = " + emp.getComm() );
System.out.println( "deptno = " + emp.getDeptno() );
System.out.println();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
private static Context getInitialContext() throws NamingException {
// Get InitialContext for Embedded OC4J
// The embedded server must be running for lookups to succeed.
return new InitialContext();
}
}

2. Create the file META-INF\application-client.xml



ConverterClient

ejb/Emp
Session
project2.EmpHome
project2.Emp



3. Create the file , META-INF\sun-application-client.xml






ejb/Emp
Emp



Compile the above file using the command ,
set classpath=c:\empClient.jar;.;c:\sun\AppServer14\lib\j2ee.jar;c:\sun\AppServer14\lib\appserv-rt.jar
javac -d *.java
Now run the file using the command ,
java project2.EmpClient

Creating the Connection using the Sun Application Server

Create a data source in Sun J2ee container

Copy the files ojdbc14dms.jar and dms.jar file in to
C:\Sun\AppServer14\lib directory.

Create a connection pool with the following ,

oracle.jdbc.pool.OracleDataSource

resource type as javax.sql.DataSource

Enter the following fields

Password tiger
User scott
ServiceName ravi.idc.oracle.com
PortNumber 1522
ServerName incq128ad
URL jdbc:oracle:thin:@incq128ad:1522:ravi1

After this create JDBC Resources and name it as jdbc/OracleDS
and select the above connection pool.

Create a War file based on the test.jsp file with the following code ,


<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="java.sql.*,oracle.jdbc.driver.*,javax.naming.*,oracle.sql.*,javax.sql.*" %>



testemp



Employee ID:


<% if (request.getParameter("empID") != null) {
String empID = request.getParameter("empID");
InitialContext testContext = null;
DataSource testOC4JDataSource = null;
Connection testDatabaseConnection = null;
Statement testDatabaseStatement = null;
ResultSet testDatabaseResultSet = null;
try {
testContext = new InitialContext();
testOC4JDataSource = (DataSource) testContext.lookup("jdbc/OracleDS");
testDatabaseConnection = testOC4JDataSource.getConnection();
testDatabaseStatement = testDatabaseConnection.createStatement();
String testQuery = "SELECT * FROM SCOTT.EMP where EMPNO =" + empID;
testDatabaseResultSet = testDatabaseStatement.executeQuery(testQuery);
while (testDatabaseResultSet.next()) {
out.println("
" + testDatabaseResultSet.getString("ENAME"));
}
} catch (Throwable e) {
String err = e.toString();
System.out.println(err);
} finally {
try {
testDatabaseStatement.close();
testDatabaseConnection.close();
} catch ( Throwable e) {
String err = e.toString();
System.out.println(err);
}
}
}
%>



Create the war file in Jdeveloper and deploy the file using the Sun Admin Console

Tuesday, August 22, 2006

Removing the trustcleaner Virus (Adware program)

I used the following method to get rid of this.

Please refer to the URL ,

http://www.superantispyware.com/definition/wschtm35/

This uses the DLL , WSCHTM35.DLL. This is stored in the temporary directory (%TEMP%)
use the procexp to locate the substring.

I found that this process is owned by the explorer.
Uninstall the software first and then
Write a batch which first kills the explorer.exe and then delete the file WSCHTM35.DLL.

And delete the corresponding registry entries.





Monday, August 07, 2006

Create DVD Install media from RedHat 4 CD's

This article explains how to create the Redhat Installable DVD from the CD's.

1. Create a directory say

/tmp/RHAS4

cd /tmp/RHAS4

2. Insert the RHAS CD1 first

dd if=/dev/cdrom of=rhas2.iso

3. Insert CD2 , 3 and 4 etc

dd if=/dev/cdrom of=rhas2.iso
dd if=/dev/cdrom of=rhas2.iso
dd if=/dev/cdrom of=rhas2.iso

4. Copy the script below , with the name as "mkdvdiso.sh".

or get the script from the location
http://www.stams.strath.ac.uk/~sergei/files/mkdvdiso.sh

-------------------------Cut From Here ---------------------------------------------------------
#/bin/bash

# by Chris Kloiber <ckloiber@redhat.com>
# Slight adaptation for Mandrake by Sergei Zuyev <sergei@stams.strath.ac.uk>
# Requires package mediacheck

# A quick hack that will create a bootable DVD iso of a Mandrake Linux
# Distribution. Feed it either a directory containing the downloaded
# iso files of a distribution, or point it at a directory containing
# the "Mandrake", "isolinux", and "images" directories.

# Usage:
# mkdvdiso.sh /path/to/the/cd/isos /destination/dvd.iso
# Burning on oka:
# /usr/bin/growisofs -Z /dev/hdc=/destination/dvd.iso -use-the-force-luke=notray -use-the-force-luke=tty -speed=2

# This version only works with "isolinux" based Red Hat Linux versions.

# Lots of disk space required to work, 3X the distribution size at least.

# GPL version 2 applies. No warranties, yadda, yadda. Have fun.


if [ $# -lt 2 ]; then
echo "Usage: `basename $0` source /destination/DVD.iso"
echo ""
echo " The 'source' can be either a directory containing a single"
echo " set of isos, or an exploded tree like an ftp site."
exit 1
fi

cleanup() {
[ ${LOOP:=/tmp/loop} = "/" ] && echo "LOOP mount point = \/, dying!" && exit
[ -d $LOOP ] && rm -rf $LOOP
[ ${DVD:=`pwd`/mkmdkdvd} = "/" ] && echo "DVD data location is \/, dying!" && exit
[ -d $DVD ] && rm -rf $DVD
}

cleanup
mkdir -p $LOOP
mkdir -p $DVD

if [ !`ls $1/*.iso 2>&1>/dev/null ; echo $?` ]; then
echo "Found ISO CD images..."
CDS=`expr 0`
DISKS="1"

for f in `ls $1/*.iso`; do
mount -o loop $f $LOOP
cp -av $LOOP/* $DVD
if [ -f $LOOP/.discinfo ]; then
cp -av $LOOP/.discinfo $DVD
CDS=`expr $CDS + 1`
if [ $CDS != 1 ] ; then
DISKS=`echo ${DISKS},${CDS}`
fi
fi
umount $LOOP
done
if [ -e $DVD/.discinfo ]; then
awk '{ if ( NR == 4 ) { print disks } else { print ; } }' disks="$DISKS" $DVD/.discinfo > $DVD/.discinfo.new
mv $DVD/.discinfo.new $DVD/.discinfo
fi
else
echo "Found FTP-like tree..."
cp -av $1/* $DVD
[ -e $1/.discinfo ] && cp -av $1/.discinfo $DVD
fi

rm -rf $DVD/isolinux/boot.cat
find $DVD -name TRANS.TBL | xargs rm -f

DIR=`pwd`
cd $DVD
#mkisofs -J -R -v -T -o $2 -b isolinux/isolinux.bin -c Boot/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table .
mkisofs -J -R -v -T -o $2 -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table .
# /usr/bin/implantisomd5 $2
cd DIR

# cleanup
echo ""
echo "Process Complete!"
echo ""

-------------------------End of the File---------------------------------------------------------

5. Run the command as ,

mkdvdiso.sh /tmp/RHAS4 /tmp/RHAS4/rhas4dvd.iso

6. The above command should create the DVD ISO image

7. Transfer the DVD ISO Image to windows machine and create the DVD

Monday, June 05, 2006

HA RAC Testing

HA RAC Testing
// You need to import the java.sql package to use JDBC
import java.sql.*;
class TestFailover
{
public static void main (String args [])
throws Exception
{
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// String url = "jdbc:oracle:thin:@DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=incq128ad.idc.oracle.com)(PORT = 1521))(ADDRESS=(PROTOCOL=TCP)(HOST=hatest-ias.idc.oracle.com)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ravi.idc.oracle.com)))";
String url = "jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(FAILOVER=on)(ADDRESS=(PROTOCOL=tcp)(HOST=incq128ad)(PORT=1521))(ADDRESS=(PROTOCOL=tcp)(HOST=hatest-ias)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ravi.idc.oracle.com)(FAILOVER_MODE=(TYPE=session)(METHOD=basic)(RETRIES=20)(DELAY=15))))";
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
for (int i = 0 ; i < 100 ; i++) {
conn= DriverManager.getConnection (url, "scott", "tiger");
// Create a Statement
stmt = conn.createStatement ();
// Select the host name from the instance you are connected to
rset = stmt.executeQuery ("select INSTANCE_NAME from v$instance");
// Iterate through the result and print the host name of the DB instance
while (rset.next ())
System.out.println (rset.getString (1));
// Close the RseultSet
rset.close();
// Close the Statement
stmt.close();
// Close the connection
conn.close();
}
}
}

Select fail-over
----------------
testrac_s=
(DESCRIPTION=
(LOAD_BALANCE=on)
(FAILOVER=on)
(ADDRESS=(PROTOCOL=tcp)(HOST=incq128ad)(PORT=1521))
(ADDRESS=(PROTOCOL=tcp)(HOST=hatest-ias)(PORT=1521))
(CONNECT_DATA=
(SERVICE_NAME=ravi.idc.oracle.com)
(FAILOVER_MODE=
(TYPE=select)
(METHOD=basic)
(RETRIES=20)
(DELAY=5))))

Copy the tnsnames.ora file to the other machine also.
Open a sql*plus connection
sqlplus scott/tiger@testrac_s
select INSTANCE_NAME from v$instance;
Note down the instance name , for example say Ravi1
now run the query , select * from dba_extents;
While the query is running , shutdown the ravi1 instance ,
you will see a pause for few seconds and after this the select command will start running again.
Session fail-over
-----------------

testrac_b=
(DESCRIPTION=
(LOAD_BALANCE=on)
(FAILOVER=on)
(ADDRESS=(PROTOCOL=tcp)(HOST=incq128ad)(PORT=1521))
(ADDRESS=(PROTOCOL=tcp)(HOST=hatest-ias)(PORT=1521))
(CONNECT_DATA=
(SERVICE_NAME=ravi.idc.oracle.com)
(FAILOVER_MODE=
(TYPE=session)
(METHOD=basic)
(RETRIES=20)
(DELAY=15))))

Connect to
SQL> select INSTANCE_NAME from v$instance;
INSTANCE_NAME
----------------
ravi1
-- Now Shutdown Instance ravi1
SQL> /
select INSTANCE_NAME from v$instance
*
ERROR at line 1:
ORA-25408: can not safely replay call

SQL> /
INSTANCE_NAME
----------------
ravi2

testrac_b_p=
(DESCRIPTION=
(LOAD_BALANCE=on)
(FAILOVER=on)
(ADDRESS=(PROTOCOL=tcp)(HOST=incq128ad)(PORT=1521))
(ADDRESS=(PROTOCOL=tcp)(HOST=hatest-ias)(PORT=1521))
(CONNECT_DATA=
(SERVICE_NAME=ravi.idc.oracle.com)
(FAILOVER_MODE=
(TYPE=session)
(METHOD=preconnect)
(RETRIES=20)
(DELAY=15))))
When you say preconnect , it opens the connection to the other database.

Tuesday, May 30, 2006

iscsi and RAC install with openfiler

Download the openfiler from http://www.openfiler.com/After downloading this cut a CD.Install the software on a machine.Now open the putty asdtbde.idc.oracle.comexport http_proxy=http://www-proxy.us.oracle.com:80/Run the command ,"yum update"
Refer the
http://fedoranews.org/mediawiki/index.php/Going_Enterprise_-_setup_your_FC4_iSCSI_target_in_5_minutes
Download the iscsi Initiator
http://www.microsoft.com/windowsserver2003/technologies/storage/iscsi/msfiSCSI.mspx

http://guialivre.governoeletronico.gov.br/mediawiki/index.php/TestesOracle10gRacISCSI


/etc/init.d/iscsi-target start
Check the logfiles
/var/log/messages
Open the file /etc/ietd.conf and change the
domain , in the reverse order , for example com.oracle.com
And restart the iscsi again.

If this fails with the iscsi_module error , please change the grub.conf file
and make sure the default kernel is "not" SMP Kernel.

Start the kernel without the SMP mode ( Openfiler Release 2 (Beta1) (2.6.9-34.EL))

Change the grub.conf file with the correct entries.

Mounting the ocfs2 files systems on linux

On incq128ad
------------

/etc/init.d/o2cb status
/etc/init.d/o2cb load
/etc/init.d/o2cb online ocfs2

mount -t ocfs2 -o datavolume /dev/sdc /ocfs

to umount
----------
umount /ocfs
/etc/init.d/o2cb status
/etc/init.d/o2cb offline ocfs2
/etc/init.d/o2cb unload


On asdtbde machine
-------------------

/etc/init.d/o2cb status
/etc/init.d/o2cb load
/etc/init.d/o2cb online ocfs2
mount -t ocfs2 -o datavolume /dev/sdc /ocfs

to umount
----------
umount /ocfs
/etc/init.d/o2cb status
/etc/init.d/o2cb offline ocfs2
/etc/init.d/o2cb unload


Start RAC Instance
--------------------

/etc/init.d/o2cb status
/etc/init.d/o2cb load
/etc/init.d/o2cb online ocfs2

mount -t ocfs2 -o datavolume /dev/sdc /ocfs

Checck whether the proper volume is monuted or not by running the "ls" command

ls -l /ocfs

Start the RAC instance by running the command ,

/home/rac/crs/bin/crsctl start crs

For the latset openfiler 2.3  I need to do the following

Commented entry in /etc/initiators.deny in the openfiler machine.
service iscsi-target restart
iscsiadm -m discovery -t sendtargets -p openfiler 
iscsiadm -m discovery -t sendtargets -p iqn.2006-01.com.openfiler:tsn.ffe2ca0ed600  -p openfiler -l
service iscsi restart

Tuesday, May 23, 2006

LDAP Useful debugging

How to enable ldap debugging so that only the LDAP Operations can be
traced like ldapsearch , modify , add and delete etc

Check the LDAP debug log level by running the following command ,

ldapsearch -p -h -D "cn=orcladmin" -w -b "" -s base "objectclass=*" orcldebugflag

This ideally should give the result as "0" , if the debugging is not enabled.

for example ,
orcldebugflag=0

ldapsearch -p -h -D "cn=orcladmin" -w -b "" -s base "objectclass=*" orcldebugop

This ideally should give the result as "0" , if the debugging is not enabled.

for example ,
orcldebugflag=0



For 9.0.4 onwards


cat debug.ldif

--cut here---
dn:
changetype: modify
replace: orcldebugop
orcldebugop: 511

dn:
changetype: modify
replace: orcldebugflag
orcldebugflag: 8388609
----cut here-------

ldapmodify -p -h -D "cn=orcladmin" -w -f debug.ldif

1 Heavy trace debugging
128 Debug packet handling
256 Connection management, related to network activities
512 Search filter processing
1024 Entry parsing
2048 Configuration file processing
8192 Access control list processing
491520 Log of communication with the back end - that is with the database
524288 Schema related operations
4194304 Replication specific operations
8388608 Log of entries, operations and results for each connection
16777216 Trace function call arguments
67108863 All possible operations/data


The value 8388609 is dertmined using the formula

8388609 = 8388608 (Log of entries, operations and results for each connection)+ 1 (Heavy trace debugging)

For the ACL debugging you can use the loglevel as 8396801 (8192 (Access control list processing) +
8388608 (Log of entries, operations and results for each connection)+ 1 (Heavy trace debugging) )

debug.ldif

--cut here---
dn:
changetype: modify
replace: orcldebugop
orcldebugop: 0

dn:
changetype: modify
replace: orcldebugflag
orcldebugflag: 0
----cut here-------

ldapmodify -p -h -D "cn=orcladmin" -w -f debug.ldif

Please note that this operations may not require restart the OID , but to be
on the safer side , restart the OID after this.

You can check the latest log files from the directory $ORACLE_HOME/ldap/log directory.

For the version 9.0.2.3


Check the LDAP debug log level by running the following command ,

ldapsearch -p -h -D "cn=orcladmin" -w -b "" -s base "objectclass=*" orcldebugflag

This ideally should give the result as "0" , if the debugging is not enabled.

for example ,
orcldebugflag=0


To enable the debug trace so that only ldap operations can be traced ,

cat debug.ldif
--------------

---Cut Here ---
dn:
changetype: modify
replace: orcldebugflag
orcldebugflag: 260
---- End ----------


Then apply it to OID:
ldapmodify -p -h -D "cn=orcladmin" -w -f debug.ldif

The available DEBUG-LEVELS are:
1 = Trace function calls
2 = Debug packet handling
4 = Heavy trace debugging
8 = Connection Management
16 = Print out packets sent and received
32 = Search filter processing
64 = Configuration file processsing
128 = Access control list processing
256 = Stats log connections/operations/results
512 = Stats log entries sent
1024 = Print communication with the back-end
2048 = Print entry parsing debugging
4096 = Schema-related debugging
32768 = Replication Specific debugging
65535 = Enable all debugging

260 is calculated based on this formula

260 = 256 ( Stats log connections/operations/results) + 4 (Heavy trace debugging)

For the ACL debugging you can use the loglevel as 388 (128 (Access control list processing) +
256 ( Stats log connections/operations/results) + 4 (Heavy trace debugging) )

To revert back the tracing run the following commands

---Cut Here ---
dn:
changetype: modify
replace: orcldebugflag
orcldebugflag: 0
---- End ----------


Then apply it to OID:
ldapmodify -p -h -D "cn=orcladmin" -w -f debug.ldif

You can check the latest log files from the directory $ORACLE_HOME/ldap/log directory.