ORACLE 19c 统一恢复处于ASM中的CDB含PDB数据文件到某一个文件目录下面

本文主要是介绍ORACLE 19c 统一恢复处于ASM中的CDB含PDB数据文件到某一个文件目录下面,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

NOCDB情况下,要把ASM中的文件恢复到文件系统,大家都知道分别设置每个文件的路径即可,但如果是租户环境,每个PDB都有不同路径,而且每个PDB都有SYSTEM,SYSAUX等一些表空降,不可能放在同一个目录中,而是放在不同的目录,那恢复时,怎么设置呢 ?

比如下面数据库以在本地恢复为例,如果是异机恢复,步骤类似:

SYS@orclcdb> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ORCLPDB                        READ WRITE NO

ORCLCDB,有一个PDB,ORCLPDB,一个PDBSEED,数据文件放在ASM磁盘组DATA中,想整体恢复到文件系统,比如 /u01/app/oracle/oradata/orclcdb/

RMAN> report schema;

Report of database schema for database with db_unique_name ORCLCDB

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    1700     SYSTEM               ***     +DATA/ORCLCDB/DATAFILE/system.257.1140286827
3    1024     SYSAUX               ***     +DATA/ORCLCDB/DATAFILE/sysaux.258.1140286963
4    1500     UNDOTBS1             ***     +DATA/ORCLCDB/DATAFILE/undotbs1.259.1140287029
5    540      PDB$SEED:SYSTEM      ***     +DATA/ORCLCDB/86B637B62FE07A65E053F706E80A27CA/DATAFILE/system.266.1140289995
6    430      PDB$SEED:SYSAUX      ***     +DATA/ORCLCDB/86B637B62FE07A65E053F706E80A27CA/DATAFILE/sysaux.267.1140289995
7    5        USERS                ***     +DATA/ORCLCDB/DATAFILE/users.260.1140287029
8    215      PDB$SEED:UNDOTBS1    ***     +DATA/ORCLCDB/86B637B62FE07A65E053F706E80A27CA/DATAFILE/undotbs1.268.1140289995
9    550      ORCLPDB:SYSTEM       ***     +DATA/ORCLCDB/FECB9F1537517278E0537885A8C0E7DC/DATAFILE/system.272.1140292289
10   500      ORCLPDB:SYSAUX       ***     +DATA/ORCLCDB/FECB9F1537517278E0537885A8C0E7DC/DATAFILE/sysaux.273.1140292289
11   215      ORCLPDB:UNDOTBS1     ***     +DATA/ORCLCDB/FECB9F1537517278E0537885A8C0E7DC/DATAFILE/undotbs1.271.1140292289
12   15       ORCLPDB:USERS        ***     +DATA/ORCLCDB/FECB9F1537517278E0537885A8C0E7DC/DATAFILE/users.275.1140292305

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    500      TEMP                 32767       +DATA/ORCLCDB/TEMPFILE/temp.265.1140287089
2    138      PDB$SEED:TEMP        32767       +DATA/ORCLCDB/FECB1A5B8C146A75E0537885A8C0F418/TEMPFILE/temp.269.1140290063
3    139      ORCLPDB:TEMP         32767       +DATA/ORCLCDB/FECB9F1537517278E0537885A8C0E7DC/TEMPFILE/temp.274.1140292293


步骤如下:
 

1.备份


  rman >backup database plus archivelog;


2.关闭数据库


  sql>shutdown immediate;


3.恢复到文件系统


  RMAN>
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
set newname for database "cdb$root" to '/u01/app/oracle/oradata/ORCLCDB/%b';
set newname for database "PDB$SEED" to '/u01/app/oracle/oradata/ORCLCDB/pdbseed/%b';
set newname for database "ORCLPDB" to '/u01/app/oracle/oradata/ORCLCDB/orclpdb/%b';
restore database root database "PDB$SEED" DATABASE "ORCLPDB";
switch datafile all;
switch tempfile all;
recover database;
}
需要注意的是:这里不同的PDB,要对应到不同的目录,需要单独指定PDB,而且,cdb$root要单独指定。

allocated channel: c1
channel c1: SID=613 device type=DISK

allocated channel: c2
channel c2: SID=11 device type=DISK

allocated channel: c3
channel c3: SID=213 device type=DISK

allocated channel: c4
channel c4: SID=414 device type=DISK

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 19-AUG-23

channel c2: starting datafile backup set restore
channel c2: specifying datafile(s) to restore from backup set
channel c2: restoring datafile 00001 to /u01/app/oracle/oradata/ORCLCDB/system.257.1140286827
channel c2: restoring datafile 00003 to /u01/app/oracle/oradata/ORCLCDB/sysaux.258.1140286963
channel c2: restoring datafile 00004 to /u01/app/oracle/oradata/ORCLCDB/undotbs1.259.1140287029
channel c2: restoring datafile 00007 to /u01/app/oracle/oradata/ORCLCDB/users.260.1140287029
channel c2: reading from backup piece +FRA/ORCLCDB/BACKUPSET/2023_08_19/nnndf0_tag20230819t170606_0.291.1145293567
channel c3: starting datafile backup set restore
channel c3: specifying datafile(s) to restore from backup set
channel c3: restoring datafile 00009 to /u01/app/oracle/oradata/ORCLCDB/orclpdb/system.272.1140292289
channel c3: restoring datafile 00010 to /u01/app/oracle/oradata/ORCLCDB/orclpdb/sysaux.273.1140292289
channel c3: restoring datafile 00011 to /u01/app/oracle/oradata/ORCLCDB/orclpdb/undotbs1.271.1140292289
channel c3: restoring datafile 00012 to /u01/app/oracle/oradata/ORCLCDB/orclpdb/users.275.1140292305
channel c3: reading from backup piece +FRA/ORCLCDB/FECB9F1537517278E0537885A8C0E7DC/BACKUPSET/2023_08_19/nnndf0_tag20230819t170606_0.290.1145293671
channel c1: restoring datafile 00005
input datafile copy RECID=22 STAMP=1144754940 file name=+FRA/ORCLCDB/FECB1A5B8C146A75E0537885A8C0F418/DATAFILE/system.260.1144754939
destination for restore of datafile 00005: /u01/app/oracle/oradata/ORCLCDB/pdbseed/system.266.1140289995
channel c4: restoring datafile 00006
input datafile copy RECID=24 STAMP=1144754946 file name=+FRA/ORCLCDB/FECB1A5B8C146A75E0537885A8C0F418/DATAFILE/sysaux.259.1144754945
destination for restore of datafile 00006: /u01/app/oracle/oradata/ORCLCDB/pdbseed/sysaux.267.1140289995
channel c4: copied datafile copy of datafile 00006, elapsed time: 00:00:45
output file name=/u01/app/oracle/oradata/ORCLCDB/pdbseed/sysaux.267.1140289995 RECID=34 STAMP=1145295053
channel c4: restoring datafile 00008
input datafile copy RECID=25 STAMP=1144754949 file name=+FRA/ORCLCDB/FECB1A5B8C146A75E0537885A8C0F418/DATAFILE/undotbs1.268.1144754949
destination for restore of datafile 00008: /u01/app/oracle/oradata/ORCLCDB/pdbseed/undotbs1.268.1140289995
channel c1: copied datafile copy of datafile 00005, elapsed time: 00:01:00
output file name=/u01/app/oracle/oradata/ORCLCDB/pdbseed/system.266.1140289995 RECID=36 STAMP=1145295065
channel c3: piece handle=+FRA/ORCLCDB/FECB9F1537517278E0537885A8C0E7DC/BACKUPSET/2023_08_19/nnndf0_tag20230819t170606_0.290.1145293671 tag=TAG20230819T170606
channel c3: restored backup piece 1
channel c3: restore complete, elapsed time: 00:01:00
channel c4: copied datafile copy of datafile 00008, elapsed time: 00:00:15
output file name=/u01/app/oracle/oradata/ORCLCDB/pdbseed/undotbs1.268.1140289995 RECID=38 STAMP=1145295072
channel c2: piece handle=+FRA/ORCLCDB/BACKUPSET/2023_08_19/nnndf0_tag20230819t170606_0.291.1145293567 tag=TAG20230819T170606
channel c2: restored backup piece 1
channel c2: restore complete, elapsed time: 00:01:41
Finished restore at 19-AUG-23

datafile 1 switched to datafile copy
input datafile copy RECID=41 STAMP=1145295112 file name=/u01/app/oracle/oradata/ORCLCDB/system.257.1140286827
datafile 3 switched to datafile copy
input datafile copy RECID=42 STAMP=1145295112 file name=/u01/app/oracle/oradata/ORCLCDB/sysaux.258.1140286963
datafile 4 switched to datafile copy
input datafile copy RECID=43 STAMP=1145295112 file name=/u01/app/oracle/oradata/ORCLCDB/undotbs1.259.1140287029
datafile 7 switched to datafile copy
input datafile copy RECID=44 STAMP=1145295112 file name=/u01/app/oracle/oradata/ORCLCDB/users.260.1140287029
datafile 5 switched to datafile copy
input datafile copy RECID=45 STAMP=1145295112 file name=/u01/app/oracle/oradata/ORCLCDB/pdbseed/system.266.1140289995
datafile 6 switched to datafile copy
input datafile copy RECID=46 STAMP=1145295113 file name=/u01/app/oracle/oradata/ORCLCDB/pdbseed/sysaux.267.1140289995
datafile 8 switched to datafile copy
input datafile copy RECID=47 STAMP=1145295113 file name=/u01/app/oracle/oradata/ORCLCDB/pdbseed/undotbs1.268.1140289995
datafile 9 switched to datafile copy
input datafile copy RECID=48 STAMP=1145295113 file name=/u01/app/oracle/oradata/ORCLCDB/orclpdb/system.272.1140292289
datafile 10 switched to datafile copy
input datafile copy RECID=49 STAMP=1145295113 file name=/u01/app/oracle/oradata/ORCLCDB/orclpdb/sysaux.273.1140292289
datafile 11 switched to datafile copy
input datafile copy RECID=50 STAMP=1145295113 file name=/u01/app/oracle/oradata/ORCLCDB/orclpdb/undotbs1.271.1140292289
datafile 12 switched to datafile copy
input datafile copy RECID=51 STAMP=1145295113 file name=/u01/app/oracle/oradata/ORCLCDB/orclpdb/users.275.1140292305


Starting recover at 19-AUG-23

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

Finished recover at 19-AUG-23
released channel: c1
released channel: c2
released channel: c3
released channel: c4


4.打开数据库


RMAN> alter database open;



5.验证数据库数据文件


SYS@orclcdb> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/ORCLCDB/system.257.1140286827
/u01/app/oracle/oradata/ORCLCDB/sysaux.258.1140286963
/u01/app/oracle/oradata/ORCLCDB/undotbs1.259.1140287029
/u01/app/oracle/oradata/ORCLCDB/pdbseed/system.266.1140289995
/u01/app/oracle/oradata/ORCLCDB/pdbseed/sysaux.267.1140289995
/u01/app/oracle/oradata/ORCLCDB/users.260.1140287029
/u01/app/oracle/oradata/ORCLCDB/pdbseed/undotbs1.268.1140289995
/u01/app/oracle/oradata/ORCLCDB/orclpdb/system.272.1140292289
/u01/app/oracle/oradata/ORCLCDB/orclpdb/sysaux.273.1140292289
/u01/app/oracle/oradata/ORCLCDB/orclpdb/undotbs1.271.1140292289
/u01/app/oracle/oradata/ORCLCDB/orclpdb/users.275.1140292305


6. 临时文件及其他文件的处理

可以参照这个处理:
http://bbs.cqsztech.com/forum.ph ... hlight=%D2%EC%BB%FA


附录:
     mos:

Doc ID 2818346.1

这篇关于ORACLE 19c 统一恢复处于ASM中的CDB含PDB数据文件到某一个文件目录下面的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



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

相关文章

Python MySQL如何通过Binlog获取变更记录恢复数据

《PythonMySQL如何通过Binlog获取变更记录恢复数据》本文介绍了如何使用Python和pymysqlreplication库通过MySQL的二进制日志(Binlog)获取数据库的变更记录... 目录python mysql通过Binlog获取变更记录恢复数据1.安装pymysqlreplicat

Oracle数据库使用 listagg去重删除重复数据的方法汇总

《Oracle数据库使用listagg去重删除重复数据的方法汇总》文章介绍了在Oracle数据库中使用LISTAGG和XMLAGG函数进行字符串聚合并去重的方法,包括去重聚合、使用XML解析和CLO... 目录案例表第一种:使用wm_concat() + distinct去重聚合第二种:使用listagg,

oracle中exists和not exists用法举例详解

《oracle中exists和notexists用法举例详解》:本文主要介绍oracle中exists和notexists用法的相关资料,EXISTS用于检测子查询是否返回任何行,而NOTE... 目录基本概念:举例语法pub_name总结 exists (sql 返回结果集为真)not exists (s

Oracle的to_date()函数详解

《Oracle的to_date()函数详解》Oracle的to_date()函数用于日期格式转换,需要注意Oracle中不区分大小写的MM和mm格式代码,应使用mi代替分钟,此外,Oracle还支持毫... 目录oracle的to_date()函数一.在使用Oracle的to_date函数来做日期转换二.日

oracle数据库索引失效的问题及解决

《oracle数据库索引失效的问题及解决》本文总结了在Oracle数据库中索引失效的一些常见场景,包括使用isnull、isnotnull、!=、、、函数处理、like前置%查询以及范围索引和等值索引... 目录oracle数据库索引失效问题场景环境索引失效情况及验证结论一结论二结论三结论四结论五总结ora

Oracle Expdp按条件导出指定表数据的方法实例

《OracleExpdp按条件导出指定表数据的方法实例》:本文主要介绍Oracle的expdp数据泵方式导出特定机构和时间范围的数据,并通过parfile文件进行条件限制和配置,文中通过代码介绍... 目录1.场景描述 2.方案分析3.实验验证 3.1 parfile文件3.2 expdp命令导出4.总结

Oracle数据库执行计划的查看与分析技巧

《Oracle数据库执行计划的查看与分析技巧》在Oracle数据库中,执行计划能够帮助我们深入了解SQL语句在数据库内部的执行细节,进而优化查询性能、提升系统效率,执行计划是Oracle数据库优化器为... 目录一、什么是执行计划二、查看执行计划的方法(一)使用 EXPLAIN PLAN 命令(二)通过 S

使用SecondaryNameNode恢复NameNode的数据

1)需求: NameNode进程挂了并且存储的数据也丢失了,如何恢复NameNode 此种方式恢复的数据可能存在小部分数据的丢失。 2)故障模拟 (1)kill -9 NameNode进程 [lytfly@hadoop102 current]$ kill -9 19886 (2)删除NameNode存储的数据(/opt/module/hadoop-3.1.4/data/tmp/dfs/na

电脑桌面文件删除了怎么找回来?别急,快速恢复攻略在此

在日常使用电脑的过程中,我们经常会遇到这样的情况:一不小心,桌面上的某个重要文件被删除了。这时,大多数人可能会感到惊慌失措,不知所措。 其实,不必过于担心,因为有很多方法可以帮助我们找回被删除的桌面文件。下面,就让我们一起来了解一下这些恢复桌面文件的方法吧。 一、使用撤销操作 如果我们刚刚删除了桌面上的文件,并且还没有进行其他操作,那么可以尝试使用撤销操作来恢复文件。在键盘上同时按下“C

Oracle type (自定义类型的使用)

oracle - type   type定义: oracle中自定义数据类型 oracle中有基本的数据类型,如number,varchar2,date,numeric,float....但有时候我们需要特殊的格式, 如将name定义为(firstname,lastname)的形式,我们想把这个作为一个表的一列看待,这时候就要我们自己定义一个数据类型 格式 :create or repla