Latest Post

JDBC Connection Issue with Oracle Database 11gR2 RAC SCAN listener

Written By askMLabs on Friday, February 18, 2011 | 9:17 AM

Recently we resolved a  JDBC connection issue with RAC database.  I will detail the issue in 8 steps

My Env setup :
We have 11gR2 RAC database running using ASM storage and all the servers are in network domain domain1. Client is using one JAVA application and it is running on non-RAC 11g database and the servers are in a different network domain domain2.
Our task :
Our task is to migrate the database that the JAVA applications is using to the RAC setup on ASM storage and establish the JAVA applications to connect to the newly migrated database. The big challenge we faced here is due to the reason that the setups are in different domains. We are using the 11gR2 SCAN concept,which complicated the issue even more.
What we did :
I am giving here the outlined view of the migration plan, but we should consider many other things in the actual migration process.
  1. export database from source
  2. Move the dump files to target database node.
  3. prepare the target database for import
  4. import the database to target database
  5. run utlrp to compile all the objects
  6. Verify the errors from import logfile
  7. "Note invalids,objects and schema status"
  8. Compare the objects status with the source
  9. verify the db links on target
All went fine. We tested the database connection from the server where java applications are running. We tested TOAD connection as well. All is well. We requested client to test the application after providing the JDBC connection string.

What is the issue :
Client raised an issue that the application is not able to connect to the database.

Troubleshooting:
As i said earlier, we tested TOAD connection. We tested sqlplus connection to the database. Both are working fine with the provided connecting string. Then we tried to dig into the SCAN listener concepts suspecting it might be an issue and configured everything as per the oracle documents. Finally we concluded that it is the issue only with JDBC connections.

Issue resolution :
Then prepared a java script to test the database java connections. Modified various settings on the database side and tested JDBC connection. Atlast we found the issue. The issue is with the connection string domain name specification.

How to test a Java Connection to oracle:
Pls see the video demo


Explanation:
As i said in my first sentence that the source and target environments are working in different domains, being source using domain2 and target using domain1. SCAN in domain1(RAC side) resolves to three IPs and the same is configured in the other network using NATing. Now the scan name resolves to three IPs in both source and target and they are connected with NATing. The host name in the connectiong string be the same as the init.ora parameter remote_listener and it should also match to the SCAN name. We should not include any domain names with SCAN name , remote_listername and with HOST setting in connecting string.

On Source RAC side:
The HOST=scan-cluster should exactly match the remote_listener parameter in the database.
SQL> show parameter remote_list
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
remote_listener                      string      scan-cluster:1521
On Applications Side: 
<database name="defaultOracle"
debug="false"
password="xxxxxxxxxxxxxxxx"
connectString="jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=scan-cluster) (PORT=1521))(CONNECT_DATA=(SERVICE_NAME=racpoc.domain1.com)(FAILOVER_MODE =(TYPE = SELECT)(METHOD = BASIC)(RETRIES = 180)(DELAY = 5))))" />
$ nslookup scan-cluster
Server:         128.191.2.13
Address:        128.191.2.13#53
Name:   scan-cluster.domain2.com
Address: 128.191.224.227
Name:   scan-cluster.domain2.com
Address: 128.191.224.29
Name:   scan-cluster.domain2.com
Address: 128.191.224.30

The Java Script to test Oracle Connection is :

import java.sql.*;
public class testconn {
public static void main(String[] s)throws Exception {
Class.forName("oracle.jdbc.OracleDriver");
String url="jdbc:oracle:thin:@(DESCRIPTION= (LOAD_BALANCE=on) (ADDRESS=(PROTOCOL=TCP)(HOST=scan-cluster)(PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=racpoc.domain)))";
for (int i=0; i<20; i++) {
try {
long x= System.currentTimeMillis () ;
Connection conn = DriverManager.getConnection(url,"askm","askm");
long y= System.currentTimeMillis ();
System.out.println("Connection Succesful "+conn);
System.out.println("Connection time is "+(y-x)/1000+" ms");
Statement stmt =conn.createStatement();
ResultSet res= stmt.executeQuery(" select host_name from v$instance");
while(res.next()) {
System.out.println(res.getString(1));
}
stmt.close();
conn.close();
}
catch(Exception e) {
e.printStackTrace();}}}}


Hope it helps
SRI

Install 10gR2 grid control and Agents

Written By askMLabs on Wednesday, February 9, 2011 | 2:00 PM

In the present article i will show you how to install 10gR2 grid control and also how to install agents on different hosts linux and windows to monitor databases.

This demo is prepared assuming that you already have 2 linux servers and 1 windows server created in vmware.

The following topics are demonstrated ...

  1. Installing 10gR2 grid control(OMS) on linux machine with new repository database and test the server URL.
  2. Installing agents on linux server with existing database
  3. Installing agents on linux when creating a new database with DBCA
  4. Installing agents on windows server with existing database
  5. Installing agents on windows when creating a new database with DBCA












Hope It Helps

SRI

relocate spfile from ASM to file system

Written By askMLabs on Thursday, February 3, 2011 | 1:35 AM

In the present article i am going to show you how to move the spfile located on ASM diskgroup to the file system. This may not be the practical requirement in the RAC as we need common place for the spfile to store. If we move spfile to local file system in RAC, then it is very hard to keep the spfiles on all the nodes in sync. But it will be useful if you are trying to change any non-dynamic parameter in the spfile.

Thats fine, how do we manage spfile, but lets see  the process how do we move the spfile located in ASM to the file system.
SQL> select name,user from v$database;

NAME                                               USER
-------------------------------------------------- ------------------------------
TESTDB                                             SYS

SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATA/testdb/spfiletestdb.ora
SQL>

[oracle@dhcppc1 ~]$ asmcmd
ASMCMD> cd +DATA/testdb/
ASMCMD> pwd
+DATA/testdb
ASMCMD> ls -lt spfile*
Type           Redund  Striped  Time             Sys  Name
N    spfiletestdb.ora => +DATA/TESTDB/PARAMETERFILE/spfile.270.738607517
ASMCMD>

[oracle@dhcppc1 datafiles]$ cd $ORACLE_HOME/dbs
[oracle@dhcppc1 dbs]$ pwd
/u01/app/11.2.0/db/dbs
[oracle@dhcppc1 dbs]$ ls -lrt init* spfile*
ls: spfile*: No such file or directory
-rw-r--r-- 1 oracle oinstall 2851 May 15  2009 init.ora
-rw-r----- 1 oracle oinstall   39 Dec 24 16:45 inittestdb.ora
[oracle@dhcppc1 dbs]$ mv inittestdb.ora inittestdb.ora_bak
[oracle@dhcppc1 dbs]$ ls -lrt init* spfile*
ls: spfile*: No such file or directory
-rw-r--r-- 1 oracle oinstall 2851 May 15  2009 init.ora
-rw-r----- 1 oracle oinstall   39 Dec 24 16:45 inittestdb.ora_bak
[oracle@dhcppc1 dbs]$

SQL> create pfile='/u01/app/11.2.0/db/dbs/inittestdb.ora' from spfile;

File created.

SQL> !ls -lrt /u01/app/11.2.0/db/dbs/inittestdb.ora
-rw-r--r-- 1 oracle dba 862 Dec 31 16:42 /u01/app/11.2.0/db/dbs/inittestdb.ora

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

ASMCMD> ls -lt spfile*
Type           Redund  Striped  Time             Sys  Name
N    spfiletestdb.ora => +DATA/TESTDB/PARAMETERFILE/spfile.270.738607517
ASMCMD> rm spfiletestdb.ora
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
TEMPFILE/
ASMCMD> ls -lt spfile*
ASMCMD-08002: entry 'spfile*' does not exist in directory '+DATA/testdb/'
ASMCMD>

SQL> create spfile='/u01/app/11.2.0/db/dbs/spfiletestdb.ora' from pfile='/u01/app/11.2.0/db/dbs/inittestdb.ora';

File created.

SQL> startup
ORACLE instance started.

Total System Global Area  723984384 bytes
Fixed Size                  1338980 bytes
Variable Size             486539676 bytes
Database Buffers          230686720 bytes
Redo Buffers                5419008 bytes
Database mounted.
Database opened.
SQL> select name,user from v$database;

NAME                                               USER
-------------------------------------------------- ------------------------------
TESTDB                                             SYS

SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/11.2.0/db/dbs/spfiletestdb.ora
SQL>


Hope it helps

SRI

Troubleshooting ASM disk drop

Written By askMLabs on Wednesday, February 2, 2011 | 1:44 PM

The present article describes how to troubleshoot  if you are not able delete an ASM disk from  the ASM storage. The troubleshooting technique may vary from person to person and the following article describes the technique  i used to drop an ASM disk. There may be so many other possible solutions to the issue, but the one presented here worked for me.

The present issue is that , i have to delete an ASM disk from the ASM storage. The disk is already marked as ASM disk and when i try to unmark it for ASM disk, it throws an error. So i cant delete the OS disk without deleting it from the ASM disks.

Present issue occured in 11gR2 RAC on linux and we are using multi path ASM disks for the storage.
[root@rac01 disks]# /etc/init.d/oracleasm deletedisk DATAVOL1
Removing ASM disk "DATAVOL1":                              [FAILED]




So i verified the log file  /var/log/oracleasm and the content of the log file shows me the following error
Unable to clear disk "DATAVOL1"
Clearing disk header: oracleasm-write-label: Unable to open device "/dev/oracleasm/disks/DATAVOL1": Device or resource busy
failed
Unable to clear disk "DATAVOL1"

I tried creating a diskgroup with this ASM disk and droped it and then tried to delete the ASM disk, but no use.
SQL> create diskgroup test external redundancy disk '/dev/oracleasm/disks/DATAVOL1';

Diskgroup created.

SQL> drop diskgroup test;
Diskgroup dropped.
SQL>

[root@rac01 disks]# /etc/init.d/oracleasm deletedisk DATAVOL1
Removing ASM disk "DATAVOL1":                              [FAILED]


I verified with the following command if the disk is still marked as ASM disk or not. It is still marked as ASM disk.
[root@rac01 disks]# blkid|grep sd.*oracleasm|while read a b;do echo -n $a$b" scsi_id=";(echo $a|tr -d [:digit:]|tr -d [:]|cut -d"/" -f3|xargs -i scsi_id -g -s /block/{})done | grep -i DATAVOL1;
/dev/sdc:LABEL="DATAVOL1" TYPE="oracleasm" scsi_id=360050768019600fba80000000000036b
/dev/sdf:LABEL="DATAVOL1" TYPE="oracleasm" scsi_id=360050768019600fba80000000000036b
/dev/sdi:LABEL="DATAVOL1" TYPE="oracleasm" scsi_id=360050768019600fba80000000000036b
/dev/sdl:LABEL="DATAVOL1" TYPE="oracleasm" scsi_id=360050768019600fba80000000000036b
/dev/sdo:LABEL="DATAVOL1" TYPE="oracleasm" scsi_id=360050768019600fba80000000000036b
/dev/sdp:LABEL="DATAVOL1" TYPE="oracleasm" scsi_id=360050768019600fba80000000000036b
/dev/sdu:LABEL="DATAVOL1" TYPE="oracleasm" scsi_id=360050768019600fba80000000000036b
/dev/sdx:LABEL="DATAVOL1" TYPE="oracleasm" scsi_id=360050768019600fba80000000000036b
[root@rac01 disks]#

[root@rac01 disks]# multipath -ll

..

..

vpath0 (360050768019600fba80000000000036b) dm-11 IBM,2145
[size=500G][features=1 queue_if_no_path][hwhandler=0][rw]
\_ round-robin 0 [prio=200][active]
\_ 2:0:7:0 sdo  8:224  [active][ready]
\_ 1:0:7:0 sdp  8:240  [active][ready]
\_ 2:0:6:0 sdu  65:64  [active][ready]
\_ 1:0:6:0 sdx  65:112 [active][ready]
\_ round-robin 0 [prio=40][enabled]
\_ 1:0:4:0 sdc  8:32   [active][ready]
\_ 1:0:5:0 sdf  8:80   [active][ready]
\_ 2:0:4:0 sdi  8:128  [active][ready]
\_ 2:0:5:0 sdl  8:176  [active][ready]
[root@rac01 disks]#


Then i tried clearing the disk with the OS command dd.
[root@rac01 disks]# dd if=/dev/zero of=/dev/dm-11 bs=1024 count=100
100+0 records in
100+0 records out
102400 bytes (102 kB) copied, 0.05526 seconds, 1.9 MB/s
[root@rac01 disks]# /etc/init.d/oracleasm deletedisk DATAVOL1
Removing ASM disk "DATAVOL1":                              [  OK  ]
[root@rac01 disks]# /etc/init.d/oracleasm listdisks
CRSVOL1
DATA1
FRADISK1
FRAVOL1
[root@rac01 disks]#

Now i am able to successfully delete the disk from ASM disk list.

On all other nodes in the RAC , do the following to sync
[root@rac02 disks]# /etc/init.d/oracleasm listdisks
CRSVOL1
DATA1
DATAVOL1
FRADISK1
FRAVOL1
[root@rac02 disks]# /etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks:               [  OK  ]
[root@rac02 disks]# /etc/init.d/oracleasm listdisks
CRSVOL1
DATA1
FRADISK1
FRAVOL1
[root@rac02 disks]#

Content from the log file /var/log/oracleasm now shows ...
Disk "DATAVOL1" defines an unmarked device
Dropping disk: done
Reloading disk partitions: done
Cleaning any stale ASM disks...
Validating disk "CRSVOL1"
Validating disk "DATA1"
Validating disk "FRADISK1"
Validating disk "FRAVOL1"




Hope it helps

SRI
 
Support :
Copyright © 2013. askMLabs - All Rights Reserved
Proudly powered by Blogger