Re: Map database to running instance from oratab?

  • From: Ethan Post <post.ethan@xxxxxxxxx>
  • To: "Radoulov, Dimitre" <cichomitiko@xxxxxxxxx>
  • Date: Tue, 24 Jul 2012 12:14:10 -0500

Thanks for all who contributed answers, seems there are no easy answers.
Ideally some of these things would be exposed externally without having to
look into the database. There are things I might like to know before I even
log in with a script. Is it running, is it a standby, is it rac non-rac,
what is the instance name...
Anyway here is what I came up with, this is my

.get-active-instance-from-database.sh script. Makes use of a couple other
custom scripts.

. .require.sh DATABASE "${1}"

.list-all-databases.sh | grep "^${1}$" | while read DATABASE; do
   INSTANCE=$(ps -ef | grep "[ora|asm]_smon_${DATABASE}$" | grep -v "grep"
| cut -d"_" -f3)
   if [[ -z "${INSTANCE}" ]]; then
      i=0
      while (( ${i} < 5 )); do
         ((i=i+1))
         INSTANCE=$(ps -ef | grep "[ora|asm]_smon_${DATABASE}${i}$" | grep
-v "grep" | cut -d"_" -f3)
         [[ -n "${INSTANCE}" ]] && break
      done
   fi
done

if [[ -z ${INSTANCE} ]]; then
   .warning.sh "$0" "Failed to map instance to database ${1}. Verify
database is running and in oratab file."
else
   echo ${INSTANCE}
fi


--
//www.freelists.org/webpage/oracle-l


Other related posts: