Re: auto start a data guard physical standby Oracle 11.2

From: Ls Cheng <exriscer_at_gmail.com>
Date: Thu, 6 Jun 2013 20:53:35 +0200
Message-ID: <CAJ2-Qb8hXNGdbj-wziVCPNwgMgzLA5WjJKgdXvT9fV4huquH9A_at_mail.gmail.com>



Hi
Any reason not use Data Guard in 11g? It works pretty good in 11g.

In ther other hand a few years ago I had to do a db startup script in Linux for DG, the code is roughly following. If you are using RAC then use the srvctl command you have mentioned.

start_db()
{

    # Parameter 1 -> Oracle SID
    ORACLE_SID=$1
    # Do not start oracle until the /u02/oradata fs is mounted     if [ ! -d $ORADATA ]; then

        echo "$ORADATA not mounted..."
        return 1

    fi

    tmpfile='/tmp/oracle-init.tmp'
    dgfile='/tmp/oracle-dg.tmp'

    echo "startup mount" > $tmpfile
    echo "set pagesize 0" >> $tmpfile
    echo "select 'DB_ROLE:' || decode(DATABASE_ROLE, 'PRIMARY', 'FALSE',
'TRUE') from v\$database;" >> $tmpfile

    echo "quit" >> $tmpfile

    $SUBIT "export ORAENV_ASK=NO; export ORACLE_SID=$ORACLE_SID; .
/usr/local/bin/oraenv; sqlplus / as sysdba" < $tmpfile | tee -a $LOGFILE |
tee $dgfile > /dev/null

    result=$?

    if [ $result -ne 0 ]; then

        echo "Oracle DB did not mount..."
        return 1

    fi

    ISDG=`grep DB_ROLE $dgfile | awk -F":" '{ print $2 }'`     if [ "$ISDG" == "FALSE" ]; then

        echo "alter database open;" > $tmpfile
        echo "quit" >> $tmpfile
    else
        echo "alter database recover managed standby database using current
logfile;" > $tmpfile
        echo "quit" >> $tmpfile

    fi

    $SUBIT "export ORAENV_ASK=NO; export ORACLE_SID=$ORACLE_SID; .
/usr/local/bin/oraenv; sqlplus / as sysdba" < $tmpfile >> $LOGFILE

    result=$?

    if [ $result -ne 0 ]; then

        #echo "Oracle DB did not start..."
        return 1
    else
        return 0

    fi
}

Regards

--
http://www.freelists.org/webpage/oracle-l
Received on Thu Jun 06 2013 - 20:53:35 CEST

Original text of this message