RMAN 不完全恢复

之前做好备份

SQL> conn scott/abc123

SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';  2012-04-24 10:10:53


SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;


SYSDATE

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

2012-03-12 01:28:15


SQL> drop table emp;

SQL> commit;



SQL> shutdown abort;

SQL> startup mount

SQL> !rman target /



RMAN> run {

 set until time "to_date('2012-04-24 10:10:53','yyyy-mm-dd hh24:mi:ss')";

 restore database;

 recover database;

 alter database open resetlogs;

 }


数据库直接打开


scott用户查看emp表



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

所有文件丢失,参数文件也丢失

RMAN> backup database;

1.删除所有文件

[oracle@sq123 ~]$ cd /oracle/app/oradata/TEST/

[oracle@sq123 TEST]$ rm -rf *

  cd /oracle/app/oracle/product/10.2.0/db_1/dbs

[oracle@sq123 dbs]$ rm -rf spfileTEST.ora 

[oracle@sq123 dbs]$ rm -rf initdw.ora 

SQL> startup

(失败,找不到参数文件)



2.[oracle@sq123 ~]$ cd /oracle/app/admin/TEST/bdump/

  [oracle@sq123 bdump]$ tail -500 alert_TEST.log |more

  (找到之前启动时的参数)

    processes                = 150

  __shared_pool_size       = 79691776

  __large_pool_size        = 4194304

  __java_pool_size         = 4194304

  __streams_pool_size      = 0

  nls_language             = AMERICAN

  sga_target               = 285212672

  control_files            = /oracle/app/oradata/TEST/control01.ctl, /oracle/app/orad

ata/TEST/control02.ctl, /oracle/app/oradata/TEST/control03.ctl

  db_block_size            = 8192

  __db_cache_size          = 192937984

  compatible               = 10.2.0.1.0

  db_file_multiblock_read_count= 16

  db_recovery_file_dest    = /oracle/app/flash_recovery_area

  db_recovery_file_dest_size= 2147483648

  undo_management          = AUTO

  undo_tablespace          = UNDOTBS1

  remote_login_passwordfile= EXCLUSIVE

  db_domain                = 

  dispatchers              = (PROTOCOL=TCP) (SERVICE=TESTXDB)

  job_queue_processes      = 10

  background_dump_dest     = /oracle/app/admin/TEST/bdump

  user_dump_dest           = /oracle/app/admin/TEST/udump

  core_dump_dest           = /oracle/app/admin/TEST/cdump

  audit_file_dest          = /oracle/app/admin/TEST/adump

  db_name                  = TEST

  open_cursors             = 300

  pga_aggregate_target     = 94371840


3.[oracle@sq123 ~]$ vi initnew.ora

  把上面的复制过来

  不要复制的行

    db_domain                = 

  dispatchers              = (PROTOCOL=TCP) (SERVICE=TESTXDB)


4.SQL> startup nomount pfile=/home/oracle/initnew.ora

(启动正常)


5.恢复spfile

RMAN> restore spfile from '/oracle/app/flash_recovery_area/TEST/backupset/2012_03_12/o1_mf_ncsnf_TAG20120312T003337_7oso413h_.bkp';


[oracle@sq123 ~]$ cd /oracle/app/oracle/product/10.2.0/db_1/dbs

[oracle@sq123 dbs]$ ls(spfile 已经恢复)


6.SQL> startup nomount force;(用恢复的spfile启动)

恢复控制文件

RMAN> restore controlfile from '/oracle/app/flash_recovery_area/TEST/backupset/2012_03_12/o1_mf_ncsnf_TAG20120312T003337_7oso413h_.bkp';



7.恢复数据文件

RMAN> alter database mount;

RMAN> restore database;

RMAN> recover database;(报错因为没有日志了,但必须运行)

RMAN> alter database open resetlogs;

(数据库正常)


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

测试备份是否有用

RMAN> restore database validate;

(测试不真正恢复)


[oracle@sq123 2012_03_12]$ echo "a" >>o1_mf_nnndf_TAG20120312T003337_7osnz2q6_.bkp 

(模拟备份实效)


RMAN> restore database validate;(报错)


查看那些文件需要备份 

RMAN> report need backup;




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

免除表空间

  RMAN>configure exclude for tablespace user03;

    RMAN>backup database;


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

块恢复

RMAN> blockrecover datafile 12 block 2718618 from backupset;


本文出自 “linux” 博客,谢绝转载!

你可能感兴趣的:(恢复,不完全)