Sunday, February 8, 2009

Oracle:rman output to a file/V$rman_output/V$rman_status

When using rman utility , you may often need to store the rman activity log in a file. And normally we use various rman backup and recovery scripts on a scheduled time to run . so, we need to refer to log to find everything was ok at the scheduled time as i want.

Although , whenever you run rman commands , it will automatically log the detail output of rman activity in a data dictionary file named as V$rman_output.

sql> select * from v$rman_output;

but as it is a dynamic view , so the contents will be washed out on restart of the database.

so, a log file is safe to store the output of rman.let us check the following demonstration:

RMAN> spool log to 'c:\rman.log';

RMAN> backup database;
RMAN> spool off;
RMAN>

Whatever statements you have issued in between spool and spool off will have there output stored in the destination file you have mentioned.As you see there is no output of backup database command on the screen.
Let us check the log file now:

c:\>notepad 'c:\rman.log'

Spooling started in log file: c:\rman.log

Recovery Manager10.2.0.1.0

RMAN>
Starting backup at 08-FEB-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=143 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=D:\LION\DATA\SYSTEM.DBF
input datafile fno=00002 name=D:\LION\DATA\UNDOTBS1.DBF
input datafile fno=00003 name=D:\LION\DATA\SYSAUX.DBF
input datafile fno=00004 name=C:\DATA01.DBF
input datafile fno=00005 name=C:\INDEX01.DBF
channel ORA_DISK_1: starting piece 1 at 08-FEB-09
channel ORA_DISK_1: finished piece 1 at 08-FEB-09
piece handle=E:\LION\BACKUPSET\2009_02_08\O1_MF_NNNDF_TAG20090208T150901_4RX89GOZ_.BKP tag=TAG20090208T150901 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
Finished backup at 08-FEB-09

Starting Control File and SPFILE Autobackup at 08-FEB-09
piece handle=E:\LION\AUTOBACKUP\2009_02_08\O1_MF_S_678294567_4RX8B8MK_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 08-FEB-09

RMAN>
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "off": expecting one of: "log, msglog, trace"
RMAN-01007: at line 1 column 7 file: standard input

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found ";": expecting one of: "allocate, alter, backup, beginline, blockrecover, catalog, change, connect, copy, convert, create, crosscheck, configure, duplicate, debug, delete, drop, exit, endinline, flashback, host, {, library, list, mount, open, print, quit, recover, register, release, replace, report, renormalize, reset, restore, resync, rman, run, rpctest, set, setlimit, sql, switch, spool, startup, shutdown, send, show, test, transport, upgrade, unregister, validate"
RMAN-01007: at line 1 column 10 file: standard input

so, hope it is ok
remember one thing , if you run the same procedure again, it will overwrite the same file.
to avoid this situation try the following:
RMAN> spool log to 'c:\rman.log' append;
RMAN> backup database;
RMAN> spool off;
RMAN>

If you are running a rman script or cmdfile then also in the file you can do the same.
or you have another option like:

rman> rman target /@lion cmdfile c:\rman.txt log c:\rman.log

to avoid overwriting ................

rman> rman target /@lion cmdfile c:\rman.txt log c:\rman.log append


Note: You can check the job status of rman by quering the V$rman_status view also....


Thanks,
Have a nice day............................

No comments: