Monday, October 17, 2011

FINDING ORACLE HOMES AND DATABASES ON LINUX

Reason: 
After DB consolidation on one host it is hard to remember how many $ORACLE_HOME and home many databases under each oracle home.


How quickly to identify which Oracle process runs out of which $ORACLE_HOME on Linux(put this script to findhomes_bibo.sh file and execute chmod +x findhomes_bibo.sh)


echo -e "\033[1mDB_NAME\t\tORACLE_HOME\033[0m"
for ora in $(pgrep -lf _pmon_ | awk '{print $1}'); do for pid in $(pgrep -lf _pmon_ | grep $ora | awk '{print $2}' | cut -d_ -f 3); \
do echo -n $pid; done && ls -l /proc/$ora/exe | awk -F'>' '{ print $2 }' | sed 's/bin\/oracle$//'; done | sort -k2,2 | sed 's/\s/\'$'\t\t''/g'



You can find some other scripts in Internet and Oracle written script also, but I prefer my script because output is simple for understanding.

8 comments:

  1. cat /etc/oratab

    this working if DBA is not lazy to enter 1 row in expected format if DB created manually or cloned. If created by DBCA - row will be already there.

    ;)

    ReplyDelete