Need help in getting the oracle instance name which is offline in 10g through shell scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help in getting the oracle instance name which is offline in 10g through shell scripting
# 1  
Old 02-10-2012
Need help in getting the oracle instance name which is offline in 10g through shell scripting

SmilieHi,

I am not sure whether i can post this question in this forum or not. because it is not completely releated to unix, but also oracle.

My question is,
How can we know the instance name(particularly the last number, eg., in INST_DB12, i need 12) when it is OFFLINE(i.e., down) through a Shell script.

Suppose if we have 2 instances INST_DB11 and INST_DB12, and we have made one of them, say INST_DB12, down.

And if we know the instance names, we can directly export it from Linuz prompt and startup the instance using sqlplus as below:
Code:
 
$ export ORACLE_SID=INST_DB12
$ sqlplus as sysdba
SQL>startup;
...
...
...
SQL>exit;
$

But if we dont know the instance name, how can we know the instance name to export it before starting up..?

To my knowledge, we can get the instance names by 3 ways.
one is
Code:
 
ps -ef | grep pmon

from which we can get the instance name.

Other one is
Code:
 
/opt/oracle/product/10.2.0/crs/bin/crs_stat -t

using the above command, we can know which one is online or offline.
but i am unable to trust its output because sometimes, the status is showing as UNKNOWN instead of either ONLINE or OFFLINE.

Third one is using
Quote:
/etc/oratab
file.
But this file consists of all the instance names, but no information whether they are online or offline.

so unable to trust in all the three ways, and so failed to solve this issue.

I need to get the insance name including with the number at the end(12 in INST_DB12) through a shell script.

Please help me in this regard.
# 2  
Old 02-10-2012
So what keeps you from combining the 2 methods you trust partly?
The result could look like this:
Code:
OIFS=$IFS
IFS=:
while read O_SID DUMMY
do
   if ps -ef |grep pmon |grep -v grep >/dev/null
   then
      echo $O_SID is up
   else
      echo $O_SID is down
   fi
done </etc/oratab
IFS=$OIFS

Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. AIX

HACMP 5.4.1->5.5 offline upgrade - different instance numbers ?

Hello, I did offline HACMP(PowerHA) upgrade 5.4.1 to 5.5 - basically stopped HACMP services and upgraded cluster.* filesets. Tried to start services again - topsvcs refused to start on second node complaining that node instance numbers are different - and indeed they are different. This is... (2 Replies)
Discussion started by: vilius
2 Replies

2. AIX

Oracle 10g on AIX7

Hi, anyone know if Oracle Database 10g is AIX 7 certified??? thanks in advance. Regards. Mario (2 Replies)
Discussion started by: Zio Bill
2 Replies

3. Shell Programming and Scripting

Need help in writing a shell Script to connect to oracle instance

Please help me in writing a shell script which connects to a Oracle instance and tables to get the required information...:wall: (1 Reply)
Discussion started by: Dpu
1 Replies

4. AIX

oracle 10g on AIX 5

hi can anyone help me by telling step by stem oracle10g installation in AIX 5 . Munir mondolsoft Bangladesh (3 Replies)
Discussion started by: dbamunir
3 Replies

5. Red Hat

Help installing Oracle 9i/10g on RedHat?

If anybody can help would be greatly appreciated... I get the same error with Oracle 9i & 10g when installing on Red Hat Fedora 4, it's java related... Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/OraInstall2007-03-16_01-09PM/jre/lib/i386/libawt.so: connat restore segment... (0 Replies)
Discussion started by: Joncamp
0 Replies

6. Shell Programming and Scripting

Shell Scripting with Oracle...

Hi guys, I have searched all the forums and searched the net as much as possible, but I carn't find any tutorials about shell scripting with Oracle. Has anyone come across any? Thanks for reading and in advance of posts, B14... (2 Replies)
Discussion started by: B14speedfreak
2 Replies

7. UNIX for Advanced & Expert Users

oracle 10g

I have download Oracle 10g for Solaris and I have configurate environment than I will start runInstaller and I have a messege that my version of solaris is not 5.7 , 5.8 and 5,9 I have 5.10 Solaris version what I shoud do I have download most actuall Oracle databases. (4 Replies)
Discussion started by: Deux
4 Replies
Login or Register to Ask a Question