RMAN>alter database open resetlogs;
注意:使用后所有的备份集都无效了,确保安全需要重新对数据库进行全备(ORACLE10G之后,resetlog之前的备份还是可以用的)
关键表空间恢复(system / undotbs1 / sysaux):
SQL>shutdown abort
SQL>startup mount
RMAN>restore tablespace 名字;
RMAN>recover tablespace 名字;
RMAN>sql 'alter database open';
非关键表空间恢复(example / users ):
select * from v$datafile_header; 表空间与数据文件对应关系
SQL>alter database datafile 数字 offline;
RMAN>restore tablespace 名字;
RMAN>recover tablespace 名字;
SQL>alter database datafile 数字 online;
10. 删除备份
所有backup备份集:delete backup;
所有copy备份机:delete copy;
特定备份机:delete backupset 19;
删除根据保存规则可删除文件:delete obsolete;
删除过期的备份:
delete expired backupset;
delete expired copy;
11. RUN块
例如:
RMAN> RUN {
ALLOCATE CHANNEL c1 DEVICE TYPE sbt;
ALLOCATE CHANNEL c2 DEVICE TYPE sbt;
ALLOCATE CHANNEL c3 DEVICE TYPE sbt;
BACKUP
INCREMENTAL LEVEL = 0
FORMAT '/disk1/backup/df_%d_%s_%p.bak'
(DATAFILE 1,4,5 CHANNEL c1)
(DATAFILE 2,3,9 CHANNEL c2)
(DATAFILE 6,7,8 CHANNEL c3);
ALTER SYSTEM ARCHIVE LOG CURRENT;
}
12. 外部变量:
语言:set nls_lang=american
日期:set nls_date_format=yyyy-mm-dd....
13. RMAN sciprt
前提条件:有catalog
写法:(global表示可以由多个数据库调用)
create global script 名
comment "备注说明"
{脚本内容}
例如:
create global script abc
comment "test"
{backup current controlfile;}
调用:run {execute script 名}
例如:run {execute script abc;}
查看:print script 名
改写:
replace global script 名
comment "备注说明"
{脚本内容}
删除:delete script 名;
14. 永久保留备份
条件是备份不能保留在flash recovery area中;
a. 创建备份:
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE disk format '/tmp/autobackup/%U';
BACKUP tablespace example;
}
b. 查找该备份:
list backupset of tablespace example;
c. 修改属性为永久
change backupset 编号 keep forever nologs;
15. 建立多个固定大小的备份
例如:example 测试备份大小是大于50M
run
{
allocate channel c1 device type disk maxpiecesize 10M format '/tmp/autobackup/%U';
backup tablespace example;
}
/tmp/autobackup目录下有六个文件
16.运行脚本:backup recovery area
备份内容:
a. control file autobackup;
b. incremental backup sets
17.block change tracking
a. 针对整个数据库;
b. 默认存放路径:background_dump_dest
--------------------------------------推荐阅读 --------------------------------------
Oracle基础教程之通过RMAN复制数据库
--------------------------------------分割线 --------------------------------------