使用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号。

相关实践学习
通过日志服务实现云资源OSS的安全审计
本实验介绍如何通过日志服务实现云资源OSS的安全审计。
目录
相关文章
|
8天前
|
人工智能 安全 API
CoPaw:5分钟部署你的 AI助理
源自阿里巴巴开源生态的个人 AI 助理——CoPaw。作为阿里倾力打造的开源力作,CoPaw 完美打通钉钉、飞书、Discord 等多平台对话通道,支持定时任务自动化。内置 PDF/Office 深度处理、新闻摘要等强大技能,更开放自定义扩展接口。坚持数据全程私有化部署,绝不上传云端,让每一位用户都能在大厂技术加持下,拥有安全、专属的智能助手。
|
11天前
|
人工智能 自然语言处理 JavaScript
2026年Windows+Ollama本地部署OpenClaw保姆级教程:本地AI Agent+阿里云上快速搭建
2026年OpenClaw凭借本地部署、私有化运行的特性,成为打造个人智能体的核心工具,而Ollama作为轻量级本地大模型管理工具,能让OpenClaw摆脱对云端大模型的依赖,实现**本地推理、数据不泄露、全流程私有化**的智能体验。本文基于Windows 11系统,从硬件环境准备、Ollama安装与模型定制、OpenClaw部署配置、技能扩展到常见问题排查,打造保姆级本地部署教程,同时补充阿里云OpenClaw(Clawdbot)快速部署步骤,兼顾本地私有化需求与云端7×24小时运行需求,文中所有代码命令均可直接复制执行,确保零基础用户也能快速搭建属于自己的本地智能体。
11633 97
|
8天前
|
人工智能 安全 JavaScript
阿里云上+本地部署OpenClaw(小龙虾)新手攻略:解锁10大必备Skills,零基础也能玩转AI助手
2026年,开源AI代理工具OpenClaw(昵称“小龙虾”)凭借“能实际做事”的核心优势,在GitHub斩获25万+星标,成为现象级AI工具。它最强大的魅力在于可扩展的Skills(技能包)系统——通过ClawHub插件市场的数百个技能,能让AI助手从简单聊天升级为处理办公、学习、日常事务的全能帮手。
7646 27
|
6天前
|
人工智能 JavaScript Ubuntu
5分钟上手龙虾AI!OpenClaw部署(阿里云+本地)+ 免费多模型配置保姆级教程(MiniMax、Claude、阿里云百炼)
OpenClaw(昵称“龙虾AI”)作为2026年热门的开源个人AI助手,由PSPDFKit创始人Peter Steinberger开发,核心优势在于“真正执行任务”——不仅能聊天互动,还能自动处理邮件、管理日程、订机票、写代码等,且所有数据本地处理,隐私完全可控。它支持接入MiniMax、Claude、GPT等多类大模型,兼容微信、Telegram、飞书等主流聊天工具,搭配100+可扩展技能,成为兼顾实用性与隐私性的AI工具首选。
5795 11
|
9天前
|
人工智能 自然语言处理 机器人
保姆级教程:Mac本地搭建OpenClaw及阿里云上1分钟部署OpenClaw+飞书集成实战指南
OpenClaw(曾用名Clawdbot、Moltbot)作为2026年最热门的开源个人AI助手平台,以“自然语言驱动自动化”为核心,支持对接飞书、Telegram等主流通讯工具,可替代人工完成文件操作、日历管理、邮件处理等重复性工作。其模块化架构适配多系统环境,既可以在Mac上本地化部署打造私人助手,也能通过阿里云实现7×24小时稳定运行,完美兼顾隐私性与便捷性。
7053 17
|
3天前
|
人工智能 安全 前端开发
Team 版 OpenClaw:HiClaw 开源,5 分钟完成本地安装
HiClaw 基于 OpenClaw、Higress AI Gateway、Element IM 客户端+Tuwunel IM 服务器(均基于 Matrix 实时通信协议)、MinIO 共享文件系统打造。
2986 7
|
4天前
|
人工智能 JavaScript 测试技术
保姆级教程:OpenClaw阿里云及本地部署+Claude Code集成,打造全能 AI 编程助手
在AI编程工具百花齐放的2026年,Anthropic推出的Claude Code凭借72.5%的SWE-bench测试高分、25倍于GitHub Copilot的上下文窗口,成为开发者追捧的智能编程助手。但单一工具仍有局限——Claude Code擅长代码生成与审查,却缺乏灵活的部署与自动化执行能力;而OpenClaw(前身为Clawdbot)作为开源AI代理框架,能完美弥补这一短板,通过云端与本地双部署,实现“代码开发-测试-部署”全流程自动化。
2164 13
|
11天前
|
人工智能 JSON JavaScript
手把手教你用 OpenClaw + 飞书,打造专属 AI 机器人
手把手教你用 OpenClaw(v2026.2.22-2)+ 飞书,10分钟零代码搭建专属AI机器人!内置飞书插件,无需额外安装;支持Claude等主流模型,命令行一键配置。告别复杂开发,像聊同事一样自然对话。
6822 17
手把手教你用 OpenClaw + 飞书,打造专属 AI 机器人
|
4天前
|
人工智能 JSON API
保姆级教程:OpenClaw阿里云及本地部署+模型切换流程+GLM5.0/Seedance2.0/MiniMax M2.5接入指南
2026年,GLM5.0、Seedance2.0、MiniMax M2.5等旗舰大模型相继发布,凭借出色的性能与极具竞争力的成本优势,成为AI工具的热门选择。OpenClaw作为灵活的AI Agent平台,支持无缝接入这些主流模型,通过简单配置即可实现“永久切换、快速切换、主备切换”三种模式,让不同场景下的任务执行更高效、更稳定。
2524 2

热门文章

最新文章