ITPub博客

首页 > Linux操作系统 > Linux操作系统 > rman

rman

原创 Linux操作系统 作者:flyingslr 时间:2009-03-10 11:21:49 0 删除 编辑

第 10 章 RMAN备份
1 数据库备份:RMAN>backup database format='d:\backup\%d_%s.dbf';rman>sql 'alter system archive log current';
2 免除表空间:rman>configure exclude for tablespace users;rman>backup database format='d:\backup\%d_%s.dbf';rman>sql 'alter system archive log current';
3 备份表空间:rman>backup tablespace users format='d:\backup\%d_%s.dbf';
4 备份数据文件:rman>backup datafile 5 format='d:\backup\%d_%s.dbf';
5 备份控制文件:rman>backup current controlfile format='d:\backup\%d_%s.dbf';
6 备份归档日志:rman>backup format='d:\backup\%d_%s.dbf' archivelog from time='sysdate-1' until 'sysdate';
7 增量备份:rman>backup incremental level 0 format='d:\backup\%d_%s.dbf' tablesapce users;
            rman>backup incremental level 1 format='d:\backup\%d_%s.dbf' tablesapce users;
            rman>backup incremental level 2 format='d:\backup\%d_%s.dbf' tablesapce users;
8 显示可用的归档日志映像:sql>col name format a45; sql> select sequence#,name,first_change# from v$archived_log where status='A';
9 显示数据文件和控制文件备份集信息:sql>select a.file#,b.handle,a.blocks*a.block_size byte from v$backup_datafile a,v$backup_piece b where a.set_stamp=b.set_stamp AND b.status='A';
10 显示归档日志备份集的信息:sql>select distinct a.handle,b.sequence#,b.first_change#,b.blocks from v$backup_piece a,v$backup_redolog b where a.set_stamp=b.set_stamp and a.status='A';

第 11 章 RMAN 恢复
1 转储命令:(1)mount:restore database;(2)nomount:restore controlfile;restore spfile;(3)open:restore tablespace;(4)mount or open:restore archivelog;restore datafile;
2 恢复命令:(1)mount:recover database;(2)open:recover tablespace;(3)mount or open:recover datafile;
3 检测数据文件:sql>select file#,error from v$recover_file;
4 所有数据文件被误删除:rman>startup force mount;rman>run { restore database; restore database; sql 'alter database open';}
5 数据文件所在磁盘故障:
RMAN> run {
2> set newname for datafile 1 to 'e:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM0.DBF';
3> set newname for datafile 2 to 'e:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS1.DBF';
4> set newname for datafile 3 to 'e:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX0.DBF';
5> set newname for datafile 4 to 'e:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF';
6> restore database;
7> switch datafile all;
8> recover database;
9> sql 'alter database open';
10> }
6 数据文件以外丢失,且所在磁盘损坏:
RMAN>run {
startup force mount;
sql 'alter database datafile 4 offline';
sql 'alter database open';
set newname for datafile 4 to 'd:\demo\users.dbf';
restore datafile 4;
switch datafile 4;
recover datafile 4;
sql 'alter database datafile 4 online';
}
7 表空间的所有数据文件丢失,且所在磁盘损坏:
rman> run {
sql 'alter tablespace users offline for recover';
set newname for datafile 4 to 'd:\demo\users.dbf';
restore tablespace users;
switch datafile all;
recover tablespace users;
sql 'alter tablespace users online';
}
8 基于时间的不完全恢复:
c:\>set nls_date_format=yyyy-mm-dd hh24:mi:ss
c:\>rman target sys/oracle@demo nocatalog
RMAN>run {
startup force mount;
set until time='2009-03-09 09:20:00';
restore database;
recover database;
sql 'alter database open resetlogs';
}
9 基于scn的不完全恢复:
sql>select current_scn from v$database;
rman>run {
startup force mount;
set until scn=511413;
restore database;
recover database;
sql 'alter database open resetlogs';
}
10 基于日志序列号的恢复:
rman>run {
startup force mount;
set until sequence=6;
restore database;
recover database;
sql 'alter database open resetlogs';
}


第 12 章 rman维护命令
1 report:RMAN> report schema;

使用目标数据库控制文件替代恢复目录
数据库方案报表

永久数据文件列表
===========================
文件大小 (MB) 表空间           回退段数据文件名称
---- -------- -------------------- ------- ------------------------
1    480      SYSTEM               ***     E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL
\SYSTEM01.DBF
2    135      UNDOTBS1             ***     E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL
\UNDOTBS01.DBF
3    260      SYSAUX               ***     E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL
\SYSAUX01.DBF
4    27       USERS                ***     E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL
2
2 list: rman>list backup;
3 crosscheck:rman>crosscheck backup;
3 delete:rman>delete noprompt obsolete;
4 change:rman>change backupset 22 unavailable;
         rman>change backupset 156 keep foever logs;
         rman>change backupset 198 keep until time 'sysdate+60';
         rman>change backupset 156 nokeep;
5 catalog:rman>catalog datafilecopy 'd:\backup\users01.bak';
          rman>catalog backuppiece 'd:\backup\demo_01.dbf' cataloged backuppiece;
          rman>catalog start with 'd:\bak';
          rman>change datafilecopy 'd:\bak\users.dbk' uncatalog;

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

上一篇: 使用flashback
下一篇: expdp/impdp
请登录后发表评论 登录
全部评论

注册时间:2008-07-15

  • 博文量
    44
  • 访问量
    80153