Oracle Instances on Linux – How to Identify Number of Oracle Instances Installed on Linux

linuxoracleredhat

Last day, I was at one training for Oracle installation and service start & shutdown. There I came to know about some Linux commands to start and shutdown an Oracle instance on a Linux machine.

To identify the instance running : The command below will return all Oracle instances which are currently running on that machine.

ps -ef | grep pmon

This command returns following results:

oracle    823     1  0 Dec03 ?        00:00:17 ora_pmon_instance1
oracle  19632     1  0 Nov17 ?        00:06:35 ora_pmon_instance2
oracle  24199     1  0 Nov20 ?        00:05:23 ora_pmon_instance3

Where instance1, instance2 and instance3 are 3 installations of Oracle on Linux, which are currently running.

My query: So, ps -ef will only show processes currently running. Suppose, instance3 is down and you need to start that instance. But, you don't know how many Oracle instances there are on the machine.

How would you get to know that this instance is down?

In Windows, there is a way called services, where you could came to know that these installations are done on Windows for Oracle.

Best Answer

There's no fool-proof way, but here's a list of ideas for you:

/etc/oratab:

Little script to give you a list of SIDs in the oratab:

cat /etc/oratab | grep -v '^#\|^\s*$' | cut -d: -f 1

$ORACLE_HOME/dbs

You can adapt the above script to look in all $ORACLE_HOMEs listed in the oratab, and search for initSID.ora and spfiles for any instances:

for ORACLEHOME in `cat oratab | grep -v '^#\|^\s*$' | cut -d: -f 2 |uniq`
do 
  ls -1 $ORACLEHOME/init*.ora | sed -n 's/init\(.*\).ora/\1/p'
  ls -1 $ORACLEHOME/spfile*.ora | sed -n 's/spfile\(.*\).ora/\1/p'
done

tnsnames.ora / listener.ora

Another option is to look in each $ORACLE_HOME/network/admin and analyse the tnsnames.ora and listener.ora files to see which instances have been configured.

Already Running Instances

You've already covered this with your pmon search. You can also use lsnrctl status to see which instances the listener is currently servicing requests for.