博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助

好好学习,天天向SUN

联系方式: leiyu530@163.com
  penguinstorm.cublog.cn

关于作者
姓名:雷宇
昵称:storm
职业:IT
年龄:26
位置:北京
个性介绍:没啥个性
不聊MSN/QQ
本着资源共享的精神,所有文章欢迎转载
|| << >> ||
我的分类


ORACLE9i_RMAN备份恢复小实验系列之七:基于恢复目录还原
准备工作
这里先建一个数据库rman(用来存放catalog)
创建表空间
SQL> create tablespace rman_ts datafile          
  2  'D:\oracle\oradata\rman\rman_ts.dbf' size 20m
  3   autoextend on next 1m maxsize unlimited    
  4  extent management local uniform size 128k;  
创建用户
SQL> create user rman_owner identified by rman_owner    
  2  default tablespace rman_ts                             
  3  quota unlimited on rman_ts;                            
       
授权
 grant connect,resource,recovery_catalog_owner to rman_owner;

登陆ora9i数据库和恢复目录数据库(rman)
D:\>rman catalog rman_owner/rman_owner@rman target sys/oracle@ora9i
创建恢复目录
RMAN> create catalog tablespace rman_ts
注册在恢复目录中的数据库
RMAN> register database;
给数据库做一个备份
注意:可能需要切换副本
RMAN> list incarnation of database;

数据库 Incarnations 列表
DB 关键字  Inc 关键字 DB 名  DB ID            CUR 重置 SCN   重置时间
------- ------- -------- ---------------- --- ---------- ----------
1       13      UNKNOWN   2439988007       NO  240781     2007-12-03:16:27:21
1       2       ORA9I     2439988007       YES 305031     2007-12-03:18:44:02
RMAN>  reset database to incarnation 2;
SQL> create table scott.test2(n1 number) tablespace users;
SQL> insert into scott.test2 values(1);
SQL> insert into scott.test2 values(2);
SQL> alter system switch logfile;
 
SQL> drop tablespace users including contents and datafiles;
SQL>  create table scott.test3(n1 number) tablespace tools;
SQL> insert into scott.test3 values(2);
SQL> shutdown abort
在 ora9iALRT.log里
Mon Dec 03 19:16:23 2007
Deleted file D:\ORACLE\ORADATA\ORA9I\USERS01.DBF
Completed: drop tablespace users including contents and dataf

恢复到2007-12-03:19:16:22的样子
RMAN> startup nomount
RMAN>
 run {                           
 set until time='2007-12-03:19:16:22';                                  
 restore controlfile;               
 alter database mount;              
 restore database;                  
 recover database;                  
 alter database open resetlogs;}  
恢复完之后
 
SQL> select * from scott.test2;                      
                             
        N1                   
----------                   
         1                   

SQL> select * from scott.test3;
select * from scott.test3
                    *
ERROR 位于第 1 行:
ORA-00942: 表或视图不存在    

发表于: 2007-12-03,修改于: 2007-12-03 19:26,已浏览330次,有评论0条 推荐 投诉


网友评论
 发表评论