zondag, november 01, 2009

oraenv oddities in 11gR2

Recently I was installing a regular 11gR2 installation and tried to use it by an other user than the software owner or a member of the dba group. A - so called - regular user.


When I ran oraenv to configure my environment for the ORACLE_SID I was going to use I was told that


ORACLE_BASE environment variable is not being set since this
information is not available for the current user ID ciber
You can set ORACLE_BASE manually if it is required.

This made me wonder why so I dived in the /usr/local/bin/oraenv script and found:

ORABASE_EXEC=$ORACLE_HOME/bin/orabase

if [ ${ORACLE_BASE:-"x"} != "x" ]; then
echo "The Oracle base for ORACLE_HOME=$ORACLE_HOME is $ORACLE_BASE"
else
if [ -w $ORACLE_HOME/inventory/ContentsXML/oraclehomeproperties.xml ]; then
if [ -e $ORABASE_EXEC ] ; then
if [ -x $ORABASE_EXEC ]; then
ORACLE_BASE=`$ORABASE_EXEC`
export ORACLE_BASE
echo "The Oracle base for ORACLE_HOME=$ORACLE_HOME is $ORACLE_BASE"
else
echo "The $ORACLE_HOME/bin/orabase binary does not have execute privilege"
echo "for the current user, $USER. Rerun the script after changing"
echo "the permission of the mentioned executable."
fi
else
ORACLE_BASE=$ORACLE_HOME
export ORACLE_BASE
echo "The Oracle base for ORACLE_HOME=$ORACLE_HOME is $ORACLE_BASE"
fi
else
echo "ORACLE_BASE environment variable is not being set since this"
echo "information is not available for the current user ID $USER."
echo "You can set ORACLE_BASE manually if it is required."
fi
fi


What this code does is
1) check ORACLE_BASE
2) if set => all ok and report ORACLE_BASE
3) else, check if $ORACLE_HOME/inventory/ContentsXML/oraclehomeproperties.xml is WRITEABLE and try to set ORACLE_BASE using $ORACLE_HOME/bin/orabase.


I made a little tweek on this script, to check for READABLE on $ORACLE_HOME/inventory/ContentsXML/oraclehomeproperties.xml. Why would we give an ordinary user write privileges on anything within ORACLE_HOME? ([in]Secure by default?).


Still I keep getting this error:


ORACLE_BASE environment variable is not being set since this
information is not available for the current user ID ciber.
You can set ORACLE_BASE manually if it is required.

So when the script is no longer the culprit, the filesystem security bits have to be it. In unix, to be able to access a file, all directories that we have to pass through need to have at least execute permission for me to pass. The fresh created app directory (/home/oracle/app) has 770 so I won't be able to pass this one.

chmod o+x app

to fix that but still I am getting the same error. When digging deeper I get to $ORACLE_HOME/inventory that also has 770 defined on it. Here again:

chmod o+x $ORACLE_HOME/inventory

Now it is the ContentsXML directory that is blocking me, it again has 770.

chmod o+x $ORACLE_HOME/inventory/ContentsXML

Finally we get to the oraclehomeproperties.xml file, this has 660 for the permisssion bits. To fix this

chmod o+r $ORACLE_HOME/inventory/ContentsXML/oraclehomeproperties.xml

Finally oraenv does no longer complain.


If it is important enough to give an error message when running oraenv, why make this file inaccessible to other users? BTW: my previous post was more or less caused by figuring out this setup. I thought I made an error so I wanted to re-install the ORACLE_HOME, just to make sure that what I write is right.

more deinstall headaches

Today I needed to re-install an ORACLE_HOME. Why? I have my reasons so let me do it. In the old days we ran $ORACLE_HOME/oui/runInstaller and selected deinstall product to get rid of the software. Now, 11gR2 (11.2.0.1) the only reaction is a popup box telling me to run $ORACLE_HOME/deinstall/deinstall to deinstall the ORACLE_HOME.


The specified ORACLE_HOME is used for a database, a database that I did not want to loose. Instead of just do what I ask, deinstall the specified ORACLE_HOME, I get a huge list of questions and end up with a system that no longer has the ORACLE_HOME on it (even the directory is deleted), but also a system that no longer has the database files on it. This came as a big surprise and not one that I liked.


Why should Oracle delete my database? There is no reason for that. If I want to delete a database, I will do so. If I deinstall an ORACLE_HOME, I expect the ORACLE_HOME to be deinstalled. I can live with the fact that ORACLE_HOME is deleted, I can not live with the fact that during this deinstallation also my database, not living in ORACLE_HOME, is deleted.


Please Oracle, give me back a normal deinstall and leave my databases alive. If I start $ORACLE_HOME/deinstall/deinstall, als are you sure, once, and deinstall the ORACLE_HOME, not the rest. In this case I was going to install the software again and bring up my database again using the fresh installation.


Tip for other dba's: test the deinstall process before you try it on a production system .... It does deinstall but not as we expect it ...