ORACLE10G RMAN 命令

连接到目标数据库(不用恢复目录数据库)
rman target / nocatalog

显示rman配置
RMAN> show all;


====================
报告目标数据库的物理结构
RMAN> report schema;

报告陈旧备份
RMAN> report obsolete;

报告不可恢复的数据文件
RMAN> report unrecoverable;

列出备份信息
RMAN> list backup;

RMAN> list backup of database;

RMAN> list backup of tablespace table_name;

RMAN> list backup of controlfile;

RMAN> list backup of spfile;

RMAN> list backupset id;

========================
校验备份信息:
RMAN> crosscheck backup;

RMAN> crosscheck backup of database;

RMAN> crosscheck backup of tablespace system;

RMAN> crosscheck backup of controlfile;

RMAN> crosscheck backup of spfile;


========================
删除备份

Use the ALLOCATE CHANNEL FOR MAINTENANCE command to manually allocate a channel in preparation for issuing a CHANGE, DELETE, or CROSSCHECK command. You can use the RELEASE CHANNEL command to unallocate the channel.

ALLOCATE CHANNEL FOR MAINTENANCE device type (disk,sbt ...)


RMAN> delete obsolete; -- 删除陈旧备份

RMAN> delete expired backup;

RMAN> delete backupset id;

RMAN> delete backup; -- 删除所有备份


--------------------------------------------------------------------------------


--------------------------------------------------------------------------------

1 列出对应物  RMAN>list incarnation;

2 列出备份

2.1概述可用的备份    RMAN>list backup summary;
B 表示 backup
F 表示 FULL
A 表示 archive log
0 1 表示 incremental backup
S 说明备份状态 (A AVAILABLE   X EXPIRED )

2.2按备份类型列出备份  RMAN>list backup by file;
按照 数据文件备份,归档日志备份,控制文件备份,服务器参数文件备份 列出

2.3列出详细备份     RMAN>list backup;

2.4列出过期备份     RMAN>list expired backup;

2.5列出表空间和数据文件备份
list backup of tablespace 和list backup of datafile 输出和list backup 相似
如:list backup of tablespace user_tbs;
list backup of datafile 3;

2.6列出归档日志备份   RMAN>list archivelog all;      简要信息
RMAN>list backup of archivelog all; 详细信息

2.7列出控制文件和服务器参数文件
RMAN>list backup of controfile;
RMAN>list backup of spfile;

=====================================================
=====================================================
RMAN 的 report命令

1. 报告最近没有被备份的数据文件
RMAN>report need backup days=3;

2. 报告备份冗余或恢复窗口
RMAN>report need backup redundancy=2;
RMAN>report need backup recovery window of 2 days;

3. 报告数据文件的不可恢复操作
RMAN>report unrecoverable;

4. 报告数据库模式
RMAN>report schema;

5. 报告丢弃的备份
如果使用了保存策略,备份会标记为丢弃状态  RMAN>report obsolete; 删除丢弃状态备份RMAN>delete obsolete;

=====================================================
=====================================================
RMAN的crosscheck 命令

1 备份集有两种状态A(Available,RMAN认为该项存在于备份介质上)X(Expired,备份存在于控制文件或恢复目录中,但是并没有物理存在于备份介质上)

2 crosscheck 的目的是检查RMAN 的目录以及物理文件,如果物理文件不存在于介质上,将标记为Expired。如果物理文件存在,将维持Available。如果原先标记为Expired的备份集再次存在于备份介质上(如恢复了损坏的磁盘驱动器后),crosscheck将把状态重新从Expired标记回Available。

3 crosscheck 输出分两部分。第一部分列出确定存在于备份介质上的所有备份集片,第二部分列出不存在于备份介质上的备份集片,并将其标记为Expired。当设置备份保 存策略后,一个备份过期,crosscheck之后标记为丢弃的备份状态依旧为availabel,要删除丢弃备份delete obsolete。

4 示例:
crosscheck backup
crosscheck backup of datafile 1;
crosscheck backup of tablespace users;
crosscheck backup of controfile;
crosscheck backup of controlfile;
crosscheck backup tag='SAT_BACKUP';
crosscheck backup completed after 'sysdate - 2'
crosscheck backup completed between 'sysdate - 5' and 'sysdate -2 '
crosscheck backup device type sbt;
crosscheck archivelog all;
crosscheck archivelog like '%ARC00012.001'
crosscheck archivelog from sequence 12;
crosscheck archivelog until sequence 522;

=====================================================
=====================================================
RMAN 的validate 命令

1 validate 命令验证备份集片是否能够被还原

2 list backup summary; 得到了备份集得主键ID如40,然后validate backupset 40;
=====================================================
=====================================================
RMAN 的备份保存策略以及change ,delete命令

0.带delete参数的change 命令删除备份集,从备份介质,并且从控制文件和恢复目录中删除。
change backupset 117,118 delete;
change backuppiece 1304 delete;
change archivelog until logseq =544 delete;

1.两类策略:恢复窗口备份保存策略(recovery windows backup retension policy) 基于时间
备份冗余备份保存策略(backup redundancy backup retension policy) 基于备份的数量

两类策略互相排斥

2.即使使用了备份保存策略,备份到期并不删除,只是在RMAN目录中标记为丢弃,看到的状态依旧为available;
要查看标记为丢弃的备份 report obsolete,只有使用delete obsolete才真正物理删除。

3.configure retension policy to recovery window of 7 days;
configure retension policy to redundancy 3;
显示结果 show all;

4.查看到期丢弃的备份时,可能需要手工保存一些备份 ,可以使用change 命令带keep 参数,使用这个命令后,那些被修改的备份将被认为是个long-term backup,不在受保存策略影响也就是说delete obsolete 也不删除。

5.要使备份时候不受保存策略影响 ,使用带keep参数的backup 命令
backup database keep forever;
backup database keep 5 days;

6.change 命令功能

可以修改备份为永久保存并将以及该备份的相关的日志保存下来,保证总能将备份恢复到当前时间点
change backupset 31 keep forever logs;
可以设置备份丢弃的新日期 ,将备份在多保存7 天,7 天后将删除
change backupset 32 keep until time 'sysdata + 7' logs;

7.change 可以将备份集设置为unavailable
change backupset 33 unavailable;
标记为unavailable状态的备份集并不参与crosscheck;
=====================================================
=====================================================
恢复目录的记录删除

1. $ORACLE_HOME/rdbms/admin/prgrmanc.sql 脚本定期删除恢复目录中具有DELETED状态的记录

2. 要删除旧的对应物记录incarnation.必须从DBINC 表中删除这些对应物,使用RC_DATABASE_INCARNATION 视图来确定要删除的对应物。记录要删除的每个对应物的DBINC_KEY
随后启动SQL*Plus,执行delete from dbinc where dbinc_key=2;
=====================================================
=====================================================
手工同步恢复目录

resync catalog;

Oracle同步恢复目录的时候,首先创建快照控制文件,然后比较这个文件和恢复目录,完成后,Oracle 更新恢复目录,使恢复目录和控制文件同步
=====================================================
=====================================================
在RMAN 中存储脚本

1,连接到目标数据库和恢复目录
rman target / catalog rman/rman@rman9i

2,创建脚本
RMAN>create script. my_bk_script
2>{backup database plus archivelog;}
create script. my_bk_script

3,打印脚本
RMAN>print script. my_bk_script;
printing stored scipt:my_bk_script
{backup database plus archivelog;}

4,运行这个脚本,备份目标数据库
RMAN>run {execute scipt my_bk_script;}

5 删除脚本
RMAN>delete script. my_bk_script;
=====================================================
=====================================================
archivelog模式下的完全恢复

step1:set oracle_sid=recover
rman target rman_backup/password
configure controlfile autobackup on;

step2:backup database plus archivelog delete input;

step3:shutdown immediate;

step4:重命名所有的数据文件和控制文件,不重命名联机重做日志。

step5: startup nomount;
set DBID=****
restore controlfile from autobackup;
alter database mount;

step6: restore database;
recover database;
alter database open resetlogs;

表空间恢复

sql"alter tablespace users offline";
sql"alter tablespace tools offline";
restore tablespace users,tools;
recover tablespace users,tools;
sql"alter tablespace users online";
sql"alter tablespace tools online";

数据文件恢复

sql"alter database datafile 3 offline";
sql"alter database datafile 'd:oracleoradatausers01.dbf' offline";
restore datafile 3
restore datafile 'd:oracleoradatausers01.dbf';
recover datafile 3
recover datafile 'd:oracleoradatausers01.dbf';
sql"alter database datafile 3 online";
sql"alter database datafile 'd:oracleoradatausers01.dbf'online";

=====================================================
=====================================================
切换当前的incarnation 回到resetlogs 前RESET DATABASE TO INCARNATION inc_key

=====================================================
=====================================================

RMAN 高级恢复

1 基于时间点的恢复
run
{
set until time "to_date('07/01/02 15:00:00','mm/dd/yy hh24:mi:ss')"'
restore database;
recover database;
alter database open resetlogs;
}

2 基于SCN 的恢复
startup mount;
restore database UNTIL SCN 10000;
recover database UNTIL SCN 10000;
alter database open resetlogs;

3 基于日志序列的恢复
startup mount;
restore database UNTIL SEQUENCE 100 thread 1;
recover database UNTIL SEQUENCE 100 thread 1;
alter database open resetlogs;

==================================

c:/> rman cmdfile='' log=''

在run{}脚本里面,format后面的参数含义:%t代表当前时间,s%代表备份集,%p代表备份片

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27165054/viewspace-741349/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/27165054/viewspace-741349/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值