Oracle Incomplete数据库恢复: 使用restore point

2024-02-04 13:18

本文主要是介绍Oracle Incomplete数据库恢复: 使用restore point,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

环境: Oracle数据库12.2.0.1,CDB=orclcdb,PDB=orclpdb1

You can’t perform an incomplete database recovery on a subset of your database’s online data files

首先全备数据库:

RMAN> backup database plus archivelog;Starting backup at 25-APR-19
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=258 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=6 RECID=23 STAMP=1006429277
input archived log thread=1 sequence=7 RECID=24 STAMP=1006530361
input archived log thread=1 sequence=8 RECID=25 STAMP=1006530370
input archived log thread=1 sequence=9 RECID=26 STAMP=1006531303
channel ORA_DISK_1: starting piece 1 at 25-APR-19
channel ORA_DISK_1: finished piece 1 at 25-APR-19
piece handle=/u01/fra/ORCLCDB/backupset/2019_04_25/o1_mf_annnn_TAG20190425T160144_gd2tc8t7_.bkp tag=TAG20190425T160144 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-APR-19Starting backup at 25-APR-19
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/opt/oracle/oradata/ORCLCDB/system01.dbf
input datafile file number=00003 name=/opt/oracle/oradata/ORCLCDB/sysaux01.dbf
input datafile file number=00004 name=/opt/oracle/oradata/ORCLCDB/undotbs01.dbf
input datafile file number=00007 name=/opt/oracle/oradata/ORCLCDB/users01.dbf
channel ORA_DISK_1: starting piece 1 at 25-APR-19
channel ORA_DISK_1: finished piece 1 at 25-APR-19
piece handle=/u01/fra/ORCLCDB/backupset/2019_04_25/o1_mf_nnndf_TAG20190425T160146_gd2tcbc7_.bkp tag=TAG20190425T160146 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00010 name=/opt/oracle/oradata/ORCLCDB/ORCLPDB1/sysaux01.dbf
input datafile file number=00009 name=/opt/oracle/oradata/ORCLCDB/ORCLPDB1/system01.dbf
input datafile file number=00011 name=/opt/oracle/oradata/ORCLCDB/ORCLPDB1/undotbs01.dbf
input datafile file number=00012 name=/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 25-APR-19
channel ORA_DISK_1: finished piece 1 at 25-APR-19
piece handle=/u01/fra/ORCLCDB/85ED2A1B333E762BE0530100007F0333/backupset/2019_04_25/o1_mf_nnndf_TAG20190425T160146_gd2tcsnt_.bkp tag=TAG20190425T160146 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/opt/oracle/oradata/ORCLCDB/pdbseed/sysaux01.dbf
input datafile file number=00005 name=/opt/oracle/oradata/ORCLCDB/pdbseed/system01.dbf
input datafile file number=00008 name=/opt/oracle/oradata/ORCLCDB/pdbseed/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 25-APR-19
channel ORA_DISK_1: finished piece 1 at 25-APR-19
piece handle=/u01/fra/ORCLCDB/85ED1CD129746EA8E0530100007FAF27/backupset/2019_04_25/o1_mf_nnndf_TAG20190425T160146_gd2tcwz4_.bkp tag=TAG20190425T160146 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 25-APR-19Starting backup at 25-APR-19
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=10 RECID=27 STAMP=1006531328
channel ORA_DISK_1: starting piece 1 at 25-APR-19
channel ORA_DISK_1: finished piece 1 at 25-APR-19
piece handle=/u01/fra/ORCLCDB/backupset/2019_04_25/o1_mf_annnn_TAG20190425T160208_gd2td0ho_.bkp tag=TAG20190425T160208 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-APR-19Starting Control File and SPFILE Autobackup at 25-APR-19
piece handle=/u01/fra/ORCLCDB/autobackup/2019_04_25/o1_mf_s_1006531329_gd2td290_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 25-APR-19

然后创建恢复点:

RMAN> create restore point MY_RP;Statement processedRMAN> select current_scn from v$database;CURRENT_SCN
-----------2470073RMAN> select name, scn from v$restore_point;NAME
--------------------------------------------------------------------------------SCN
----------MY_RP2470052

插入一条新数据:

SQL> alter session set container=orclpdb1;Session altered.SQL> select * from foo;FOO
----------12SQL> insert into foo values(3);1 row created.SQL> commit;Commit complete.

进行恢复:

RMAN> shutdown immediate;database closed
database dismounted
Oracle instance shut downRMAN> startup mount;connected to target database (not started)
Oracle instance started
database mountedTotal System Global Area    1207959552 bytesFixed Size                     8792152 bytes
Variable Size                436209576 bytes
Database Buffers             754974720 bytes
Redo Buffers                   7983104 bytesRMAN> restore database until restore point MY_RP;Starting restore at 25-APR-19
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=255 device type=DISKskipping datafile 5; already restored to file /opt/oracle/oradata/ORCLCDB/pdbseed/system01.dbf
skipping datafile 6; already restored to file /opt/oracle/oradata/ORCLCDB/pdbseed/sysaux01.dbf
skipping datafile 8; already restored to file /opt/oracle/oradata/ORCLCDB/pdbseed/undotbs01.dbf
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 /opt/oracle/oradata/ORCLCDB/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /opt/oracle/oradata/ORCLCDB/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /opt/oracle/oradata/ORCLCDB/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00007 to /opt/oracle/oradata/ORCLCDB/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/fra/ORCLCDB/backupset/2019_04_25/o1_mf_nnndf_TAG20190425T160146_gd2tcbc7_.bkp
channel ORA_DISK_1: piece handle=/u01/fra/ORCLCDB/backupset/2019_04_25/o1_mf_nnndf_TAG20190425T160146_gd2tcbc7_.bkp tag=TAG20190425T160146
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
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 00009 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/system01.dbf
channel ORA_DISK_1: restoring datafile 00010 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00011 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00012 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/fra/ORCLCDB/85ED2A1B333E762BE0530100007F0333/backupset/2019_04_25/o1_mf_nnndf_TAG20190425T160146_gd2tcsnt_.bkp
channel ORA_DISK_1: piece handle=/u01/fra/ORCLCDB/85ED2A1B333E762BE0530100007F0333/backupset/2019_04_25/o1_mf_nnndf_TAG20190425T160146_gd2tcsnt_.bkp tag=TAG20190425T160146
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 25-APR-19RMAN> recover database until restore point MY_RP;Starting recover at 25-APR-19
using channel ORA_DISK_1starting media recovery
media recovery complete, elapsed time: 00:00:01Finished recover at 25-APR-19RMAN> alter database open resetlogs;Statement processedRMAN> alter session set container=orclpdb1;RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 04/25/2019 16:10:50
RMAN-06815: cannot change the container in RMAN session.

验证时间点恢复成功:

SQL> alter session set container=orclpdb1;Session altered.SQL> select * from foo;FOO
----------12

再做一次,这次在PDB中建立restore point:

SQL> show con_name;CON_NAME
------------------------------
ORCLPDB1
SQL> create restore point MY_RP;Restore point created.SQL> insert into foo values(3);1 row created.SQL> select * from foo;FOO
----------312SQL> select current_scn from v$database;CURRENT_SCN
-----------2471694SQL> select name, scn from v$restore_point;NAME
--------------------------------------------------------------------------------SCN
----------
MY_RP2470052MY_RP2471498

目前为止,我们有两个restore point了:

select * from v$restore_point;

以下为输出:在这里插入图片描述
开始恢复,注意是直接连接到PDB:

[oracle@oracle-12201-vagrant ~]$ rman target sys/Abcdef_123456@orclpdb1Recovery Manager: Release 12.2.0.1.0 - Production on Thu Apr 25 16:27:08 2019Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.connected to target database: ORCLCDB:ORCLPDB1 (DBID=2352397633)RMAN> shutdown immediate;using target database control file instead of recovery catalog
database closedRMAN> startup mount;RMAN> restore database until restore point MY_RP;Starting restore at 25-APR-19
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 device type=DISKchannel 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 00009 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/system01.dbf
channel ORA_DISK_1: restoring datafile 00010 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00011 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00012 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/fra/ORCLCDB/85ED2A1B333E762BE0530100007F0333/backupset/2019_04_25/o1_mf_nnndf_TAG20190425T160146_gd2tcsnt_.bkp
channel ORA_DISK_1: piece handle=/u01/fra/ORCLCDB/85ED2A1B333E762BE0530100007F0333/backupset/2019_04_25/o1_mf_nnndf_TAG20190425T160146_gd2tcsnt_.bkp tag=TAG20190425T160146
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
Finished restore at 25-APR-19RMAN> recover database until restore point MY_RP;Starting recover at 25-APR-19
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 04/25/2019 16:28:48
RMAN-07536: command not allowed when connected to a Pluggable Database

restore成功了,但recover失败。因为不允许在PDB中执行。
只好重新连接到根容器,此时recover成功:

[oracle@oracle-12201-vagrant ~]$ rlwrap rman target /Recovery Manager: Release 12.2.0.1.0 - Production on Thu Apr 25 16:32:22 2019Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.connected to target database: ORCLCDB (DBID=2776037359)RMAN> recover pluggable database orclpdb1 until restore point MY_RP;Starting recover at 25-APR-19
using target database control file instead of recovery catalog
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISKstarting media recoveryarchived log for thread 1 with sequence 10 is already on disk as file /u01/fra/ORCLCDB/archivelog/2019_04_25/o1_mf_1_10_gd2td039_.arc
archived log for thread 1 with sequence 11 is already on disk as file /u01/fra/ORCLCDB/archivelog/2019_04_25/o1_mf_1_11_gd2tvbq3_.arc
archived log for thread 1 with sequence 1 is already on disk as file /u01/fra/ORCLCDB/archivelog/2019_04_25/o1_mf_1_1_gd2w5nsx_.arc
media recovery complete, elapsed time: 00:00:00
Finished recover at 25-APR-19

然后打开PDB:

RMAN> alter pluggable database orclpdb1 open resetlogs;Statement processed

验证恢复成功:

SQL> alter session set container=orclpdb1;Session altered.SQL> select * from foo;FOO
----------12

新插入的数据3缺省不见了。

实验结论为:

  1. 可以为每一个数据库,包括CDB和PDB创建各自的restore point
  2. 可以为单独的数据库进行incomplete恢复

这篇关于Oracle Incomplete数据库恢复: 使用restore point的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/677631

相关文章

如何使用 Python 读取 Excel 数据

《如何使用Python读取Excel数据》:本文主要介绍使用Python读取Excel数据的详细教程,通过pandas和openpyxl,你可以轻松读取Excel文件,并进行各种数据处理操... 目录使用 python 读取 Excel 数据的详细教程1. 安装必要的依赖2. 读取 Excel 文件3. 读

解决Maven项目idea找不到本地仓库jar包问题以及使用mvn install:install-file

《解决Maven项目idea找不到本地仓库jar包问题以及使用mvninstall:install-file》:本文主要介绍解决Maven项目idea找不到本地仓库jar包问题以及使用mvnin... 目录Maven项目idea找不到本地仓库jar包以及使用mvn install:install-file基

Python使用getopt处理命令行参数示例解析(最佳实践)

《Python使用getopt处理命令行参数示例解析(最佳实践)》getopt模块是Python标准库中一个简单但强大的命令行参数处理工具,它特别适合那些需要快速实现基本命令行参数解析的场景,或者需要... 目录为什么需要处理命令行参数?getopt模块基础实际应用示例与其他参数处理方式的比较常见问http

C 语言中enum枚举的定义和使用小结

《C语言中enum枚举的定义和使用小结》在C语言里,enum(枚举)是一种用户自定义的数据类型,它能够让你创建一组具名的整数常量,下面我会从定义、使用、特性等方面详细介绍enum,感兴趣的朋友一起看... 目录1、引言2、基本定义3、定义枚举变量4、自定义枚举常量的值5、枚举与switch语句结合使用6、枚

使用Python从PPT文档中提取图片和图片信息(如坐标、宽度和高度等)

《使用Python从PPT文档中提取图片和图片信息(如坐标、宽度和高度等)》PPT是一种高效的信息展示工具,广泛应用于教育、商务和设计等多个领域,PPT文档中常常包含丰富的图片内容,这些图片不仅提升了... 目录一、引言二、环境与工具三、python 提取PPT背景图片3.1 提取幻灯片背景图片3.2 提取

使用Python实现图像LBP特征提取的操作方法

《使用Python实现图像LBP特征提取的操作方法》LBP特征叫做局部二值模式,常用于纹理特征提取,并在纹理分类中具有较强的区分能力,本文给大家介绍了如何使用Python实现图像LBP特征提取的操作方... 目录一、LBP特征介绍二、LBP特征描述三、一些改进版本的LBP1.圆形LBP算子2.旋转不变的LB

Maven的使用和配置国内源的保姆级教程

《Maven的使用和配置国内源的保姆级教程》Maven是⼀个项目管理工具,基于POM(ProjectObjectModel,项目对象模型)的概念,Maven可以通过一小段描述信息来管理项目的构建,报告... 目录1. 什么是Maven?2.创建⼀个Maven项目3.Maven 核心功能4.使用Maven H

Python中__init__方法使用的深度解析

《Python中__init__方法使用的深度解析》在Python的面向对象编程(OOP)体系中,__init__方法如同建造房屋时的奠基仪式——它定义了对象诞生时的初始状态,下面我们就来深入了解下_... 目录一、__init__的基因图谱二、初始化过程的魔法时刻继承链中的初始化顺序self参数的奥秘默认

SpringBoot使用GZIP压缩反回数据问题

《SpringBoot使用GZIP压缩反回数据问题》:本文主要介绍SpringBoot使用GZIP压缩反回数据问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录SpringBoot使用GZIP压缩反回数据1、初识gzip2、gzip是什么,可以干什么?3、Spr

Spring Boot 集成 Quartz并使用Cron 表达式实现定时任务

《SpringBoot集成Quartz并使用Cron表达式实现定时任务》本篇文章介绍了如何在SpringBoot中集成Quartz进行定时任务调度,并通过Cron表达式控制任务... 目录前言1. 添加 Quartz 依赖2. 创建 Quartz 任务3. 配置 Quartz 任务调度4. 启动 Sprin