#!/bin/sh
rm -f /root/tmp/bclcustom.sh for i in `ls /root/tmp/bclresult*` do v_botang_thread=$( grep -A 2 INSTANCE_NUMBER $i | tail -n 1 | tr -d '[:blank:]') v_botang_currlog=$( grep 'Current log sequence' $i | tail -n 1 | cut -c 29- ) v_botang_currlogplus1=$[ $v_botang_currlog + 1 ] v_botang_oldestlog=$( grep 'Oldest online log sequence' $i | tail -n 1 | cut -c 29- ) v_botang_oldestlogbefore=$( grep 'Oldest online log sequence' $i | head -n 1 | cut -c 29- ) v_botang_nextlog=$( grep 'Next log sequence to archive' $i | tail -n 1 | cut -c 29- ) v_botang_nextlogbefore=$( grep 'Next log sequence to archive' $i | head -n 1 | cut -c 29- ) v_botang_currlogdest=$( grep 'Archive destination' $i | tail -n 1 | cut -c 29- ) v_botang_ip=$(echo $i | cut -f 2 -d - ) perl -i -pe "s,Oldest online log sequence $v_botang_oldestlog,Oldest online log sequence XXX," $i perl -i -pe "s,Oldest online log sequence $v_botang_oldestlogbefore,Oldest online log sequence AAA," $i perl -i -pe "s,Next log sequence to archive$v_botang_nextlog,Next log sequence to archive YYY," $i perl -i -pe "s,Next log sequence to archive$v_botang_nextlogbefore,Next log sequence to archive BBB," $i grep -v 'Current log sequence' $i > $i.tmp rm -f $i mv $i.tmp $i cat > /root/tmp/rac.sh < v_dbname=\$(cat /home/oracle/dbname | tr -d [:blank:]) v_ip=\$(ifconfig | grep '192\.168\.0' | head -n 1| cut -d . -f 4| cut -d ' ' -f 1) grep -q 'LABS ADD' /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora if [ \$? == '1' ] then echo " " >> /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora echo "rcat =" >> /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora echo " (DESCRIPTION =" >> /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora echo
" (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1521))"
>>
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora echo " (CONNECT_DATA =" >> /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora echo " (SERVER = DEDICATED)" >> /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora echo " (SERVICE_NAME = rcat.example.com)" >> /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora echo " )" >> /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora echo " )" >> /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora echo " " >> /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora echo '#LABS ADD' >> /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora fi if [ -f /u01/app/11.2.0/grid/dbs/hc_+ASM1.dat ] then echo "***Connecting Catalog***" su - oracle -c "rman target sys/oracle_4U@\$v_dbname catalog u90/oracle_4U@rcat" < resync catalog; ! fi echo " " if [ -f /u01/app/11.2.0/grid/dbs/hc_+ASM1.dat ] then su - grid -c "export ORACLE_SID=+ASM1;export ORACLE_HOME=/u01/app/11.2.0/grid;asmcmd"< /home/oracle/asm find / thread_${v_botang_thread}_seq_$v_botang_currlogplus1* exit EOF sleep 15 grep -i '+FRA' /home/oracle/asm | sort -n -k 3 -t . > /home/oracle/asm.tmp mv /home/oracle/asm.tmp /home/oracle/asm v_path1=\$(cut -f 2 -d '+' /home/oracle/asm | tail -n 1 | tr -d [:blank:]) v_path2="+"\$v_path1 su - grid -c "export ORACLE_SID=+ASM1;export ORACLE_HOME=/u01/app/11.2.0/grid;asmcmd"< rm -rf \$v_path2 exit EOF fi EOL scp
-q -o ConnectTimeout=1 -o StrictHostKeyChecking=no -o
NumberOfPasswordPrompts=1 -o ConnectionAttempts=1 /root/tmp/rac.sh
$v_botang_ip:/usr/bin ssh
-q -o ConnectTimeout=1 -o StrictHostKeyChecking=no -o
NumberOfPasswordPrompts=1 -o ConnectionAttempts=1 $v_botang_ip "chmod +x
/usr/bin/rac.sh" ssh
-q -o ConnectTimeout=1 -o StrictHostKeyChecking=no -o
NumberOfPasswordPrompts=1 -o ConnectionAttempts=1 $v_botang_ip
/usr/bin/rac.sh >>$i 2>&1 ssh
-q -o ConnectTimeout=1 -o StrictHostKeyChecking=no -o
NumberOfPasswordPrompts=1 -o ConnectionAttempts=1 $v_botang_ip "rm -rf
/usr/bin/rac.sh" rm -rf /root/tmp/bclshell-$v_botang_ip echo "v_dbname=\$(cat /home/oracle/dbname | tr -d [:blank:])" >> /root/tmp/bclshell-$v_botang_ip echo
'su - oracle -c "srvctl start instance -i ${v_dbname}1 -d $v_dbname -o
mount &>/dev/null"' >> /root/tmp/bclshell-$v_botang_ip echo
'su - oracle -c "srvctl start instance -i ${v_dbname}2 -d $v_dbname -o
mount &>/dev/null"' >> /root/tmp/bclshell-$v_botang_ip echo "if [ -f /u01/app/11.2.0/grid/dbs/hc_+ASM1.dat ]" >> /root/tmp/bclshell-$v_botang_ip echo "then" >> /root/tmp/bclshell-$v_botang_ip echo "sleep 10" >> /root/tmp/bclshell-$v_botang_ip echo "su - oracle -c \"rman target sys/oracle_4U@\${v_dbname} \" <> /root/tmp/bclshell-$v_botang_ip echo "run { " >> /root/tmp/bclshell-$v_botang_ip echo "set until sequence $v_botang_currlogplus1 thread $v_botang_thread;" >> /root/tmp/bclshell-$v_botang_ip echo "restore database;" >> /root/tmp/bclshell-$v_botang_ip echo "recover database;" >> /root/tmp/bclshell-$v_botang_ip echo "}" >> /root/tmp/bclshell-$v_botang_ip echo "EOF" >> /root/tmp/bclshell-$v_botang_ip echo "su - oracle -c \"sqlplus /nolog \" <> /root/tmp/bclshell-$v_botang_ip echo "conn sys/oracle_4U@\${v_dbname}1 as sysdba" >> /root/tmp/bclshell-$v_botang_ip echo "alter database flashback off;" >> /root/tmp/bclshell-$v_botang_ip echo "alter database open resetlogs;" >> /root/tmp/bclshell-$v_botang_ip echo "set echo off" >> /root/tmp/bclshell-$v_botang_ip echo "set feedback off" >> /root/tmp/bclshell-$v_botang_ip echo "@/home/oracle/rtable.sql;" >> /root/tmp/bclshell-$v_botang_ip echo "quit" >> /root/tmp/bclshell-$v_botang_ip echo "EOF" >> /root/tmp/bclshell-$v_botang_ip echo "su - oracle -c \"sqlplus /nolog \" <> /root/tmp/bclshell-$v_botang_ip echo "conn sys/oracle_4U@\${v_dbname}2 as sysdba" >> /root/tmp/bclshell-$v_botang_ip echo "alter database open;" >> /root/tmp/bclshell-$v_botang_ip echo "quit" >> /root/tmp/bclshell-$v_botang_ip echo "EOF" >> /root/tmp/bclshell-$v_botang_ip echo "fi" >> /root/tmp/bclshell-$v_botang_ip echo "rm -f /home/oracle/rtable.sql" >> /root/tmp/bclshell-$v_botang_ip
echo
" echo \"DELETE ARCHIVELOGS HAVE ALREADY BEEN RECOVERED FOR LAB15
SUCCESSFULLY,THE END AGAIN\"" >> /root/tmp/bclshell-$v_botang_ip scp
-q -o ConnectTimeout=1 -o StrictHostKeyChecking=no -o
NumberOfPasswordPrompts=1 -o ConnectionAttempts=1
/root/tmp/bclshell-$v_botang_ip $v_botang_ip:/usr/bin/ >/dev/null
2>&1 scp
-q -o ConnectTimeout=1 -o StrictHostKeyChecking=no -o
NumberOfPasswordPrompts=1 -o ConnectionAttempts=1
/root/tmp/bclsend-$v_botang_ip/rtable.sql $v_botang_ip:/home/oracle/
>/dev/null 2>&1 ssh
-q -o ConnectTimeout=1 -o StrictHostKeyChecking=no -o
NumberOfPasswordPrompts=1 -o ConnectionAttempts=1 $v_botang_ip chmod +x
/usr/bin/bclshell-$v_botang_ip (ssh
-q -o ConnectTimeout=1 -o StrictHostKeyChecking=no -o
NumberOfPasswordPrompts=1 -o ConnectionAttempts=1 $v_botang_ip
/usr/bin/bclshell-$v_botang_ip >>$i 2>&1)& done |