Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1278618
  • 博文数量: 1211
  • 博客积分: 10010
  • 博客等级: 上将
  • 技术积分: 14340
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-09 11:20
文章分类

全部博文(1211)

文章存档

2011年(1)

2008年(1210)

我的朋友

分类: 服务器与存储

2008-06-14 13:34:11

 如果表的许多分区被意外drop,需要利用带库上的备份集在测试机上做不完全恢复,而具体日期需要达到一个特定的时间,那么我们可以参考下文中的解决方法。
        ◆首先需要用logminer查出删除语句:

         uncompress /oracle/oradata/xxx/xxx.ARC.Z
        ...

        begin
        sys.dbms_logmnr.add_logfile('/oracle/oradata/xxx/xxx.ARC');
        ...
        end;

        begin sys.dbms_logmnr.start_logmnr(Options => sys.dbms_logmnr.DICT_FROM_ONLINE_CATALOG); end;

        create table xsb_logminer_1 as
        select timestamp, seg_name,operation, sql_redo
        from V$LOGMNR_CONTENTS
        where seg_owner='XXX' and operation='DDL' and sql_redo like 'ALTER TABLE XXX DROP PARTITION %';

        BEGIN sys.dbms_logmnr.end_logmnr();END;

        ◆然后在生产库上创建pfile:

         create pfile='...' from spfile;


        需要从带库上恢复rman备份集至生产机上,将此备份集FTP至测试机上,连同pfile文件.

        在测试机上创建与生产机上相同目录,admin ...

        在测试机上创建新实例:

         orapwd file=... password=xxx

        然后修改pfile文件内容,改变control_files内容。

        ◆启动新实例

         export ORACLE_SID=xxx
        sqlplus / as sysdba
        startup nomount pfile='/home/oracle/init_xxx.ora';
        create spfile from pfile='/home/oracle/init_xxx.ora';

        exit

        RMAN target sys/xxx
        restore controlfile from '...';
        startup mount
        --crosscheck backup;
        list backup;

        run
        {
        set newname for datafile 1 to '/oracle/oradata/xxx/system01.dbf';
        set newname for datafile 2 to '/oracle/oradata/xxx/undo01.dbf';
        set newname for datafile 3 to '/oracle/oradata/xxx/sysaux01.dbf';
        set newname for datafile 6

to '/oracle/oradata/xxx/pay_ts01.dbf';
        restore datafile 1;
        restore datafile 2;
        restore datafile 3;
        restore datafile 6;
        }
        (注:发现单个datafile恢复不如整库恢复快!)
        sql 'alter database backup controlfile to trace';
        shutdown immediate;
        exit

 

然后修改controlfile文件内容,去掉不用的文件名

        ◆不完全恢复数据库:

         sqlplus / as sysdba
        startup nomount;

        ◆重建控制文件
         CREATE CONTROLFILE REUSE DATABASE "XXX" RESETLOGS ARCHIVELOG
        MAXLOGFILES 40
        MAXLOGMEMBERS 3
        MAXDATAFILES 400
        MAXINSTANCES 2
        MAXLOGHISTORY 454
        LOGFILE
        GROUP 1 (
        '/oracle/oradata/xxx/rdb_redo01a'
        ) SIZE 10M,
        GROUP 2 (
        '/oracle/oradata/xxx/rdb_redo02a'
        ) SIZE 10M
        DATAFILE
        '/oracle/oradata/xxx/system01.dbf',
        '/oracle/oradata/xxx/undo01.dbf',
        '/oracle/oradata/xxx/sysaux01.dbf',
        '/oracle/oradata/xxx/pay_ts01.dbf'
        CHARACTER SET ZHS16GBK
        ;

        recover database until cancel using backup controlfile;
        ...

        alter database open resetlogs;


        ◆做数据恢复操作:
         create table xxx as select xxx from xxx where xxx;
        exp,ftp .dmp,imp

        也可以如下所示,这样会更简单一些:
         restore database;
        recover database using backup controlfile until cancel;
        alter database open resetlogs;
        ...

        END!!!

阅读(364) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~