码迷,mamicode.com
首页 > 其他好文 > 详细

RMAN异机恢复到不同的路劲下

时间:2015-02-11 18:49:48      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:rman异机恢复到不同的路劲下

1.全库备份,scp到异机目录下
  查询源库的DBID:
  SQL> select dbid,name from v$database;

      DBID NAME
---------- ---------
 439840715 YIJI

SQL>
   异机建立dump目录、oradata下建立SID名对应目录
 
2.恢复spfile,启动到nomount:   
   export ORACLE_SID=yiji
   rman target /
   set dbid=439840715
   startup nomount
   restore spfile to pfile ‘/u01/yiji/inityiji.ora‘ from ‘/u01/oradata/rman/YIJI_7_1_1.spf‘;
   startup force nomount pfile=‘/u01/yiji/inityiji.ora‘;

3.恢复控制文件到新的‘/u01/yiji/‘ 而非老的‘/u01/oradata/yiji/‘,启动到mount
 restore controlfile to ‘/u01/yiji/control01.ctl‘ from ‘/u01/oradata/rman/YIJI_6_1_1.ctl‘;
 restore controlfile to ‘/u01/yiji/control02.ctl‘ from ‘/u01/oradata/rman/YIJI_6_1_1.ctl‘;
RMAN> restore controlfile to ‘/u01/yiji/control03.ctl‘ from ‘/u01/oradata/rman/YIJI_6_1_1.ctl‘;

Starting restore at 19-JAN-15
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 19-JAN-15

RMAN>


 这个时候,初始化参数文件中的控制文件还是显示的之前的:
 SQL> show parameter contro

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      /u01/oradata/yiji/control01.ct
                                                 l, /u01/oradata/yiji/control02
                                                 .ctl, /u01/oradata/yiji/contro
                                                 l03.ctl
SQL>

 alter database mount;

 RMAN> alter database mount;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 01/19/2015 16:46:59
ORA-00205: error in identifying control file, check alert log for more info

RMAN>

所以,先修改 ‘/u01/yiji/inityiji.ora‘ 文件中的控制文件地址/u01/yiji,启动到nomout,然后再次mount:

RMAN> startup force nomount pfile=‘/u01/yiji/inityiji.ora‘;

Oracle instance started

Total System Global Area     285212672 bytes

Fixed Size                     2020224 bytes
Variable Size                 92277888 bytes
Database Buffers             188743680 bytes
Redo Buffers                   2170880 bytes

RMAN> alter database mount;

using target database control file instead of recovery catalog
database mounted

RMAN>


4.恢复数据库
 登记备份段:
catalog start with ‘/u01/oradata/rman/‘;

 run  {
set newname for datafile ‘/u01/oradata/yiji/system01.dbf‘ to ‘/u01/yiji/system01.dbf‘;
set newname for datafile ‘/u01/oradata/yiji/undotbs01.dbf‘ to ‘/u01/yiji/undotbs01.dbfF‘;
set newname for datafile ‘/u01/oradata/yiji/sysaux01.dbf‘ to ‘/u01/yiji/sysaux01.dbf‘;
set newname for datafile ‘/u01/oradata/yiji/users01.dbf‘ to ‘/u01/yiji/users01.dbf‘;
restore database;
switch datafile all;
}
recover database;

5.此时,控制文件中的redolog的路劲还是之前的/u01/oradata/yiji,所以需要backup controlfile to trace的方式重建控制文件,
修改其中的redolog的路劲到新的路劲,然后再打开:

CREATE CONTROLFILE REUSE DATABASE "YIJI" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 ‘/u01/yiji/redo01.log‘  SIZE 50M,
  GROUP 2 ‘/u01/yiji/redo02.log‘  SIZE 50M,
  GROUP 3 ‘/u01/yiji/redo03.log‘  SIZE 50M
DATAFILE
  ‘/u01/yiji/system01.dbf‘,
  ‘/u01/yiji/undotbs01.dbfF‘,
  ‘/u01/yiji/sysaux01.dbf‘,
  ‘/u01/yiji/users01.dbf‘
CHARACTER SET WE8ISO8859P1
;


alter database open resetlogs;

至此,控制文件、数据文件、redolog的路劲全部改了,数据库恢复成功!

本文出自 “hunter的Oracle世界” 博客,转载请与作者联系!

RMAN异机恢复到不同的路劲下

标签:rman异机恢复到不同的路劲下

原文地址:http://hunter8888.blog.51cto.com/1850277/1613788

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!