Automating database recovery using Pipes (Linux) with sqlplus - dynamic recovery

Hi All,


This is neto from Brazil


How are you?


My friend Leighton Nelson ( had asked me ( to help him with a very interesting challenge.


AUTO for Oracle RAC database recovery does not work well, and we will need to execute some queries to find out the exactly change for the recovery.


select name, thread#, sequence#, first_change#, next_change# from v$archived_log where thread#=1 and 7728330471997 between first_change# and next_change#;


With the exactly change number, we will pass it as the STDIN for the sqlplus process (dynamically).




Terminal 1: As Oracle user run:


mkfifo sql

cat > sql &

sqlplus / as sysdba < sql > output


NOTE: sql is the pipe for STDIN and output is for STDOUT


Terminal 2: As Oracle user run:


tail -f output


NOTE: To check all output from sqlplus process.


Terminal 3: As Oracle user run:


echo "select * from v\$instance;" > sql


NOTE: Sending "select * from v$instance" to pipe sql - where it will be redirected to STDIN for sqlplus process


Now, it will be easier to execute queries to find out the change number (check STDOUT) and create dynamic queries to send to sqlplus process (STDIN).


echo "recover database using backup controlfile until cancel;" > sql

echo "+DG_ARCH/prod/archivelog/2014_01_06/thread_1_seq_27236.1832.836139501" > sql



Love you my friend,


All the best



NetApp - I love this company!