自己整理了点Oracle RMAN管理命令的文档

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:42

首先执行如下脚本进行数据库的0级备份:
[td=553] RMAN> run{ 2> allocate channel c1 device type disk; 3> backup as compressed backupset incremental level=0 database 4> format '/home/oracle/backup/l0_prod_%U' 5> include current controlfile 6> plus 7> archivelog format '/home/oracle/backup/l0_arc_prod_%U' 8> delete all input; 9> release channel c1; 10> }

稍后又执行了如下脚本:
[td=553] RMAN> backup as copy incremental level=0 datafile 1 tag 'systemcopy0';
Starting backup at 07-FEB-14 using channel ORA_DISK_1 using channel ORA_DISK_2 channel ORA_DISK_1: starting datafile copy input datafile fno=00001 name=/u01/app/oracle/oradata/PROD/disk1/system001.dbf output filename=/home/oracle/backup/PROD_data_D-PROD_I-248672105_TS-SYSTEM_FNO-1_1dp01pgj tag=SYSTEMCOPY0 recid=1 stamp=838919713 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15 Finished backup at 07-FEB-14
Starting Control File and SPFILE Autobackup at 07-FEB-14 piece handle=/home/oracle/backup/control/controlfile_c-248672105-20140207-02 comment=NONE Finished Control File and SPFILE Autobackup at 07-FEB-14
然后查询copy结果,可以看到/home/oracle/backup/PROD_data_D-PROD_I-248672105_TS-SYSTEM_FNO-1_1dp01pgj的文件大小与datafile 1大小相同
[td=553] [oracle@odd-oelr4u8 disk1]$ ll 总用量 2098016 -rw-r----- 1 oracle oinstall 9781248 2月 7 17:17 control01.ctl -rw-r----- 1 oracle oinstall 419438592 2月 7 16:48 example1.dbf -rw-r----- 1 oracle oinstall 41951232 2月 7 16:48 indx1.dbf -rw-r----- 1 oracle oinstall 10493952 2月 7 16:48 nan2.dbf -rw-r----- 1 oracle oinstall 50339840 2月 7 16:48 oltp1.dbf -rw-r----- 1 oracle oinstall 52445184 2月 7 16:48 part1_01.dbf -rw-r----- 1 oracle oinstall 52445184 2月 7 16:48 part2_01.dbf -rw-r----- 1 oracle oinstall 52445184 2月 7 16:48 part3_01.dbf -rw-r----- 1 oracle oinstall 52445184 2月 7 16:48 part4_01.dbf -rw-r----- 1 oracle oinstall 104858112 2月 7 16:43 redo101.log -rw-r----- 1 oracle oinstall 104858112 2月 7 16:44 redo201.log -rw-r----- 1 oracle oinstall 104858112 2月 7 17:15 redo301.log -rw-r----- 1 oracle oinstall 340795392 2月 7 17:13 sysaux01.dbf -rw-r----- 1 oracle oinstall 340795392 2月 7 17:14 system001.dbf -rw-r----- 1 oracle oinstall 20979712 2月 5 03:08 temp1.dbf -rw-r----- 1 oracle oinstall 20979712 2月 5 22:00 temp2.dbf -rw-r----- 1 oracle oinstall 20979712 2月 3 06:56 temp.dbf -rw-r----- 1 oracle oinstall 20979712 2月 7 16:48 test1.dbf -rw-r----- 1 oracle oinstall 10493952 2月 7 16:48 tools1.dbf -rw-r----- 1 oracle oinstall 20979712 2月 7 16:48 tsport01.dbf -rw-r----- 1 oracle oinstall 20979712 2月 7 16:48 tsport_dp01.dbf -rw-r----- 1 oracle oinstall 209723392 2月 7 17:13 undotbs01.dbf -rw-r----- 1 oracle oinstall 121643008 2月 7 16:48 users1.dbf [oracle@odd-oelr4u8 disk1]$ df -h Filesystem 容量 已用 可用 已用% 挂载点 /dev/sda2 18G 15G 2.5G 86% / /dev/sda1 190M 12M 169M 7% /boot none 506M 0 506M 0% /dev/shm [oracle@odd-oelr4u8 disk1]$ cd - /home/oracle/backup/control [oracle@odd-oelr4u8 control]$ cd .. [oracle@odd-oelr4u8 backup]$ ll 总用量 437652 drwxr-xr-x 2 oracle oinstall 4096 2月 7 17:15 control -rw-r----- 1 oracle oinstall 36876288 2月 7 16:43 l0_arc_prod_18p01nl0_1_1 -rw-r----- 1 oracle oinstall 10240 2月 7 16:44 l0_arc_prod_1bp01no5_1_1 -rw-r----- 1 oracle oinstall 68894720 2月 7 16:44 l0_prod_19p01nlh_1_1 -rw-r----- 1 oracle oinstall 1114112 2月 7 16:44 l0_prod_1ap01nns_1_1 -rw-r----- 1 oracle oinstall 340795392 2月 7 17:15 PROD_data_D-PROD_I-248672105_TS-SYSTEM_FNO-1_1dp01pgj

一、 ListRMAN的list命令是一种在数据库控制文件或恢复目录中查询备份的历史信息的方法。在RMAN的命令行界面输入list后回车出现如下提示信息:
1 列出对应物1.1 命令:list incarnation
[td=487] RMAN> list incarnation;
List of Database Incarnations DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time ------- ------- -------- ---------------- --- ---------- ---------- 1 16 PROD 248672105 PARENT 648905 25-JAN-14 1 2 PROD 248672105 CURRENT 765009 02-FEB-14
1.2 作用:为用户提供目标数据库的每个数据库对应物列表,可以将数据库恢复到执行最后一条resetlogs命令前的某个时间点。2 列出备份首先查看一下list命令后面可以跟哪些参数,然后再选取一些常用的列出备份命令的使用场景。
[td=553] RMAN> list 2> 3>
RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-00558: error encountered while parsing input commands RMAN-01009: syntax error: found "end-of-file": expecting one of: "all, archivelog, backup, backuppiece, backupset, backed, completed, copy, controlfilecopy, datafilecopy, device, expired, global, incarnation, like, proxy, recoverable, script, tag" RMAN-01007: at line 3 column 1 file: standard input
[td=553]RMAN> list backup 2> 3>
RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-00558: error encountered while parsing input commands RMAN-01009: syntax error: found "end-of-file": expecting one of: "by, backed, completed, controlfile, device, like, of, recoverable, ;, summary, tag, verbose" RMAN-01007: at line 3 column 1 file: standard input
[td=553]其他参数的查询方法以此类推
下面是常用列出命令和参数的组合2.1 概述可用的备份:
[td=553] RMAN> list backup summary;

List of Backups =============== Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag ------- -- -- - ----------- --------------- ------- ------- ---------- --- 307 B A A DISK 07-FEB-14 1 1 YES TAG20140207T164312 308 B 0 A DISK 07-FEB-14 1 1 YES TAG20140207T164328 309 B 0 A DISK 07-FEB-14 1 1 YES TAG20140207T164328 346 B A A DISK 07-FEB-14 1 1 YES TAG20140207T164453 362 B F A DISK 07-FEB-14 1 1 NO TAG20140207T164455

2.2 按备份类型列出备份
[td=553] RMAN> list backup summary;

List of Backups =============== Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag ------- -- -- - ----------- --------------- ------- ------- ---------- --- 307 B A A DISK 07-FEB-14 1 1 YES TAG20140207T164312 308 B 0 A DISK 07-FEB-14 1 1 YES TAG20140207T164328 309 B 0 A DISK 07-FEB-14 1 1 YES TAG20140207T164328 346 B A A DISK 07-FEB-14 1 1 YES TAG20140207T164453 362 B F A DISK 07-FEB-14 1 1 NO TAG20140207T164455
RMAN> list backup by file;

List of Datafile Backups ========================
File Key TY LV S Ckp SCN Ckp Time #Pieces #Copies Compressed Tag ---- ------- - -- - ---------- --------- ------- ------- ---------- --- 1 308 B 0 A 953160 07-FEB-14 1 1 YES TAG20140207T164328 2 308 B 0 A 953160 07-FEB-14 1 1 YES TAG20140207T164328 3 308 B 0 A 953160 07-FEB-14 1 1 YES TAG20140207T164328 4 308 B 0 A 953160 07-FEB-14 1 1 YES TAG20140207T164328 5 308 B 0 A 953160 07-FEB-14 1 1 YES TAG20140207T164328 6 308 B 0 A 953160 07-FEB-14 1 1 YES TAG20140207T164328 7 308 B 0 A 953160 07-FEB-14 1 1 YES TAG20140207T164328 8 308 B 0 A 953160 07-FEB-14 1 1 YES TAG20140207T164328 9 308 B 0 A 953160 07-FEB-14 1 1 YES TAG20140207T164328 10 308 B 0 A 953160 07-FEB-14 1 1 YES TAG20140207T164328 11 308 B 0 A 953160 07-FEB-14 1 1 YES TAG20140207T164328 12 308 B 0 A 953160 07-FEB-14 1 1 YES TAG20140207T164328 13 309 B 0 A 953191 07-FEB-14 1 1 YES TAG20140207T164328 14 309 B 0 A 953191 07-FEB-14 1 1 YES TAG20140207T164328 15 309 B 0 A 953191 07-FEB-14 1 1 YES TAG20140207T164328 16 309 B 0 A 953191 07-FEB-14 1 1 YES TAG20140207T164328 17 308 B 0 A 953160 07-FEB-14 1 1 YES TAG20140207T164328
List of Archived Log Backups ============================
Thrd Seq Low SCN Low Time BS Key S #Pieces #Copies Compressed Tag ---- ------- ---------- --------- ------- - ------- ------- ---------- --- 1 7 770537 03-FEB-14 307 A 1 1 YES TAG20140207T164312 1 8 850084 06-FEB-14 307 A 1 1 YES TAG20140207T164312 1 9 872793 06-FEB-14 307 A 1 1 YES TAG20140207T164312 1 10 893253 06-FEB-14 307 A 1 1 YES TAG20140207T164312 1 11 915720 06-FEB-14 307 A 1 1 YES TAG20140207T164312 1 12 937645 06-FEB-14 307 A 1 1 YES TAG20140207T164312 1 13 953098 07-FEB-14 307 A 1 1 YES TAG20140207T164312 1 14 953144 07-FEB-14 346 A 1 1 YES TAG20140207T164453
List of Control File Backups ============================
CF Ckp SCN Ckp Time BS Key S #Pieces #Copies Compressed Tag ---------- --------- ------- - ------- ------- ---------- --- 953214 07-FEB-14 362 A 1 1 NO TAG20140207T164455 953190 07-FEB-14 309 A 1 1 YES TAG20140207T164328 List of SPFILE Backups ======================
Modification Time BS Key S #Pieces #Copies Compressed Tag ----------------- ------- - ------- ------- ---------- --- 07-FEB-14 362 A 1 1 NO TAG20140207T164455

2.3 其他备份信息
[td=553] RMAN> list backup;

List of Backup Sets ===================
BS Key Size Device Type Elapsed Time Completion Time ------- ---------- ----------- ------------ --------------- 307 35.17M DISK 00:00:08 07-FEB-14 BP Key: 310 Status: AVAILABLE Compressed: YES Tag: TAG20140207T164312 Piece Name: /home/oracle/backup/l0_arc_prod_18p01nl0_1_1
List of Archived Logs in backup set 307 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- --------- ---------- --------- 1 7 770537 03-FEB-14 850084 06-FEB-14 1 8 850084 06-FEB-14 872793 06-FEB-14 1 9 872793 06-FEB-14 893253 06-FEB-14 1 10 893253 06-FEB-14 915720 06-FEB-14 1 11 915720 06-FEB-14 937645 06-FEB-14 1 12 937645 06-FEB-14 953098 07-FEB-14 1 13 953098 07-FEB-14 953144 07-FEB-14
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 308 Incr 0 65.70M DISK 00:01:14 07-FEB-14 BP Key: 311 Status: AVAILABLE Compressed: YES Tag: TAG20140207T164328 Piece Name: /home/oracle/backup/l0_prod_19p01nlh_1_1 List of Datafiles in backup set 308 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 1 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/system001.dbf 2 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/undotbs01.dbf 3 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/sysaux01.dbf 4 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/example1.dbf 5 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/indx1.dbf 6 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/tools1.dbf 7 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/users1.dbf 8 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/oltp1.dbf 9 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk3/tbs_tommie01.dbf 10 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/nan2.dbf 11 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/tsport01.dbf 12 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/tsport_dp01.dbf 17 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/test1.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 309 Incr 0 1.05M DISK 00:00:05 07-FEB-14 BP Key: 312 Status: AVAILABLE Compressed: YES Tag: TAG20140207T164328 Piece Name: /home/oracle/backup/l0_prod_1ap01nns_1_1 Control File Included: Ckp SCN: 953190 Ckp time: 07-FEB-14 List of Datafiles in backup set 309 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 13 0 Incr 953191 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/part1_01.dbf 14 0 Incr 953191 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/part2_01.dbf 15 0 Incr 953191 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/part3_01.dbf 16 0 Incr 953191 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/part4_01.dbf
BS Key Size Device Type Elapsed Time Completion Time ------- ---------- ----------- ------------ --------------- 346 9.50K DISK 00:00:01 07-FEB-14 BP Key: 352 Status: AVAILABLE Compressed: YES Tag: TAG20140207T164453 Piece Name: /home/oracle/backup/l0_arc_prod_1bp01no5_1_1
List of Archived Logs in backup set 346 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- --------- ---------- --------- 1 14 953144 07-FEB-14 953197 07-FEB-14
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 362 Full 9.39M DISK 00:00:01 07-FEB-14 BP Key: 364 Status: AVAILABLE Compressed: NO Tag: TAG20140207T164455 Piece Name: /home/oracle/backup/control/controlfile_c-248672105-20140207-01 Control File Included: Ckp SCN: 953214 Ckp time: 07-FEB-14 SPFILE Included: Modification time: 07-FEB-14

2.4 列出适合恢复的备份
[td=553] RMAN> list recoverable backup of database;

List of Backup Sets ===================
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 308 Incr 0 65.70M DISK 00:01:14 07-FEB-14 BP Key: 311 Status: AVAILABLE Compressed: YES Tag: TAG20140207T164328 Piece Name: /home/oracle/backup/l0_prod_19p01nlh_1_1 List of Datafiles in backup set 308 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 1 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/system001.dbf 2 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/undotbs01.dbf 3 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/sysaux01.dbf 4 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/example1.dbf 5 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/indx1.dbf 6 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/tools1.dbf 7 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/users1.dbf 8 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/oltp1.dbf 9 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk3/tbs_tommie01.dbf 10 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/nan2.dbf 11 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/tsport01.dbf 12 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/tsport_dp01.dbf 17 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/test1.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 309 Incr 0 1.05M DISK 00:00:05 07-FEB-14 BP Key: 312 Status: AVAILABLE Compressed: YES Tag: TAG20140207T164328 Piece Name: /home/oracle/backup/l0_prod_1ap01nns_1_1 List of Datafiles in backup set 309 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 13 0 Incr 953191 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/part1_01.dbf 14 0 Incr 953191 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/part2_01.dbf 15 0 Incr 953191 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/part3_01.dbf 16 0 Incr 953191 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/part4_01.dbf

2.5 列出到期的备份信息 可获得到期的归档日志备份和控制文件/服务参数文件自动备份列表。
[td=553] RMAN> list expired backup;

RMAN> list expired backup of datafile 1;

RMAN> list expired backup of archivelog;
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: "all, from, high, like, logseq, low, scn, sequence, time, until" RMAN-01007: at line 1 column 34 file: standard input
list expired backup of archive log
RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-00558: error encountered while parsing input commands RMAN-01009: syntax error: found "identifier": expecting one of: "archivelog, controlfile, database, datafile, spfile, tablespace" RMAN-01008: the bad identifier was: archive RMAN-01007: at line 1 column 24 file: standard input
RMAN> list expired backup of archivelog all;

RMAN> list expired backup of archivelog 2> 3>
RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-00558: error encountered while parsing input commands RMAN-01009: syntax error: found "end-of-file": expecting one of: "all, from, high, like, logseq, low, scn, sequence, time, until" RMAN-01007: at line 3 column 1 file: standard input

2.6 按表空间名和数据文件号列出备份
[td=553] RMAN> list backup of tablespace nan2;

List of Backup Sets ===================
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 308 Incr 0 65.70M DISK 00:01:14 07-FEB-14 BP Key: 311 Status: AVAILABLE Compressed: YES Tag: TAG20140207T164328 Piece Name: /home/oracle/backup/l0_prod_19p01nlh_1_1 List of Datafiles in backup set 308 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 10 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/nan2.dbf
[td=553]RMAN> list backup of datafile 1;

List of Backup Sets ===================
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 308 Incr 0 65.70M DISK 00:01:14 07-FEB-14 BP Key: 311 Status: AVAILABLE Compressed: YES Tag: TAG20140207T164328 Piece Name: /home/oracle/backup/l0_prod_19p01nlh_1_1 List of Datafiles in backup set 308 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 1 0 Incr 953160 07-FEB-14 /u01/app/oracle/oradata/PROD/disk1/system001.dbf

2.7 列出控制文件和服务器参数文件备份
[td=553] RMAN> list backup of controlfile;

List of Backup Sets ===================
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 309 Incr 0 1.05M DISK 00:00:05 07-FEB-14 BP Key: 312 Status: AVAILABLE Compressed: YES Tag: TAG20140207T164328 Piece Name: /home/oracle/backup/l0_prod_1ap01nns_1_1 Control File Included: Ckp SCN: 953190 Ckp time: 07-FEB-14
BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 362 Full 9.39M DISK 00:00:01 07-FEB-14 BP Key: 364 Status: AVAILABLE Compressed: NO Tag: TAG20140207T164455 Piece Name: /home/oracle/backup/control/controlfile_c-248672105-20140207-01 Control File Included: Ckp SCN: 953214 Ckp time: 07-FEB-14

3 列出映像副本列出所有的映像副本使用list copy;
[td=553] RMAN> list copy; --下面这句话什么意思? specification does not match any archive log in the recovery catalog
List of Datafile Copies Key File S Completion Time Ckp SCN Ckp Time Name ------- ---- - --------------- ---------- --------------- ---- 402 1 A 07-FEB-14 954410 07-FEB-14 /home/oracle/backup/PROD_data_D-PROD_I-248672105_TS-SYSTEM_FNO-1_1dp01pgj

3.1 列出数据文件副本
[td=553] RMAN> list copy of database;

List of Datafile Copies Key File S Completion Time Ckp SCN Ckp Time Name ------- ---- - --------------- ---------- --------------- ---- 402 1 A 07-FEB-14 954410 07-FEB-14 /home/oracle/backup/PROD_data_D-PROD_I-248672105_TS-SYSTEM_FNO-1_1dp01pgj
[td=553]RMAN> list copy of tablespace system;

List of Datafile Copies Key File S Completion Time Ckp SCN Ckp Time Name ------- ---- - --------------- ---------- --------------- ---- 402 1 A 07-FEB-14 954410 07-FEB-14 /home/oracle/backup/PROD_data_D-PROD_I-248672105_TS-SYSTEM_FNO-1_1dp01pgj

3.2 列出归档的重做日志
[td=553] RMAN> backup as copy archivelog all;
Starting backup at 07-FEB-14 current log archived using channel ORA_DISK_1 using channel ORA_DISK_2 channel ORA_DISK_1: starting archive copy input archive log thread=1 sequence=15 recid=18 stamp=838920150 channel ORA_DISK_2: starting archive copy input archive log thread=1 sequence=17 recid=20 stamp=838920267 output filename=/home/oracle/backup/PROD_arch_D-PROD_id-248672105_S-15_T-1_A-838438693_1fp01q2c recid=21 stamp=838920269 channel ORA_DISK_1: archivelog copy complete, elapsed time: 00:00:02 output filename=/home/oracle/backup/PROD_arch_D-PROD_id-248672105_S-17_T-1_A-838438693_1gp01q2c recid=22 stamp=838920269 channel ORA_DISK_2: archivelog copy complete, elapsed time: 00:00:02 channel ORA_DISK_1: starting archive copy input archive log thread=1 sequence=16 recid=19 stamp=838920170 output filename=/home/oracle/backup/PROD_arch_D-PROD_id-248672105_S-16_T-1_A-838438693_1hp01q2e recid=23 stamp=838920270 channel ORA_DISK_1: archivelog copy complete, elapsed time: 00:00:01 Finished backup at 07-FEB-14
Starting Control File and SPFILE Autobackup at 07-FEB-14 piece handle=/home/oracle/backup/control/controlfile_c-248672105-20140207-03 comment=NONE Finished Control File and SPFILE Autobackup at 07-FEB-14
[td=553]RMAN> list copy of archivelog all;

List of Archived Log Copies Key Thrd Seq S Low Time Name ------- ---- ------- - --------- ---- 534 1 15 A 07-FEB-14 /home/oracle/backup/PROD_arch_D-PROD_id-248672105_S-15_T-1_A-838438693_1fp01q2c 498 1 15 A 07-FEB-14 /u01/app/oracle/oradata/PROD/arc_dest_1/1_15_838438693.dbf 536 1 16 A 07-FEB-14 /home/oracle/backup/PROD_arch_D-PROD_id-248672105_S-16_T-1_A-838438693_1hp01q2e 499 1 16 A 07-FEB-14 /u01/app/oracle/oradata/PROD/arc_dest_1/1_16_838438693.dbf 535 1 17 A 07-FEB-14 /home/oracle/backup/PROD_arch_D-PROD_id-248672105_S-17_T-1_A-838438693_1gp01q2c 500 1 17 A 07-FEB-14 /u01/app/oracle/oradata/PROD/arc_dest_1/1_17_838438693.dbf
[td=553]RMAN> list copy of archivelog from sequence 15 until sequence 16;

List of Archived Log Copies Key Thrd Seq S Low Time Name ------- ---- ------- - --------- ---- 534 1 15 A 07-FEB-14 /home/oracle/backup/PROD_arch_D-PROD_id-248672105_S-15_T-1_A-838438693_1fp01q2c 498 1 15 A 07-FEB-14 /u01/app/oracle/oradata/PROD/arc_dest_1/1_15_838438693.dbf 536 1 16 A 07-FEB-14 /home/oracle/backup/PROD_arch_D-PROD_id-248672105_S-16_T-1_A-838438693_1hp01q2e 499 1 16 A 07-FEB-14 /u01/app/oracle/oradata/PROD/arc_dest_1/1_16_838438693.dbf

3.3 列出控制文件副本
rman>list copy of controlfile;
[td=553] RMAN> copy current controlfile to '/home/oracle/backup/control/controlfile01';
Starting backup at 07-FEB-14 using channel ORA_DISK_1 using channel ORA_DISK_2 channel ORA_DISK_1: starting datafile copy copying current control file output filename=/home/oracle/backup/control/controlfile01 tag=TAG20140207T173732 recid=3 stamp=838921052 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 Finished backup at 07-FEB-14
Starting Control File and SPFILE Autobackup at 07-FEB-14 piece handle=/home/oracle/backup/control/controlfile_c-248672105-20140207-05 comment=NONE Finished Control File and SPFILE Autobackup at 07-FEB-14
[td=553]RMAN> list copy of controlfile;

List of Control File Copies Key S Completion Time Ckp SCN Ckp Time Name ------- - --------------- ---------- --------------- ---- 770 A 07-FEB-14 955173 07-FEB-14 /home/oracle/backup/control/controlfile01 647 A 07-FEB-14 955125 07-FEB-14 /home/oracle/backup/controlfile

二、 Crosscheck该命令用于核对磁盘和磁带上的备份文件,以确保RMAN资料库与备份文件保持同步。该命令只会检查RMAN资料库所记载的备份文件。当执行CROSSCHECK命令时,如果资料库记录不匹配于备份文件的物理状态,那么该命令会更新资料库记录的状态信息。当使用CROSSCHECK命令核对备份文件之后,备份文件的状态会包括AVAILABLE、UNAVAILABLE和EXPIRED三种,如果备份文件处于EXPIRED状态,则说明物理文件已经被手工删除或者损坏。注意,如果备份文件处于EXPIRED状态,应该使用DELETE命令删除该备份文件。AVAILABLE与UNAVAILABLE是可以手工进行设置切换的要是备份集处于UNAVAILABLE状态,当使用RMAN恢复时,RMAN不会考虑使用这个备份集。1 核对所有备份集
RMAN>CROSSCHECK BACKUP;2 核对所有数据文件的备份集
RMAN>CROSSCHECK BACKUP OF DATABASE;3 核对特定表空间的备份集
RMAN>CROSSCHECK BACKUP OF TABLESPACE SYSTEM;4 核对特定数据文件的备份集
RMAN>CROSSCHECK BACKUP OF DATAFILE 4;5 核对控制文件的备份集
RMAN>CROSSCHECK BACKUP OF CONTROLFILE;6 核对SPFILE的备份集
RMAN>CROSSCHECK BACKUP OF SPFILE;7 核对归档日志的备份集
RMAN>CROSSCHECK BACKUP OF ARCHIVELOG SEQUENCE3;8 核对所有映像副本
RMAN>CROSSCHECK COPY;9 核对所有数据文件的映像副本
RMAN>CROSSCHECK COPY OF DATABASE;10 核对特定表空间的映像副本
RMAN>CROSSCHECK COPY OF TABLESPACE USERS;11 核对特定数据文件的映像副本
RMAN>CROSSCHECK COPY OF DATAFILE 4;12 核对控制文件的映像副本
RMAN>CROSSCHECK COPY OFCONTROLFILE;13 核对归档日志的映像副本
RMAN>CROSSCHECK COPY OF ARCHIVELOGSEQUENCE 4;三、 Delete该命令用于删除RMAN备份记录及相应的物理文件。1 删除陈旧备份
RMAN>DELETE OBSOLETE;2 删除EXPIRED备份集
当使用OS命令删除了备份集对应的备份片文件后,如果执行CROSSCHECK命令核对备份集,那么会将该备份集标记为EXPIRED状态。NOPROMPT表示删除时不需要有任何提示信息。
RMAN>DELETE NOPROMPT EXPIRED BACKUP;3 删除EXPIRED副本
RMAN>DELETE NOPROMPT EXPIREDCOPY; 4 删除特定备份集
RMAN>DELETE NOPROMPT BACKUPSET 19;5 删除特定备份片
RMAN>DELETE NOPROMPT BACKUPPIECE'D:/BACKUP/DEMO_18.BAK';6 删除所有备份集
RMAN>DELETE NOPROMPT BACKUP;7 删除特定映像副本
RMAN>DELETE NOPROMPT DATAFILECOPY'D:/BACKUP/DEM0_19.BAK';8 删除所有映像副本
RMAN>DELETE NOPROMPT COPY;9 在备份后删除输入对象
当使用BACKUP命令备份归档日志或备份集时,在备份完成之后可以删除原有输入对象,示例如下:
RMAN>BACKUP ARCHIVELOG ALL DELETEINPUT;
RMAN>BACKUP BACKUPSET 22 FORMAT='D:/BACKUP/%u.BAK'DELETE INPUT;
四、 ReportRMAN的report命令用于判断数据库的当前可恢复状态和提供数据库备份的特定信息。
[td=553] RMAN> report 2> 3>
RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-00558: error encountered while parsing input commands RMAN-01009: syntax error: found "end-of-file": expecting one of: "device, need, obsolete, schema, unrecoverable" RMAN-01007: at line 3 column 1 file: standard input
1 报告最近没有被备份的数据文件
在执行备份之前,常常需要取得需要备份的数据文件信息,通过执行REPORT NEED BACKUP命令,可以列出需要备份的数据文件。当使用REPORT NEED BACKUP命令时,可以带有INCREMENTAL、DAYS、REDUNDANCY、RECOVERY WINDOW四个选项。1.1 报告特定天数未备份的数据文件查看最近3天没有备份过的表空间,当恢复数据文件时,在转储了所需的数据文件备份之后,会应用从备份点开始的所有归档日志。需要应用的归档日志越多,恢复时间越长,为了减少恢复时间,应该制定备份数据文件的时间周期如:
rman>report need backup days = 3; 1.2 报告需要转储的增量备份超出特定个数的数据文件
根据需要应用的增量备份数生成报告,当恢复数据文件时,需要转储数据文件备份,然后应用归档日志执行恢复。如果备份数据文件采用了增量备份和累积备份策略,那么在转储数据文件时依次转储 0、1、2..级别的增量备份,转储的数据文件备份越多,恢复时间越长,下面以报告恢复数据文件需要转储的增量备份个数超过3次的数据文件为例如:
rman>report need backup incremental = 3; 2 报告备份冗余或恢复窗口
恢复数据文件时,需要转储数据文件备份。当数据文件出现介质失败,并且数据文件备份也出现问题时,会导致数据文件无法恢复。在制定备份册落时,为了防止数据文件备份出现问题,应该为数据文件保留多个备份,但某些文件的备份次数过少时,需要增加备份数量
rman>report need backup redundancy = 2; 3 报告在恢复时间窗口内未备份的数据文件当恢复数据文件时,在转储了所需的数据文件备份之后,会应用从备份点开始的所有归档日志。需要应用的归档日志越多,恢复时间越长。通过使用恢复时间窗口,可以将恢复操作需要应用的归档日志控制在特定时间范围内。下面以报告超过恢复窗口6天的未备份数据文件为例,说明使用DAYS选项的方法:
RMAN>REPORT NEED BACKUP RECOVERY WINDOWOF 6 DAYSDAYS用于标识恢复数据文件需要应用几天前的归档日志。
4 报告数据文件的不可恢复操作 当使用NOLOGGING选项装载了数据库之后,因为数据变化没有被记录到归档日志中,所以会导致过去的数据文件备份不能恢复当前数据文件。为防止数据文件不能恢复,应该备份该数据文件,通过如下语句,可以查看数据库所有不可恢复的数据文件
rman>report unrecoveable; 5 报告数据库模式
模式指的是数据库的物理结构。模式包括数据文件名、数据文件号、为这些数据文件指派的表空间、数据文件大小、以及数据文件是否含有回滚段。

[td=553] RMAN> report schema;
Report of database schema
List of Permanent Datafiles =========================== File Size(MB) Tablespace RB segs Datafile Name ---- -------- -------------------- ------- ------------------------ 1 325 SYSTEM YES /u01/app/oracle/oradata/PROD/disk1/system001.dbf 2 200 UNDOTBS YES /u01/app/oracle/oradata/PROD/disk1/undotbs01.dbf 3 325 SYSAUX NO /u01/app/oracle/oradata/PROD/disk1/sysaux01.dbf 4 400 EXAMPLE NO /u01/app/oracle/oradata/PROD/disk1/example1.dbf 5 40 INDX NO /u01/app/oracle/oradata/PROD/disk1/indx1.dbf 6 10 TOOLS NO /u01/app/oracle/oradata/PROD/disk1/tools1.dbf 7 116 USERS NO /u01/app/oracle/oradata/PROD/disk1/users1.dbf 8 48 OLTP NO /u01/app/oracle/oradata/PROD/disk1/oltp1.dbf 9 10 TBS_TOMMIE NO /u01/app/oracle/oradata/PROD/disk3/tbs_tommie01.dbf 10 10 NAN2 NO /u01/app/oracle/oradata/PROD/disk1/nan2.dbf 11 20 TSPORT NO /u01/app/oracle/oradata/PROD/disk1/tsport01.dbf 12 20 TSPORT_DP NO /u01/app/oracle/oradata/PROD/disk1/tsport_dp01.dbf 13 50 PART1 NO /u01/app/oracle/oradata/PROD/disk1/part1_01.dbf 14 50 PART2 NO /u01/app/oracle/oradata/PROD/disk1/part2_01.dbf 15 50 PART3 NO /u01/app/oracle/oradata/PROD/disk1/part3_01.dbf 16 50 PART4 NO /u01/app/oracle/oradata/PROD/disk1/part4_01.dbf 17 20 TEST1 NO /u01/app/oracle/oradata/PROD/disk1/test1.dbf
List of Temporary Files ======================= File Size(MB) Tablespace Maxsize(MB) Tempfile Name ---- -------- -------------------- ----------- -------------------- 1 20 TEMP 1024 /u01/app/oracle/oradata/PROD/disk1/temp.dbf 2 20 TEMP1 1024 /u01/app/oracle/oradata/PROD/disk1/temp1.dbf 3 20 TEMP2 1024 /u01/app/oracle/oradata/PROD/disk1/temp2.dbf
6 报告丢弃的备份
如备份时使用了保存策略,备份有可能会被标记为丢弃状态(OBSOLETE)。此时执行report obsolete就可查看到丢弃的备份记录。当使用RMAN执行恢复操作时,RMAN会自动转储最近的备份文件,然后应用该备份文件之后的归档日志。如果在特定数据文件上进行了多次备份,那么可以删除早期备份,通过使用REPORT OBSOLETE命令,可以报告陈旧备份。下例报告备份次数超过2次的陈旧备份:
RMAN>REPORT OBSOLETEREDUNDANCY 2;
五、 CHANGE1 改变备份集状态
可用CHANGE BACKUPSET ..UNAVAILABLE/AVAILABLE来改变一个备份集的状态。

RMAN>CHANGE BACKUPSET 22 UNAVAILABLE2 改变映像副本状态
数据文件:CHANGE DATAFILECOPY ..AVAILABLE/UNAVAILABLE
控制文件:CHANGE CONTROLFILECOPY ..AVAILABLE/UNAVAILABLE
归档日志:CHANGE ARCHIVELOG ..AVAILABLE/UNAVAILABLE例如:
RMAN>CHANGE DATAFILECOPY'D:/BACKUP/DEMO_37.BAK' UNAVAILABLE;
3 建立长期备份
长期备份是指被长期保留的备份文件(黄金备份),使用长期备份的目的是为了可以将数据库恢复到过去的特定时间点。当设定了长期备份之后,RMAN会从设备冗余策略中免除该备份文件,也就是说,长期备份文件不会被标记为陈旧备份。
命令:CHANGE .. KEEP/NOKEEP(1)使备份集156永久保留
RMAN>CHANGE BACKUPSET 156KEEP FOREVER LOGS;
(2)使备份集198保留60天
RMAN>CHANGE BACKUPSET 198KEEP UNTIL TIME 'SYSDATE+60' LOGS;
(3)免除备份集156的保留期限
RMAN>CHANGE BACKUPSET 156NOKEEP;

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】