OS:

Oracle Linux Server release 5.7

DB:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

① RMAN异机恢复的时候,db_name必须相同。如果想要改别的实例命,可以在RMAN恢复成功后,用 nid 命令修改。

② 恢复路径与源库不相同,在restore时用set指定新位置,并用switch logfile all 将信息更新到controlfile文件中

准备工作:

1、查看源库的DBID

SQL> select name,dbid from v$database;

NAME DBID
--------------------------- ----------
YOON 675362528

SQL>

2、将源库的初始化参数文件拷贝到目标服务器上

3、将控制文件,数据文件,归档文件拷贝到目标服务器上

步骤:

1、准备工作准备好后,创建密码文件

[oracle@yoon dbs]$ orapwd file=orapwyoon password=oracle

2、检查拷贝过去的目录和文件的所属组和权限

3、连接到RMAN

[oracle@yoon dbs]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Sep 17 14:33:27 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

connected to target database (not started)

RMAN>

4、恢复初始化参数文件

RMAN> restore spfile to pfile '/u01/oracle/product/11.2.0/db_1/dbs/inityoon.ora' from '/u01/backup/c-675362528-20130915-02';

Starting restore at 17-SEP-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/backup/c-675362528-20130915-02
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 17-SEP-13

RMAN>

5、用pfile将目标库启动到nomount状态

RMAN> startup nomount pfile='/u01/oracle/product/11.2.0/db_1/dbs/inityoon.ora';

Oracle instance started

Total System Global Area 1653518336 bytes

Fixed Size 2228904 bytes
Variable Size 956304728 bytes
Database Buffers 687865856 bytes
Redo Buffers 7118848 bytes

RMAN>

6、恢复控制文件

RMAN> restore controlfile from '/u01/backup/c-675362528-20130915-02';

Starting restore at 17-SEP-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/oracle/oradata/yoon/control01.ctl
output file name=/u01/oracle/fast_recovery_area/yoon/control02.ctl
Finished restore at 17-SEP-13

RMAN>

7、将数据库启动到mount状态

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN>

8、restore数据库

RMAN> restore database;

Starting restore at 17-SEP-13
Starting implicit crosscheck backup at 17-SEP-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 17-SEP-13

Starting implicit crosscheck copy at 17-SEP-13
using channel ORA_DISK_1
Finished implicit crosscheck copy at 17-SEP-13

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/oracle/oradata/yoon/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/oracle/oradata/yoon/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/oracle/oradata/yoon/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/oracle/oradata/yoon/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/oracle/fast_recovery_area/YOON/backupset/2013_09_15/o1_mf_nnndf_TAG20130915T124630_93bgx6qx_.bkp
channel ORA_DISK_1: piece handle=/u01/oracle/fast_recovery_area/YOON/backupset/2013_09_15/o1_mf_nnndf_TAG20130915T124630_93bgx6qx_.bkp tag=TAG20130915T124630
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 17-SEP-13

RMAN>

9、recover 数据库

RMAN> recover database;

Starting recover at 17-SEP-13
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 1 is already on disk as file /u01/oracle/fast_recovery_area/YOON/archivelog/2013_09_15/o1_mf_1_1_93bj33dx_.arc
archived log file name=/u01/oracle/fast_recovery_area/YOON/archivelog/2013_09_15/o1_mf_1_1_93bj33dx_.arc thread=1 sequence=1
unable to find archived log
archived log thread=1 sequence=1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 09/17/2013 14:45:37
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 1 and starting SCN of 1298407

RMAN>

RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 1 and starting SCN of 1298407

提醒恢复到一个未知的SCN号,在alter database mount 之后,通过set until scn 或 set until time命令设置恢复到scn号或时间。

10、用open resetlogs 打开数据库

RMAN> alter database open resetlogs;

database opened

RMAN>

* 11g r2,在open resetlogs后,自动创建默认路径的temp表空间和redo文件

11、查看目标的BDID

SQL> select name,dbid from v$database;

NAME DBID
--------------------------- ----------
YOON 675362528

SQL>

12、用NID命令修改DBID,执行前主要关闭all session

① 修改dbid可能会遇到错误,建议备份数据库,特别是控制文件,因为nid会修改控制文件的信息

② 需要将数据库启动到mount

RMAN> shutdown immediate

database closed
database dismounted
Oracle instance shut down

RMAN>

RMAN> startup mount

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area 1653518336 bytes

Fixed Size 2228904 bytes
Variable Size 956304728 bytes
Database Buffers 687865856 bytes
Redo Buffers 7118848 bytes

RMAN>

[oracle@yoon ~]$ nid target=sys/oracle

DBNEWID: Release 11.2.0.3.0 - Production on Tue Sep 17 14:57:03 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

Connected to database YOON (DBID=675362528)

Connected to server version 11.2.0

Control Files in database:
/u01/oracle/oradata/yoon/control01.ctl
/u01/oracle/fast_recovery_area/yoon/control02.ctl

Change database ID of database YOON? (Y/[N]) => y

Proceeding with operation
Changing database ID from 675362528 to 678297407
Control File /u01/oracle/oradata/yoon/control01.ctl - modified
Control File /u01/oracle/fast_recovery_area/yoon/control02.ctl - modified
Datafile /u01/oracle/oradata/yoon/system01.db - dbid changed
Datafile /u01/oracle/oradata/yoon/sysaux01.db - dbid changed
Datafile /u01/oracle/oradata/yoon/undotbs01.db - dbid changed
Datafile /u01/oracle/oradata/yoon/users01.db - dbid changed
Datafile /u01/oracle/oradata/yoon/temp01.db - dbid changed
Control File /u01/oracle/oradata/yoon/control01.ctl - dbid changed
Control File /u01/oracle/fast_recovery_area/yoon/control02.ctl - dbid changed
Instance shut down

Database ID for database YOON changed to 678297407.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database ID.
DBNEWID - Completed succesfully.

[oracle@yoon dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Tue Sep 17 14:58:01 2013

Copyright (c) 1982, 2011, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 1653518336 bytes
Fixed Size 2228904 bytes
Variable Size 956304728 bytes
Database Buffers 687865856 bytes
Redo Buffers 7118848 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

SQL>

SQL> alter database open resetlogs;

Database altered.

SQL>

SQL> select name,dbid from v$database;

NAME DBID
--------------------------- ----------
YOON 678297407

SQL>

13、修改DB_NAME

[oracle@yoon ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Sep 17 15:01:06 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

connected to target database: YOON (DBID=678297407)

RMAN> shutdown immediate

using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down

RMAN> startup mount

connected to target database (not started)
Oracle instance started
database mounted

Total System Global Area 1653518336 bytes

Fixed Size 2228904 bytes
Variable Size 956304728 bytes
Database Buffers 687865856 bytes
Redo Buffers 7118848 bytes

RMAN>

[oracle@yoon ~]$ nid target=sys/oracle dbname=leonardo

DBNEWID: Release 11.2.0.3.0 - Production on Tue Sep 17 15:01:55 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

Connected to database YOON (DBID=678297407)

Connected to server version 11.2.0

Control Files in database:
/u01/oracle/oradata/yoon/control01.ctl
/u01/oracle/fast_recovery_area/yoon/control02.ctl

Change database ID and database name YOON to LEONARDO? (Y/[N]) => y

Proceeding with operation
Changing database ID from 678297407 to 4108249507
Changing database name from YOON to LEONARDO
Control File /u01/oracle/oradata/yoon/control01.ctl - modified
Control File /u01/oracle/fast_recovery_area/yoon/control02.ctl - modified
Datafile /u01/oracle/oradata/yoon/system01.db - dbid changed, wrote new name
Datafile /u01/oracle/oradata/yoon/sysaux01.db - dbid changed, wrote new name
Datafile /u01/oracle/oradata/yoon/undotbs01.db - dbid changed, wrote new name
Datafile /u01/oracle/oradata/yoon/users01.db - dbid changed, wrote new name
Datafile /u01/oracle/oradata/yoon/temp01.db - dbid changed, wrote new name
Control File /u01/oracle/oradata/yoon/control01.ctl - dbid changed, wrote new name
Control File /u01/oracle/fast_recovery_area/yoon/control02.ctl - dbid changed, wrote new name
Instance shut down

Database name changed to LEONARDO.
Modify parameter file and generate a new password file before restarting.
Database ID for database LEONARDO changed to 4108249507.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.

[oracle@yoon ~]$

SQL> select name,dbid from v$database;

NAME DBID
--------------------------- ----------
LEONARDO 4108249507

SQL>

RMAN - 备份异机恢复的更多相关文章

  1. RMAN 备份异机恢复 并创建新DBID

    测试平台信息: Oracle:11gR2 操作系统:Redhat 5.5 Target DB:dave   几点说明: (1)RMAN 异机恢复的时候,db_name必须相同. 如果说要想改成其他的实 ...

  2. 使用rman备份异机恢复数据库

    一.RMAN备份源库注意点: 最好保留rman备份日志 $rman target / log=backup.log RMAN>run { allocate channel t1 type dis ...

  3. Rman备份异机恢复

    最后更新时间:2018/12/29 前置条件 已准备一台安装好Centos6+oracle11gr2 软件的服务器; 只安装了 oracle 数据库软件,需要手工创建以下目录: #环境变量 expor ...

  4. RAC数据库的RMAN备份异机恢复到单节点数据库

    1.首先在rac环境用rman备份数据库.[oracle@rac1 admin]$ rman target /run{allocate channel c1 device type disk conn ...

  5. Hyper-V安装Oracle Linux6_4 Oracle db 12c并使用rman做异机恢复

    本文记录在Windows Server 2012 R2上安装Oracle Enterprise Linux 6.4以及使用RMAN进行进行异机恢复的过程. Windows服务器增加Hyper-V功能 ...

  6. Oracle之使用rman进行异机恢复测试记录

    本次测试目的是从生产数据库导出rman备份然后在测试数据库恢复 1,拷贝备份至相应目录 2,进入rman rman target \ 3,关闭数据库 shutdown 4,以nomount模式启动数据 ...

  7. rman全备份异机恢复

    一.测试环境 [oracle@localhost ~]$ uname -a Linux localhost.localdomain -.el6.x86_64 # SMP Tue May :: EDT ...

  8. rman 备份并异机恢复

    1.RMAN 备份脚本 RUN { CONFIGURE RETENTION POLICY DAYS; CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CO ...

  9. Oracle 单实例 迁移到 RAC 实例 -- 使用RMAN 异机恢复

    Oracle 官网有关单实例迁移到RAC的一个步骤说明: How to Convert 10g Single-Instance database to 10g RAC using Manual Con ...

随机推荐

  1. [闲谈] 有经验的程序员用Google用得多么?

    关于程序员有没有必要记一些API什么的讨论有很多,我个人觉得能Google到的就没必要刻意去记,可以简单的做个笔记,需要用的时候查一下就好了.真正有必要记的东西,用得多了自然也就能记住了. 文章不难, ...

  2. (转载)MonoBehaviour的事件和具体功能总结

    分享一点MonoBehaviour的事件和具体功能总结的基础知识,苦于Visual Studio 2013没有对MonoBehaviour的行为做出智能提示,写个函数都要全手打,记性好的将就着手打,脑 ...

  3. c++引用小问题!

    两段程序 string version(const string &s1,const string &s2) { string temp; temp =s2+s1+s2; return ...

  4. Git 图解剖析

    git中文件内容并没有真正存储在索引(.git/index)或者提交对象中,而是以blob的形式分别存储在数据库中(.git/objects),并用SHA-1值来校验. 索引文件用识别码列出相关的bl ...

  5. 终于解决了PHP调用SOAP过程中的种种问题。(转)

    最近在做公司和第三方的一个合作项目,需要调用统一验证接口和统一支付接口.由于牵涉公司机密,所以我要单独写一层PHP的接口给第三方用.前面那个验证接口主要卡在了des加密的方式上,这个有时间再说.这篇主 ...

  6. 【Hibernate 3】一对一映射配置

    一.一对一映射简介 一对一关联映射有两种实现策略: 第一种:主键关联,即让两个对象具有相同的主键值,以表明它们之间的一一对应的关系:数据库表不会有额外的字段来维护它们之间的关系,仅通过表的主键来关联 ...

  7. A new start!

    从今天起,开始每天晚上拿出来半个小时到一个小时的时间来总结今天我做的那些事情,有哪些进步,有哪些不足,有哪些心得和笔记. 以前的学习都是每天学完就往脑袋后面一放,导致很多东西当时学会了,但是后面就都想 ...

  8. 转载:SMS软件FESWMS模型使用体会

    自学了SMS-FESWMS几个月,从其原理到具体应用都已经比较熟悉.感觉这个软件还是有许多不足,这也是需要进一步提高和改进的地方.下面谈谈自己的一些感受和体会. 首先,对一些比较简单的模型,软件的计算 ...

  9. [zt]Which are the 10 algorithms every computer science student must implement at least once in life?

    More important than algorithms(just problems #$!%), the techniques/concepts residing at the base of ...

  10. POJ 1195

    Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 13774   Accepted: 6393 De ...