记录RMAN的输出结果很重要,有下面几种收集RMAN输出结果的方法:1.重定向 2.tee或script命令 3.spool 4.用sql查数据字典
将输出重定向到文件
这个是老生常谈了,1代表正常输出,2代表错误输出,统统定向到同一个文件。
rmanback.bsh 1>/home/oracle/bin/log/rmanback.log 2>&1
Linux/UNIX自带命令输出
tee 命令
$ rman | tee /tmp/rman.log
#加入参数-a是追加的意思
$ rman | tee -a /tmp/rman.log
script 命令
这个命令不怎么常用
#开始记录,指定记录文件,如果不指定默认记录到当前文件夹的typescript文件
-bash-3.00# script /tmp/scritpt.log
Script command is started. The file is /tmp/scritpt.log.
#注意这儿变化,bash变成了sh
sh-3.00# id
uid=0(root) gid=0(system) groups=2(bin),3(sys),7(security),8(cron),10(audit),11(lp)
sh-3.00# pwd
/
#用exit结束退出,sh重新变成了bash
sh-3.00# exit
exit
Script command is complete. The file is /tmp/scritpt.log.
#看下记录的内容
-bash-3.00# cat /tmp/scritpt.log
Script command is started on Wed Dec 16 19:35:26 BEIST 2015.
sh-3.00# id
uid=0(root) gid=0(system) groups=2(bin),3(sys),7(security),8(cron),10(audit),11(lp)
sh-3.00# pwd
/
sh-3.00# exit
exit
Script command is complete on Wed Dec 16 19:35:31 BEIST 2015.
数据库的spool log 命令
--开始记录
RMAN> spool log to '/tmp/rman.log'
RMAN> set echo on
--这时候是没有交互的
RMAN> show all;
RMAN> show all;
RMAN> set echo on;
RMAN> show all;
--结束记录
RMAN> spool log off;
Spooling for log turned off
Recovery Manager10.2.0.4.0
--结束后就有记录了
RMAN> show all;
show all;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/almtest/oracle/oracle/product/10.2.0/db_1/dbs/snapcf_almtest.f'; # default
RMAN> exit
exit
Recovery Manager complete.
--加入append 代表追加
bash-3.00$ rman target / log /tmp/rman.log append
RMAN> set echo on
RMAN> show all;
RMAN> exit
通过数据字典查信息
可以通过动态视图来查,最多包含32768行信息,库重启后会被清空
select sid, recid, output
from v$rman_output
order by recid;