使用RMAN复制恢复开发库环境

最近为了不影响开发库的使用,打算复制创建一个备库,定时更新,防止开发库不能使用的情况下,可以临时使用备库,不影响进度。

环境:
11.2.0.4的单实例库。
库1是源库(target),库2是备库(auxiliary)

操作过程:

1.库1执行全库备份

[oracle@testvm002 duplicate]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Feb 1 16:57:06 2016

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

connected to target database: DEP (DBID=1501218369)

RMAN> run{
2> allocate channel dup type disk;
3> backup format '/home/oracle/duplicate/df_t%t_s%s_p%p' database;
4> sql 'alter system archive log current';
5> backup format '/home/oracle/duplicate/al_t%t_s%s_p%p' archivelog all delete input;
6> release channel dup;
7> }

using target database control file instead of recovery catalog
allocated channel: dup
channel dup: SID=24 device type=DISK

Starting backup at 01-FEB-16
channel dup: starting full datafile backup set
channel dup: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/11.2.0.4/oradata/dep/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/11.2.0.4/oradata/dep/dep_tbs01.dbf
input datafile file number=00001 name=/u01/app/oracle/11.2.0.4/oradata/dep/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/11.2.0.4/oradata/dep/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/11.2.0.4/oradata/dep/users01.dbf
channel dup: starting piece 1 at 01-FEB-16
channel dup: finished piece 1 at 01-FEB-16
piece handle=/home/oracle/duplicate/df_t902681834_s10_p1 tag=TAG20160201T165714 comment=NONE
channel dup: backup set complete, elapsed time: 00:00:36
channel dup: starting full datafile backup set
channel dup: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel dup: starting piece 1 at 01-FEB-16
channel dup: finished piece 1 at 01-FEB-16
piece handle=/home/oracle/duplicate/df_t902681870_s11_p1 tag=TAG20160201T165714 comment=NONE
channel dup: backup set complete, elapsed time: 00:00:01
Finished backup at 01-FEB-16

sql statement: alter system archive log current

Starting backup at 01-FEB-16
current log archived
channel dup: starting archived log backup set
channel dup: specifying archived log(s) in backup set
input archived log thread=1 sequence=743 RECID=13 STAMP=902681873
input archived log thread=1 sequence=744 RECID=14 STAMP=902681874
channel dup: starting piece 1 at 01-FEB-16
channel dup: finished piece 1 at 01-FEB-16
piece handle=/home/oracle/duplicate/al_t902681874_s12_p1 tag=TAG20160201T165754 comment=NONE
channel dup: backup set complete, elapsed time: 00:00:01
channel dup: deleting archived log(s)
archived log file name=/u01/app/oracle/11.2.0.4/fast_recovery_area/DEP/archivelog/2016_02_01/o1_mf_1_743_cby7jklq_.arc RECID=13 STAMP=902681873
archived log file name=/u01/app/oracle/11.2.0.4/fast_recovery_area/DEP/archivelog/2016_02_01/o1_mf_1_744_cby7jl4s_.arc RECID=14 STAMP=902681874
Finished backup at 01-FEB-16

released channel: dup

2.库1备份控制文件

SQL> alter database backup controlfile to '/home/oracle/duplicate/control.ctl';

Database altered.

3.将备份集(1)拷贝到库2相同路径下,即/home/oracle/duplicate,此时产生了三个文件:

al_t902681874_s12_p1
df_t902681834_s10_p1
df_t902681870_s11_p1

4.将库1的inittest.ora参数文件拷贝到库2,并按照其中配置的控制文件路径,将库1的控制文件(2)可以直接copy到库2对应路径下,包括文件名需要保持和参数文件总定义一致:

*.control_files='/u01/app/oracle/11.2.0.4/oradata/test/control01.ctl','/u01/app/oracle/11.2.0.4/fast_recovery_area/test/control02.ctl'

创建文件夹:

/u01/app/oracle/11.2.0.4/oradata/test
/u01/app/oracle/11.2.0.4/fast_recovery_area/test
/u01/app/oracle/11.2.0.4/admin/adump(/bdump/cdump/dpdump/udump)

5.库2启动nomount状态

SQL> startup nomount pfile='/u01/app/oracle/11.2.0.4/dbhome_1/dbs/initdep.ora';
ORACLE instance started.

Total System Global Area 1620115456 bytes
Fixed Size                  2253704 bytes
Variable Size             922750072 bytes
Database Buffers          687865856 bytes
Redo Buffers                7245824 bytes

6.库2执行恢复

[oracle@testvm001 dbs]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Feb 1 17:10:21 2016

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

connected to target database: DEP (not mounted)

RMAN> restore database;

Starting restore at 01-FEB-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 device type=DISK
RMAN-00571: ==================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ======
RMAN-00571: ==================================================
RMAN-03002: failure of restore command at 02/01/2016 17:10:28
ORA-01507: database not mounted

报错提示数据库需要置为mount状态。

7.库2置为mount状态

SQL> alter database mount;

Database altered.

8.库2执行恢复

RMAN> restore database;

Starting restore at 01-FEB-16
released channel: ORA_DISK_1
Starting implicit crosscheck backup at 01-FEB-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 device type=DISK
Crosschecked 6 objects
Finished implicit crosscheck backup at 01-FEB-16

Starting implicit crosscheck copy at 01-FEB-16
using channel ORA_DISK_1
Crosschecked 6 objects
Finished implicit crosscheck copy at 01-FEB-16

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/app/oracle/11.2.0.4/oradata/dep/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/11.2.0.4/oradata/dep/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/11.2.0.4/oradata/dep/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/11.2.0.4/oradata/dep/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/11.2.0.4/oradata/dep/dep_tbs01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/duplicate/df_t902681834_s10_p1
channel ORA_DISK_1: piece handle=/home/oracle/duplicate/df_t902681834_s10_p1 tag=TAG20160201T165714
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 01-FEB-16

9.库2执行打开

SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

报错提示需要使用RESETLOGS或NORESETLOGS。

10.库2执行打开

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u01/app/oracle/11.2.0.4/oradata/dep/system01.dbf'

依旧报错,提示:
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: ‘/u01/app/oracle/11.2.0.4/oradata/dep/system01.dbf’

查看这两个报错:

[oracle@testvm001 dbs]$ oerr ora 1152 01152, 00000, “file %s was
not restored from a sufficiently old backup ”
*Cause: An incomplete recovery session was started, but an
insufficient number of logs were applied to make the database
consistent. This file is still in the future of the last log applied.
The most likely cause of this error is forgetting to restore the file
from a backup before doing incomplete recovery.
*Action: Either apply more logs until the database is consistent or > restore the database file from an older backup and repeat
recovery.

[oracle@testvm001 dbs]$ oerr ora 1110 01110, 00000, “data file %s: ‘%s’”
*Cause: Reporting file name for details of another error.
The reported name can be of the old file if a data file
move operation is in progress.
*Action: See associated error message.

11.库2执行recover

RMAN> recover database;

Starting recover at 01-FEB-16
using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=743
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=744
channel ORA_DISK_1: reading from backup piece /home/oracle/duplicate/al_t902681874_s12_p1
channel ORA_DISK_1: piece handle=/home/oracle/duplicate/al_t902681874_s12_p1 tag=TAG20160201T165754
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oracle/11.2.0.4/fast_recovery_area/DEP/archivelog/2016_02_01/o1_mf_1_743_cby8pbbf_.arc thread=1 sequence=743
channel default: deleting archived log(s)
archived log file name=/u01/app/oracle/11.2.0.4/fast_recovery_area/DEP/archivelog/2016_02_01/o1_mf_1_743_cby8pbbf_.arc RECID=16 STAMP=902683082
archived log file name=/u01/app/oracle/11.2.0.4/fast_recovery_area/DEP/archivelog/2016_02_01/o1_mf_1_744_cby8pbc5_.arc thread=1 sequence=744
channel default: deleting archived log(s)
archived log file name=/u01/app/oracle/11.2.0.4/fast_recovery_area/DEP/archivelog/2016_02_01/o1_mf_1_744_cby8pbc5_.arc RECID=15 STAMP=902683082
unable to find archived log
archived log thread=1 sequence=745
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/01/2016 17:18:03
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 745 and starting SCN of 14019269

提示需要sequence=745号的archivelog

12.查看备份集中归档文件al_t902681874_s12_p1的sequence是12。

13.再次执行恢复

RMAN> run{
2>  allocate channel ch00 type disk;
3>  set until sequence 13 thread 1;
4>  recover database;
5>  release channel ch00;
6> }

released channel: ORA_DISK_1
allocated channel: ch00
channel ch00: SID=10 device type=DISK

executing command: SET until clause

Starting recover at 01-FEB-16

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 01-FEB-16

released channel: ch00

对应alert日志:

ARC3: Archival started
ARC0: STARTING ARCH PROCESSES COMPLETE
Starting background process QMNC
Mon Feb 01 17:22:33 2016
QMNC started with pid=27, OS id=4154
LOGSTDBY: Validating controlfile with logical metadata
LOGSTDBY: Validation complete

14.开启库2

SQL> alter database open resetlogs;

Database altered.

对应alert日志:

Completed: alter database open resetlogs
Mon Feb 01 17:22:35 2016
db_recovery_file_dest_size of 4977 MB is 0.00% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.
Mon Feb 01 17:22:35 2016
Starting background process CJQ0
Mon Feb 01 17:22:35 2016
CJQ0 started with pid=28, OS id=4168

15.登录库2,用户、对象等信息和库1完全一致。

总结:
​1.RMAN执行restore需要数据库置于mount状态。
2.可以先将target的control控制文件拷贝到auxiliary库相同路径下,需要注意参数文件中定义的控制文件路径以及其他文件夹均需要提前在auxiliary库中创建,如果提前将控制文件拷贝到auxiliary库对应路径下,则无需restore control,相当于已经做了这不操作。
​3.resetlogs提示ORA1152错误,需要进行相应归档日志的恢复,根据拷贝过来的归档日志文件名推算seq号。

时间: 2024-09-16 11:32:39

使用RMAN复制恢复开发库环境的相关文章

DG6—— 用RMAN复制 搭建 物理 Data Gurad 环境

原文转自:http://blog.csdn.net/tianlesoftware/article/details/5756750 Data Guard 环境: 操作系统: redhat 4.7  Primary数据库: IP地址:10.85.10.1 数据库SID:orcl DB_UNIQUE_NAME:orcl_pd   Standby数据库: IP地址:10.85.10.2 数据库SID:orcl DB_UNIQUE_NAME:orcl_st 之前也做过相关实验, 今天这个测试主要是用RMA

RMAN高级应用之不同环境下的复制流程

不同配置决定不同的复制的流程. 一.远程站点相同路径结构的复制 Duplicating a Database on a Remote Host with the Same Directory Structure 对于这种选择而言,操作实在太过简单,你甚至不需要修改初始化参数文件或者重命名复制的数据文件(可惜,做测试的话这却不能做为我们的首选,一般测试都只有一台机器,难道让我再虚拟个操作系统?)如果是多台机器的话,这种操作非常省事,步骤也很少: 1.创建辅助实例. 2.Rman连接并运行dupli

pdf-如何在一个PDF文件中划线,划好之后保存,用的是C/C++,windows环境,请问用什么开发库?

问题描述 如何在一个PDF文件中划线,划好之后保存,用的是C/C++,windows环境,请问用什么开发库? 在线等,请各位大神帮忙,谢谢!在线等,请各位大神帮忙,谢谢! 解决方案 学习PDF文件结构,然后读写文件,自己实现.自己动手,丰衣足食~~ 解决方案二: http://blog.csdn.net/wangjie0377/article/details/7163370

使用rman复制数据库

数据|数据库 -------------------------------------------- 实验环境:windows + oracle 10.1.0.2.0 原数据库:ning[归档模式]  复制数据库:test Author:NinGoo    2005-3-27 -------------------------------------------   在同一台server上使用rman的Duplicate Database创建复制数据库.   1.    创建新的instanc

如何不使用rman工具恢复被rm删除的数据文件

朋友一时兴起使用了rm**,删除了oracle数据文件后找我帮忙,我在帮朋友恢复数据库时,遇到了当recover时,报错不能找到28739号归档日志,这样我就不能同步scn,更不能打开数据库了.这是归档日志不连续的典型案例,我最后告诉他要做好心理准备.事情还没有完,这个真实案例引发了我的思考,如果当时在朋友没有做rman拯救措施的情况下,可不可能不使用rman即可恢复数据文件呢!最后我找到了答案:) 案例 1.系统solaris SunOS TJLT-YDWG6 5.9 Generic_1223

OpenGL开发库的介绍[转载]

开发基于 OpenGL 的应用程序,必须先了解 OpenGL 的库函数.它采用 C 语言风格,提供大量的函数来进行图形的处理和显示. OpenGL 库函数的命名方式非常有规律.所有 OpenGL 函数采用了以下格式:  < 库前缀 >< 根命令 >< 可选的参数个数 >< 可选的参数类型 >  库前缀有 gl . glu . aux . glut . wgl . glx . agl 等等,分别表示该函数属于 OpenGL 那个开发库,从函数名后面中还可以看出

centos5.5下搭建python开发运行环境

首先想说的是,centos5.5操作系统版本比较老了,它默认安装了python2.4,与其相关联的如yum等,则要求必须使用python2.4.因此,在安装python更高版本时,必须要注意与老软件的兼容问题. 安装方法很简单,直接使用yum即可:  代码如下 复制代码 yum install python27 yum install python-pip 安装完成后,需要修改yum服务的scripts: 开发运行环境-python运行环境搭建">  代码如下 复制代码 vim pytho

oracle中如何通过RMAN复制数据库

通过使用数据库备份,DBA可以在同一服务器或其它服务器上建立副本数据库.这个副本数据库可以和主数据库有相同的名称(拷贝)或与主数据库名称不同(克隆). ORACLE在数据库拷贝和数据库克隆之间惟一不同的是拷贝的数据库不能更改名称.使用RMAN的复制数据库特性,可以从RMAN备份创建一个新的数据库,并为这个副本数据库保留已有的数据库名称或者赋予新的名称. RMAN术语和命令: A. 辅助数据库(Auxiliary database):RMAN将目标数据库复制到该数据库实例.要创建该数据库的参数文件

Oracle RMAN高级恢复概述(二) 基于RMAN 的恢复主题

1.只读表空间的恢复 在默认情况下,即使丢失了只读的数据文件,RMAN也不会在执行完全恢复数据库还原操作时还原只读的数据文件. 要在完全恢复期间还原只读的数据文件,就必须在restore 命令中使用check readonly 参数,如: Restore database check readonly; 注意,执行recover tablespace或recover datafile命令时,RMAN的工作情况是不一样的. 使用这两个命令时,不管表空间是否为只读状态都会执行恢复操作. 2.归档重做