Anda di halaman 1dari 13

#!

/bin/csh # srdf_db_step_1 # Step 1 for SRDF Backup # ---------------------------# 15-Feb-2006 Alejandro Vargas # ------------------------------------------------------------------------------# This script does: # 1) Set rebalance power to 0 on all ASM disk groups # 2) Issue Begin backup # 3) Archive log all and switch logfile on instance $1 # 4) Archive log all and switch logfile on instance $2 # IF this script succeeds Storage, after having established it, execute split of # the Data Disk Group # ------------------------------------------------------------------------------# This script works with 2 nodes only, if you have more than 2 nodes you need to customize it. # # This script use aliases and Environment variables set on .cshrc # to setup the environment to point to the ASM instance or the Database: # setenv DBS_HOME /u01/app01/oracle/product/10gDB # setenv ASM_HOME /u01/app01/oracle/product/10gASM # setenv BASE_PATH /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bi n:/usr/X11R6/bin:/root/bin # alias 10asm 'setenv $ORACLE_HOME $ASM_HOME; setenv PATH $ORACLE_HOME/bin:$BASE_PATH' # alias 10db 'setenv $ORACLE_HOME $DBS_HOME; setenv PATH $ORACLE_HOME/bin:$BASE_PATH' # This script do require as parameters the 2 instance names # It will use them to archive all required logs from instances 1 and 2 if ( $#argv != 2 ) then

echo this script needs 2 parameters echo the Oracle SID's on Nodes 1 and 2 exit Endif setenv TERM vt100 source ~/.cshrc 10asm set vdir=$DB_SCRIPTS/RAC set vlog=$DB_SCRIPTS/log/step1_`date | awk '{print $2"_"$3"_"$4}'`.log cd $vdir setenv ORACLE_SID `ps -ef |grep asm|grep pmon|grep -v grep|cut -d_ -f3` # Step 1: Set rebalance power ot 0 on all diskgroups: # -------------------------------------------------sqlplus -s '/ as sysdba' << EOF > /dev/null set pages 50000 lines 120 echo off head off feed off veri off ti off term off spool rebout.sql select 'alter diskgroup '||name||' rebalance power 0;' from v\$asm_diskgroup / spool off set pages 50000 lines 120 echo on head on feed on veri on ti on spool $vlog select 'ON STEP 1 ASM: set rebalance power to 0' from dual / @rebout.sql spool off exit

EOF 10db setenv ORACLE_SID $1 # Step 2: Begin backup and switch logfile # --------------------------------------sqlplus -s '/ as sysdba' << EOF > /dev/null set pages 50000 lines 120 echo on head on feed on veri on ti on spool tmp.log select 'ON STEP 2 $1: Begin backup and switch logfile' from dual / select instance_name from v\$instance / alter database begin backup / alter system switch logfile / alter system archive log current / spool off !cat tmp.log >>$vlog !rm tmp.log connect /@$2; spool tmp.log select 'ON STEP 2 $2: Begin backup and switch logfile' from dual / select instance_name from v\$instance /

alter system switch logfile / alter system archive log current / spool off exit EOF # Here we check status, if there are errors on the log file we send to the standard output 1 # The storage script will exit if it gets 1 as result of running this script cat tmp.log >>$vlog rm tmp.log egrep -e ORA- -e SP2-0640 $vlog > /dev/null if ( "$status" == 0 ) then echo 1 else echo 0 endif exit # eof srdf_db_step_1

#!/bin/csh # srdf_db_step_2 # Step 2 for SRDF Backup # ----------------------------# 15-Feb-2006 Alejandro Vargas # ----------------------------# This scripts does: # 1) make 2 backups of the control file on the ARCH Disk Group # 2) Take the database out of backup mode # 3) Archive all and Force a log switch on $1 # 4) Create backup controlfile control_start # 5) Create backup controlfile control_backup # 6) Archive all and Force a log switch on $2 # IF this script succeeds Storage, after having established it, execute split of # the Arch Disk Group # -----------------------------------------------# # This script works with 2 nodes only, if you have more than 2 nodes you need to customize it. # # This script use aliases and Environment variables set on .cshrc # to setup the environment to point to the ASM instance or the Database: # setenv DBS_HOME /u01/app01/oracle/product/10gDB # setenv ASM_HOME /u01/app01/oracle/product/10gASM # setenv BASE_PATH /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bi n:/usr/X11R6/bin:/root/bin # alias 10asm 'setenv $ORACLE_HOME $ASM_HOME; setenv PATH $ORACLE_HOME/bin:$BASE_PATH' # alias 10db 'setenv $ORACLE_HOME $DBS_HOME; setenv PATH $ORACLE_HOME/bin:$BASE_PATH' # This script do require as parameters the 2 instance names

# It will use them to archive all required logs from instances 1 and 2 if ( $#argv != 2 ) then echo this script needs 2 parameters echo the Oracle SID's on Nodes 1 and 2 exit Endif source ~/.cshrc # Required variables (customize to your needs) # -------------------------------------------set vasm=archdg # disk group and path to store control file backups set vdir=$DB_SCRIPTS/RAC # script directory set vlog=$vdir/../log/step2_`date | awk '{print $2"_"$3"_"$4}'`.log # log location and name cd $vdir 10asm setenv ORACLE_SID `ps -ef |grep asm|grep pmon|grep -v grep|cut -d_ -f3` asmcmd rm $vasm/control_backup >& /dev/null asmcmd rm $vasm/control_start >& /dev/null 10db setenv ORACLE_SID $1 sqlplus -s '/ as sysdba' << EOF >/dev/null set pages 50000 lines 120 echo on head on feed on veri on ti on spool $vlog

select 'ON STEP 1-4 ON $1 : database end backup - switch logfile - 2 backup controlfile' from dual; select instance_name from v\$instance; alter database end backup; alter database backup controlfile to '+$vasm/control_backup'; alter database backup controlfile to '+$vasm/control_start'; alter system switch logfile; alter system switch logfile; spool off connect /@$2; spool tmp.log select 'ON STEP 5 ON $2 : switch logfile' from dual; select instance_name from v\$instance; alter system switch logfile; alter system switch logfile; spool off exit EOF cat tmp.log>>$vlog rm tmp.log # Here we check status, if there are errors on the log file we send to the standard output 1 # The storage script will exit if it gets 1 as result of running this script grep ORA- $vlog > /dev/null if ( "$status" == 0 ) then echo 1 else echo 0 endif

exit # eof srdf_db_step_2

#!/bin/csh # srdf_db_step_3 # Step 3 for SRDF Backup # ---------------------------# 15-Feb-2006 Alejandro Vargas # ------------------------------------------------------------------------------------# This script set rebalance power to 5 on ASM # IF this script succeeds Storage, Mount the SRDF copy on the Backup server to proceed # to check it. # ------------------------------------------------------------------------------------# This script use aliases and Environment variables set on .cshrc # to setup the environment to point to the ASM instance: # setenv ASM_HOME /u01/app01/oracle/product/10gASM # setenv BASE_PATH /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bi n:/usr/X11R6/bin:/root/bin # alias 10asm 'setenv $ORACLE_HOME $ASM_HOME; setenv PATH $ORACLE_HOME/bin:$BASE_PATH' # This script do not require arguments 10asm echo set vdir=$DB_SCRIPTS/RAC set vlog=$vdir/../log/step3_`date | awk '{print $2"_"$3"_"$4}'`.log cd $vdir setenv ORACLE_SID `ps -ef |grep asm|grep pmon|grep -v grep|cut -d_ -f3`

# Step 1: Set rebalance power to 5 on all diskgroups: # ---------------------------------------------------

sqlplus -s '/ as sysdba' << EOF > /dev/null set pages 50000 lines 120 echo off head off feed off veri off ti off spool rebin.sql select 'alter diskgroup '||name||' rebalance power 5;' from v\$asm_diskgroup / spool off set pages 50000 lines 120 echo on head on feed on veri on ti on spool $vlog @rebin.sql spool off exit EOF # Here we check status, if there are errors on the log file we send to the standard output 1 # The storage script will exit if it gets 1 as result of running this script grep ORA- $vlog > /dev/null if ( "$status" == 0 ) then echo 1 else echo 0 endif exit # eof r2_step3

#!/bin/csh # srdf_open_readonly # Step 4 of SRDF Backup. Check the backup # --------------------------------------# 15-Feb-2006 Alejandro Vargas # ------------------------------------------------------------------------------# This script run on the backup server. # The backup server must be configured with an ASM home and a Database home, Single Instance # The script does: # 1) Start ASM Instance # 2) Mount the Database # 3) Recover the Database until cancel # 4) Open the database in Read Only Mode # 5) Log a simple database checkup # 6) Shutdown the database # 7) Shutdown the ASM Instance # IF this script succeeds Storage, after having established it, execute split of # the Data Disk Group # ------------------------------------------------------------------------------# This script works with 2 nodes only, if you have more than 2 nodes you need to customize it. # # This script use aliases and Environment variables set on .cshrc # to setup the environment to point to the ASM instance or the Database: # setenv DBS_HOME /u01/app01/oracle/product/10gDB # setenv ASM_HOME /u01/app01/oracle/product/10gASM # setenv BASE_PATH /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bi n:/usr/X11R6/bin:/root/bin # alias 10asm 'setenv $ORACLE_HOME $ASM_HOME; setenv PATH $ORACLE_HOME/bin:$BASE_PATH' # alias 10db 'setenv $ORACLE_HOME $DBS_HOME; setenv PATH $ORACLE_HOME/bin:$BASE_PATH'

# This script do require as parameters the 2 instance names # It will use them to archive all required logs from instances 1 and 2 if ( $#argv != 1 ) then echo this script needs 1 parameter echo the Oracle SID's , that is the database name if coming from RAC. exit Endif # Clean up any possible oracle processes before start # --------------------------------------------------ps -ef | grep pmon | grep -v grep | xargs kill -9 >& /dev/null source ~/.cshrc set vlog=$DB_SCRIPTS/log/openR2readonly_`date | awk '{print $2"_"$3"_"$4}'`.log 10asm setenv ORACLE_SID `ps -ef |grep asm|grep pmon|grep -v grep|cut -d_ -f3` sqlplus '/ as sysdba' <<EOF > $vlog startup; exit EOF 10db setenv ORACLE_SID $1 sqlplus '/ as sysdba' <<EOF >> $vlog startup mount; recover database using backup controlfile until cancel; auto alter database open read only;

exit EOF set UpInd=`echo "select 'OK' from dual;" | sqlplus -s / | grep OK | wc -l` sqlplus '/ as sysdba' <<EOF >> $vlog select file_name from dba_data_files; shutdown immediate; exit EOF 10asm setenv ORACLE_SID `ps -ef |grep asm|grep pmon|grep -v grep|cut -d_ -f3` sqlplus '/ as sysdba' <<EOF >> $vlog shutdown immediate; exit EOF # Check if the procedure succeeded # If not Storage script will send failure status to Admins if ("$UpInd" == "1") then echo 0 else echo 1 endif Exit # eof srdf_open_readonly

Anda mungkin juga menyukai