Finding out the version of a database without logging into it?




A recent technet question that was asked was 'how can i tell what version of the database is running without logging onto it'? If i have 6 versions of oracle installed and 10 databases this could be difficult to work out.

On the face of it you would just say look in the oratab file - however in this case that file was not reliable. So how could this be done? I guess there is more than one way to approach this but a simple way is just to do the following.

First up we need to find the pid of one of the pmon processes - in this case i'm looking at the pmon for the database DBNAME

#ps -ef |grep pmon |grep DBNAME
oracle    7665     1  0 14:36 ?        00:00:01 ora_pmon_DBNAME


Once we have the pid we can use lsof to see which oracle software pmon is using - i choose the oraus.msb file to check this but there are other files you could use




# lsof | grep 7665 |grep oraus.msb
oracle     7665     oracle    8r      REG             253,10     1092096   1982497 /oracle/11.2.0.2.0.DB/rdbms/mesg/oraus.msb
oracle     7665     oracle   16r      REG             253,10     1092096   1982497 /oracle/11.2.0.2.0.DB/rdbms/mesg/oraus.msb









This gives us the ORACLE_HOME - in this case /oracle/11.2.0.2.0.DB

Now we can us OPatch to find out what software is actually installed in that home (in my case you can probably guess - but not all homes are named with the version they are)

# /oracle/11.2.0.2.0.DB/OPatch/opatch lsinventory -oh /oracle/11.2.0.2.0.DB |grep "Oracle Database"
Oracle Database 11g                                                  11.2.0.2.0


Note here we use the OPatch from the home we discovered (though we didnt have to - but we are pretty sure this one will work), we also use the -oh parameter to override any setting of ORACLE_HOME in the users environment.

So there you go we found out DBNAME is version 11.2.0.2 without logging on to it.....

Comments