当前位置:  数据库>oracle

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

    来源: 互联网  发布时间:2017-06-22

    本文导语: 最近为了不影响开发库的使用,打算复制创建一个备库,定时更新,防止开发库不能使用的情况下,可以临时使用备库,不影响进度。 环境: 11.2.0.4的单实例库。 库1是源库(target),库2是备库(auxiliary) 操作过程: 1.库1执行全库...

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

环境:
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号。


    
 
 

您可能感兴趣的文章:

  • linux 下两个硬盘进行复制,用DD该如何使用????
  • 使用正则表达式复制问题:cp
  • jquery使用jquery.zclip插件复制对象的实例教程
  • 在linux下使用C开发,需要使用什么样的开发环境呀? iis7站长之家
  • java实现在复制文件时使用进度条(java实现进度条)
  • 使用Rotate Master实现MySQL 多主复制的实现方法
  • 如何强制删除或恢复SQLServer正在使用的数据库
  • 原来装了linux和win2k,使用LiLO启动,现在重新win2k,如何恢复使用LILO来引导使得Linux可用
  • 请问:使用fdisk/mbr清除bios中登陆选择菜单后,如何恢复?或重设
  • 在线等。。。使用压力测试工具进行测试有时出现httpd子进程CPU占用率100%,且压力撤除后无法恢复
  • Solaris桌面的程序控制面板中的一项被我使用右键菜单中的Move left/Move right移走了, 出不来了,怎么恢复啊?
  • oracle冷备份恢复和oracle异机恢复使用方法
  • 如何恢复数据库备份到一个已存在的正在使用的数据库上
  • MYSQL使用.frm恢复数据表结构的实现方法
  • 解析Mysql备份与恢复简单总结与tee命令的使用介绍
  • MySQL数据库恢复(使用mysqlbinlog命令)
  • MySQL数据库InnoDB数据恢复工具的使用小结详解
  •  
    本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
    本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • 求教: Linux环境下有没有类似VC++那样的、比较容易使用的集成开发环境?
  • 在linux下使用C开发,需要使用什么样的开发环境呀?
  • JSP开发环境和运行环境的配置和使用方法,以SUN JDK为例
  • 在使用gcc之前,需要先设置环境吗?如何设置?在线等!!!
  • 驱动编译环境的内核版本到底是不是必须和使用环境的内核版本一致?
  • 请教:使用什么命令查看导出的环境变量?
  • 请问使用crontab是否必须设置环境变量?
  • telnet环境下,退格键的使用问题
  • 请教linux英文环境下使用中文输入法
  • 有没有方法可以使用脚本批量修改bash环境变量
  • 在LINUX环境下,怎样限定SendMail邮件服务器中邮件用户使用邮件空间的大小。。。。。。
  • [请问]如果在sed命令使用环境变量
  • 各位大侠,请推荐几本在UNIX环境下使用标准C语言编程的好书.谢谢啊!!!
  • Linux环境如何使用拨号17201上网,谢谢
  • 如何使用shell文件实现linux环境下的挂载功能,具体代码!!
  • 一个完整的JSP开发/使用环境需要什么组件?
  • 请问有没有在Windows环境下使用的Emacs和Vi版本下载?
  • linux 下设置环境变量 使用了setenv 和putenv 在程序结束以后 发现变量又变回去了
  • 使用JavaScript实现的Flash运行环境 Gordon
  • snmp的使用环境
  • C++ I/O 成员 tellg():使用输入流读取流指针
  • 在测试memset函数的执行效率时,分为使用Cash和不使用Cash辆种方式,该如何控制是否使用缓存?
  • C++ I/O 成员 tellp():使用输出流读取流指针
  • 求ibm6000的中文使用手册 !从来没用过服务器,现在急需使用它,不知如何使用! 急!!!!!
  • Python不使用print而直接输出二进制字符串
  • 请问:在使用oracle数据库作开发时,是使用pro*c作开发好些,还是使用库函数如oci等好一些啊?或者它们有什么区别或者优缺点啊?
  • Office 2010 Module模式下使用VBA Addressof
  • 急求结果!!假设一个有两个元素的信号量集S,表示了一个磁带驱动器系统,其中进程1使用磁带机A,进程2同时使用磁带机A和B,进程3使用磁带机B。
  • windows下tinyxml.dll下载安装使用(c++解析XML库)
  • c#中SAPI使用总结——SpVoice的使用方法
  • tcmalloc内存泄露优化c++开源库下载,安装及使用介绍


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3