Sunteți pe pagina 1din 3

rman_pipes.sql rman_pipes.sql rman_pipes.sql rman_pipes.

sql
connect connect connect connect / / / / as sysdba as sysdba as sysdba as sysdba
set serveroutput on size set serveroutput on size set serveroutput on size set serveroutput on size 50000 50000 50000 50000
pause pause pause pause
REM Demo the RMAN pipe interface using pipe called DEMO REM Demo the RMAN pipe interface using pipe called DEMO REM Demo the RMAN pipe interface using pipe called DEMO REM Demo the RMAN pipe interface using pipe called DEMO_ __ _PIPE PIPE PIPE PIPE
REM THe procedure once created is invoked REM THe procedure once created is invoked REM THe procedure once created is invoked REM THe procedure once created is invoked : : : : exec rman exec rman exec rman exec rman_ __ _cmd cmd cmd cmd( (( ('< '< '< '<command command command command>;' >;' >;' >;') )) ); ;; ;
REM RMAN is started with RMAN PIPE DEMO REM RMAN is started with RMAN PIPE DEMO REM RMAN is started with RMAN PIPE DEMO REM RMAN is started with RMAN PIPE DEMO_ __ _PIPE timeout PIPE timeout PIPE timeout PIPE timeout 600 600 600 600 target system target system target system target system/ // /oracle oracle oracle oracle
REM Terminator messages is REM Terminator messages is REM Terminator messages is REM Terminator messages is : : : : RMAN RMAN RMAN RMAN- -- -00572 00572 00572 00572 " "" "waiting for dbms waiting for dbms waiting for dbms waiting for dbms_ __ _pipe input pipe input pipe input pipe input" "" "
REM For UNIX do the following REM For UNIX do the following REM For UNIX do the following REM For UNIX do the following: :: :
Host rman pipe demo Host rman pipe demo Host rman pipe demo Host rman pipe demo_ __ _pipe timeout pipe timeout pipe timeout pipe timeout 600 600 600 600 target target target target / / / / \& \& \& \&
REM REM REM REM
REM For Windows do the Following REM For Windows do the Following REM For Windows do the Following REM For Windows do the Following: :: :
REM REM REM REM
REM host start cmd REM host start cmd REM host start cmd REM host start cmd / // /k k k k " "" "rman PIPE DEMO rman PIPE DEMO rman PIPE DEMO rman PIPE DEMO_ __ _PIPE timeout PIPE timeout PIPE timeout PIPE timeout 600 600 600 600 target system target system target system target system/ // /oracle oracle oracle oracle" "" "
rem check that the rman session is started waiting for pipe input rem check that the rman session is started waiting for pipe input rem check that the rman session is started waiting for pipe input rem check that the rman session is started waiting for pipe input
pause pause pause pause
set numwidth set numwidth set numwidth set numwidth 8 88 8
col event for a col event for a col event for a col event for a27 27 27 27
col p col p col p col p1 11 1text for a text for a text for a text for a10 10 10 10
col p col p col p col p2 22 2text for a text for a text for a text for a10 10 10 10
col p col p col p col p3 33 3text for a text for a text for a text for a10 10 10 10
rem first show the event and parameters rem first show the event and parameters rem first show the event and parameters rem first show the event and parameters
pause pause pause pause
select sid select sid select sid select sid, , , , seq seq seq seq#, #, #, #,event event event event, ,, ,
p pp p1 11 1text text text text, ,, ,p pp p1 11 1, ,, ,p pp p1 11 1raw raw raw raw, ,, ,
p pp p2 22 2text text text text, ,, ,p pp p2 22 2, ,, ,p pp p2 22 2raw raw raw raw
from v from v from v from v$ $$ $session session session session_ __ _wait wait wait wait
where event like where event like where event like where event like ' '' '% %% %pipe pipe pipe pipe% %% %' '' '
order by event order by event order by event order by event; ;; ;
rem clean up in case of data left in pipe rem clean up in case of data left in pipe rem clean up in case of data left in pipe rem clean up in case of data left in pipe
pause pause pause pause
exec dbms exec dbms exec dbms exec dbms_ __ _pipe pipe pipe pipe. .. .purge purge purge purge( (( (' '' 'ORA ORA ORA ORA$ $$ $RMAN RMAN RMAN RMAN_ __ _DEMO DEMO DEMO DEMO_ __ _PIPE PIPE PIPE PIPE_ __ _IN IN IN IN' '' ') )) ); ;; ;
exec dbms exec dbms exec dbms exec dbms_ __ _pipe pipe pipe pipe. .. .purge purge purge purge( (( (' '' 'ORA ORA ORA ORA$ $$ $RMAN RMAN RMAN RMAN_ __ _DEMO DEMO DEMO DEMO_ __ _PIPE PIPE PIPE PIPE_ __ _OUT OUT OUT OUT' '' ') )) ); ;; ;
rem create the procedure rem create the procedure rem create the procedure rem create the procedure
pause pause pause pause
create or replace procedure rman create or replace procedure rman create or replace procedure rman create or replace procedure rman_ __ _cmd cmd cmd cmd
( (( (cmd varchar cmd varchar cmd varchar cmd varchar2 22 2) )) )
as as as as
in in in in_ __ _pipe pipe pipe pipe_ __ _name varchar name varchar name varchar name varchar2 22 2( (( (2000 2000 2000 2000) )) ); ;; ;
out out out out_ __ _pipe pipe pipe pipe_ __ _name varchar name varchar name varchar name varchar2 22 2( (( (2000 2000 2000 2000) )) ); ;; ;
v v v v_ __ _info varchar info varchar info varchar info varchar2 22 2( (( (255 255 255 255) )) ); ;; ;
v v v v_ __ _status integer status integer status integer status integer( (( (2 22 2) )) ); ;; ;
begin begin begin begin
-- -- -- --
in in in in_ __ _pipe pipe pipe pipe_ __ _name name name name := := := := ' '' 'ORA ORA ORA ORA$ $$ $RMAN RMAN RMAN RMAN_ __ _DEMO DEMO DEMO DEMO_ __ _PIPE PIPE PIPE PIPE_ __ _IN IN IN IN'; '; '; ';
out out out out_ __ _pipe pipe pipe pipe_ __ _name name name name := := := := ' '' 'ORA ORA ORA ORA$ $$ $RMAN RMAN RMAN RMAN_ __ _DEMO DEMO DEMO DEMO_ __ _PIPE PIPE PIPE PIPE_ __ _OUT OUT OUT OUT'; '; '; ';
dbms dbms dbms dbms_ __ _output output output output. .. .put put put put_ __ _line line line line( (( (' '' 'Begin RMAN command Begin RMAN command Begin RMAN command Begin RMAN command : : : : ' || ' || ' || ' || cmd cmd cmd cmd) )) ); ;; ;
/* /* /* /*
* * * * Cleanup pipe Cleanup pipe Cleanup pipe Cleanup pipe : : : : read old messages before executing new command read old messages before executing new command read old messages before executing new command read old messages before executing new command
*/ */ */ */
v v v v_ __ _status status status status := := := := dbms dbms dbms dbms_ __ _pipe pipe pipe pipe. .. .receive receive receive receive_ __ _message message message message( (( (out out out out_ __ _pipe pipe pipe pipe_ __ _name name name name, , , , 0 00 0) )) ); ;; ;
while while while while ( (( (v vv v_ __ _status status status status = = = = 0 00 0) ) ) ) loop loop loop loop
dbms dbms dbms dbms_ __ _pipe pipe pipe pipe. .. .unpack unpack unpack unpack_ __ _message message message message( (( (v vv v_ __ _info info info info) )) ); ;; ;
dbms dbms dbms dbms_ __ _output output output output. .. .put put put put_ __ _line line line line( (( (' '' 'Old Old Old Old : : : : ' || ' || ' || ' || v vv v_ __ _info info info info) )) ); ;; ;
if if if if ( (( (v vv v_ __ _info like info like info like info like ' '' '% %% %RMAN RMAN RMAN RMAN- -- -00572 00572 00572 00572% %% %' '' ') ) ) ) or or or or
( ( ( (v vv v_ __ _info like info like info like info like ' '' 'Recovery Manager complete Recovery Manager complete Recovery Manager complete Recovery Manager complete% %% %' '' ') ) ) ) then then then then
v v v v_ __ _status status status status := := := := 99 99 99 99; ;; ;
else else else else
v v v v_ __ _status status status status := := := := dbms dbms dbms dbms_ __ _pipe pipe pipe pipe. .. .receive receive receive receive_ __ _message message message message( (( (out out out out_ __ _pipe pipe pipe pipe_ __ _name name name name, , , , 10 10 10 10) )) ); ;; ;
end if end if end if end if; ;; ;
end loop end loop end loop end loop; ;; ;
/* /* /* /*
* * * * End CleanUp End CleanUp End CleanUp End CleanUp
*/ */ */ */
/* /* /* /*
* * * * Send message Send message Send message Send message
*/ */ */ */
dbms dbms dbms dbms_ __ _pipe pipe pipe pipe. .. .pack pack pack pack_ __ _message message message message( (( (cmd cmd cmd cmd) )) ); ;; ;
v v v v_ __ _status status status status := := := := dbms dbms dbms dbms_ __ _pipe pipe pipe pipe. .. .send send send send_ __ _message message message message( (( (in in in in_ __ _pipe pipe pipe pipe_ __ _name name name name) )) ); ;; ;
if v if v if v if v_ __ _status status status status <> <> <> <> 0 0 0 0 then then then then
dbms dbms dbms dbms_ __ _output output output output. .. .put put put put_ __ _line line line line( (( (' '' 'Error in writing to pipe Error in writing to pipe Error in writing to pipe Error in writing to pipe : : : : ' || ' || ' || ' || in in in in_ __ _pipe pipe pipe pipe_ __ _name name name name) )) ); ;; ;
Page 1 Page 1 Page 1 Page 1
rman_pipes.sql rman_pipes.sql rman_pipes.sql rman_pipes.sql
return return return return; ;; ;
end if end if end if end if; ;; ;
/* /* /* /*
* * * * Wait for the results Wait for the results Wait for the results Wait for the results
*/ */ */ */
v v v v_ __ _status status status status := := := := 0 00 0; ;; ;
/* /* /* /*
* * * * Status Status Status Status 0 0 0 0 : : : : Sucees Sucees Sucees Sucees
* * * * Status Status Status Status 1 1 1 1 : : : : Time Out Time Out Time Out Time Out
*/ */ */ */
while while while while ( (( (v vv v_ __ _status status status status = = = = 0 00 0) ) ) ) or or or or ( (( (v vv v_ __ _status status status status = = = = 1 11 1) ) ) ) loop loop loop loop
v v v v_ __ _status status status status := := := := dbms dbms dbms dbms_ __ _pipe pipe pipe pipe. .. .receive receive receive receive_ __ _message message message message( (( (out out out out_ __ _pipe pipe pipe pipe_ __ _name name name name, , , , 30 30 30 30) )) ); ;; ;
if v if v if v if v_ __ _status status status status = = = = 0 0 0 0 then then then then
dbms dbms dbms dbms_ __ _pipe pipe pipe pipe. .. .unpack unpack unpack unpack_ __ _message message message message( (( (v vv v_ __ _info info info info) )) ); ;; ;
/* /* /* /*
* * * * Check for termination record Check for termination record Check for termination record Check for termination record( (( (s ss s) )) )
*/ */ */ */
if if if if ( (( (v vv v_ __ _info like info like info like info like ' '' '% %% %RMAN RMAN RMAN RMAN- -- -00572 00572 00572 00572% %% %' '' ') ) ) ) or or or or
( ( ( (v vv v_ __ _info like info like info like info like ' '' 'Recovery Manager complete Recovery Manager complete Recovery Manager complete Recovery Manager complete% %% %' '' ') ) ) ) then then then then
dbms dbms dbms dbms_ __ _output output output output. .. .put put put put_ __ _line line line line( (( (v vv v_ __ _info info info info) )) ); ;; ;
dbms dbms dbms dbms_ __ _output output output output. .. .put put put put_ __ _line line line line( (( (' '' 'End output RMAN command End output RMAN command End output RMAN command End output RMAN command : : : : ' || ' || ' || ' || cmd cmd cmd cmd) )) ); ;; ;
exit exit exit exit; ;; ;
else else else else
/* /* /* /*
* * * * Check for Errors Check for Errors Check for Errors Check for Errors
* * * * RMAN RMAN RMAN RMAN- -- -00571 00571 00571 00571 is an informative line and not an error is an informative line and not an error is an informative line and not an error is an informative line and not an error. .. .
*/ */ */ */
if v if v if v if v_ __ _info like info like info like info like ' '' '% %% %RMAN RMAN RMAN RMAN-% -% -% -%' ' ' ' then then then then
if v if v if v if v_ __ _info not like info not like info not like info not like ' '' '% %% %00571 00571 00571 00571% %% %' ' ' ' then then then then
dbms dbms dbms dbms_ __ _output output output output. .. .put put put put_ __ _line line line line( (( (' '' '*** *** *** *** ERROR ERROR ERROR ERROR *** : *** : *** : *** : ' || ' || ' || ' || v vv v_ __ _info info info info) )) ); ;; ;
while while while while ( (( (dbms dbms dbms dbms_ __ _pipe pipe pipe pipe. .. .receive receive receive receive_ __ _message message message message( (( (out out out out_ __ _pipe pipe pipe pipe_ __ _name name name name, , , , 5 55 5) = ) = ) = ) = 0 00 0) ) ) ) loop loop loop loop
dbms dbms dbms dbms_ __ _pipe pipe pipe pipe. .. .unpack unpack unpack unpack_ __ _message message message message( (( (v vv v_ __ _info info info info) )) ); ;; ;
dbms dbms dbms dbms_ __ _output output output output. .. .put put put put_ __ _line line line line( (( (v vv v_ __ _info info info info) )) ); ;; ;
end loop end loop end loop end loop; ;; ;
exit exit exit exit; ;; ;
end if end if end if end if; ;; ;
else else else else
/* /* /* /*
* * * * Print output Print output Print output Print output
*/ */ */ */
dbms dbms dbms dbms_ __ _output output output output. .. .put put put put_ __ _line line line line( (( (v vv v_ __ _info info info info) )) ); ;; ;
end if end if end if end if; ;; ;
end if end if end if end if; ;; ;
else else else else
if v if v if v if v_ __ _status status status status <> <> <> <> 1 1 1 1 then then then then
dbms dbms dbms dbms_ __ _output output output output. .. .put put put put_ __ _line line line line( (( (' '' 'Error on reading pipe Error on reading pipe Error on reading pipe Error on reading pipe : : : : ' || ' || ' || ' || out out out out_ __ _pipe pipe pipe pipe_ __ _name name name name) )) ); ;; ;
exit exit exit exit; ;; ;
end if end if end if end if; ;; ;
end if end if end if end if; ;; ;
end loop end loop end loop end loop; ;; ;
-- -- -- --
end rman end rman end rman end rman_ __ _cmd cmd cmd cmd; ;; ;
/ // /
rem check for errors rem check for errors rem check for errors rem check for errors
pause pause pause pause
show errors show errors show errors show errors
rem see the pipes rem see the pipes rem see the pipes rem see the pipes
pause pause pause pause
col name for a col name for a col name for a col name for a24 24 24 24
select select select select * * * *
from v from v from v from v$ $$ $db db db db_ __ _pipes pipes pipes pipes; ;; ;
rem now try some RMAN commands via the procedure rem now try some RMAN commands via the procedure rem now try some RMAN commands via the procedure rem now try some RMAN commands via the procedure
pause pause pause pause
exec rman exec rman exec rman exec rman_ __ _cmd cmd cmd cmd( (( (' '' 'show all show all show all show all;' ;' ;' ;') )) ); ;; ;
pause pause pause pause
exec rman exec rman exec rman exec rman_ __ _cmd cmd cmd cmd( (( (' '' 'CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 3 3 3 DAYS DAYS DAYS DAYS;' ;' ;' ;') )) ); ;; ;
pause pause pause pause
exec rman exec rman exec rman exec rman_ __ _cmd cmd cmd cmd( (( (' '' 'BACKUP SPFILE BACKUP SPFILE BACKUP SPFILE BACKUP SPFILE;' ;' ;' ;') )) ); ;; ;
pause pause pause pause
exec rman exec rman exec rman exec rman_ __ _cmd cmd cmd cmd( (( (' '' 'LIST BACKUP of tablespace SYSTEM LIST BACKUP of tablespace SYSTEM LIST BACKUP of tablespace SYSTEM LIST BACKUP of tablespace SYSTEM;' ;' ;' ;') )) ); ;; ;
pause pause pause pause
exec rman exec rman exec rman exec rman_ __ _cmd cmd cmd cmd( (( (' '' 'LIST BACKUP SUMMARY LIST BACKUP SUMMARY LIST BACKUP SUMMARY LIST BACKUP SUMMARY;' ;' ;' ;') )) ); ;; ;
pause pause pause pause
exec rman exec rman exec rman exec rman_ __ _cmd cmd cmd cmd( (( (' '' 'REPORT NEED BACKUP REPORT NEED BACKUP REPORT NEED BACKUP REPORT NEED BACKUP;' ;' ;' ;') )) ); ;; ;
pause pause pause pause
Page 2 Page 2 Page 2 Page 2
rman_pipes.sql rman_pipes.sql rman_pipes.sql rman_pipes.sql
exec rman exec rman exec rman exec rman_ __ _cmd cmd cmd cmd( (( (' '' 'CONFIGURE RETENTION POLICY CLEAR CONFIGURE RETENTION POLICY CLEAR CONFIGURE RETENTION POLICY CLEAR CONFIGURE RETENTION POLICY CLEAR;' ;' ;' ;') )) ); ;; ;
pause pause pause pause
exec rman exec rman exec rman exec rman_ __ _cmd cmd cmd cmd( (( (' '' 'EXIT EXIT EXIT EXIT;' ;' ;' ;') )) ); ;; ;
Page 3 Page 3 Page 3 Page 3

S-ar putea să vă placă și