mapletree

an Oracle player in Ottawa
正文

automatically startup with multiple ORACLE_HOME

(2007-08-07 18:09:36) 下一個

--automatically startup and shutdown, with multiple ORACLE_HOMEs
  normally this is not a problem, but there's problem when 8i and 10g co-exist in oratab, and the default ORACLE_HOME is set to 8i.  as $ORACLE_HOME/bin/dbstartup will pickup 'svrmglr' instead of 'sqlplus /as sysdba'

$ORACLE_HOME/bin/dbstart |Ensures a clean startup of database instance(s), even after system failure  
-------------------------|-------------------------------------------------- 
$ORACLE_HOME/bin/dbshut  |Ensures a clean shutdown for data base instances    
-------------------------|-------------------------------------------------- 
/etc/oratab    or        |Contains a field that specifies whether a   particular database instance should be brought up/down at system startup/shutdown time.
/var/opt/oracle/oratab   | By pecifying "Y" in this field, the "dbstart" and "dbshut" scripts bring this database instance up or down.   
                       
--for:  SunOS ott-db-01 5.8 Generic_117350-33 sun4u sparc SUNW,Ultra-250, refer to following Doc and scripts
cat /usr/local/bin/oraenv
cat /etc/init.d/dbora
cat /etc/init.d/README   --how Solaris initiate the scripts during startup

/etc/init.d> ls -ltr dbora
-rwxr-xr-x   1 root     other       1350 Nov  9  2004 dbora
in /etc/rc2.d>, there's a link:
lrwxrwxrwx   1 root     other         17 Jul  8  2003 S99dbora -> /etc/init.d/dbora
in /etc/rc0.d>, there's a link:
lrwxrwxrwx   1 root     other         17 Jul  8  2003 K10dbora -> /etc/init.d/dbora

--check dbora, it's straighforward if there's only one ORACLE_HOME, how about if there're multiple ORACLE_HOMEs?
--/export/home/oracle> cat /var/opt/oracle/oratab
dpower:/oracle/app/product/8.1.7:Y
TOOLS:/oracle/app/product/8.1.7:Y
rcat:/oracle/app/product/10.2.0:Y
--in this case, the first 2 instance are up automatically, while the 3rd one will not


--note that the version of rcat , it's 10g, the other 2 are 8i
--/export/home/oracle> cat /var/opt/oracle/oratab
dpower:/oracle/app/product/8.1.7:Y
TOOLS:/oracle/app/product/8.1.7:Y
rcat:/oracle/app/product/10.2.0:Y

--check the dbstartup script:
/etc/init.d> cat dbora
#!/bin/sh
#
# Oracle Startup script
#
PATH=/oracle/app/product/8.1.7/bin:/usr/local/bin:$PATH
export PATH

ORA_HOME=/oracle/app/product/8.1.7
ORA_OWNER=oracle
APA_OWNER=orapache

#
# Setup Oracle Environment
#
# Default SID
#
ORACLE_SID=dpower
#
# Use the SID set above for getting Oracle Environment Information
#
ORAENV_ASK=NO
if [ -f /usr/local/bin/oraenv ];then
. /usr/local/bin/oraenv
else
 echo "Missing /usr/local/bin/oraenv Oracle startup aborted"
 exit 1
fi

if [ ! -f $ORA_HOME/bin/dbstart ]
      then
        echo "Oracle startup: cannot start"
        exit
      fi
      case "$1" in
         'start') # Start the Oracle databases and Net8 listener
                  su $ORA_OWNER -c "$ORA_HOME/bin/dbstart" &
                  su $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" &
                  # Next line for Oracle 8.1.7 only
                  su $ORA_OWNER -c "$ORA_HOME/Apache/Apache/bin/apachectl start"
                  ;;
         'stop')  # Stop the Oracle databases and Net8 listener
                  su  $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" &
                  su  $ORA_OWNER -c "$ORA_HOME/bin/dbshut" &
                  # Next line for Oracle 8.1.7 only
                  su  $ORA_OWNER -c "$ORA_HOME/Apache/Apache/bin/apachectl stop"
                  ;;
        *) echo "\nUsage: `basename $0` stop|start\n"
      esac
 
--when checking the DB version, it choose svrmgrl, this is not able to start a DB 10g
if [ -f $ORACLE_HOME/bin/sqldba ] ; then
    VERSION=`$ORACLE_HOME/bin/sqldba command=exit | awk '
            /SQL\*DBA: (Release|Version)/ {split($3, V, ".") ;
            print V[1]}'`
    SQLDBA=sqldba
else
    if [ -f $ORACLE_HOME/bin/svrmgrl ] ; then
        SQLDBA=svrmgrl
    else
        SQLDBA="sqlplus /nolog"
    fi
fi

--while "sqlplus /nolog" could be used to start up a 8i DB,
  so modify dbora, let it refer to dbstart in a 10g ORACLE_HOME could resolve this issue

--will need root access to modify the script
/etc/init.d> ls -ltr dbora
-rwxr-xr-x   1 root     other       1350 Nov  9  2004 dbora

--and also, need to modify the listener in 10g ORACLE_HOME, make sure it listens for the 2 8i instance
here's another question, what will happen if 2 listeners on a box listen for a same instance?
how about the 2 listeners with the same name?

[ 打印 ]
閱讀 ()評論 (0)
評論
目前還沒有任何評論
登錄後才可評論.