标题: RMAN "set newname for database" Does Not Work for Root datafiles [打印本页] 作者: 刘泽宇 时间: 2024-7-21 17:48 标题: RMAN "set newname for database" Does Not Work for Root datafiles 现象:
When restoring a PDB tablespace and using "set newname for database", RMAN tries to restore the Root datafiles to the source database directory. I.e., ignoring the 'set newname for database'. If permission of that source directory is not present, or the directory does not exists, then error will occur.
For example, at source DB, data file is under the following directory:
<PATH_1>
RMAN> report schema;
using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name <pdb name>
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 910 SYSTEM YES <PATH_1>/system01.dbf
3 750 SYSAUX NO <PATH_1>/sysaux01.dbf
4 295 UNDOTBS1 YES <PATH_1>/undotbs01.dbf
5 270 PDB$SEED:SYSTEM NO <PATH_1>/pdbseed/system01.dbf
6 330 PDB$SEED:SYSAUX NO <PATH_1>/pdbseed/sysaux01.dbf
7 5 USERS NO <PATH_1>/users01.dbf
8 100 PDB$SEED:UNDOTBS1 NO <PATH_1>/pdbseed/undotbs01.dbf
9 270 <PDBNAME>:SYSTEM NO <PATH_1>/<PDBNAME>/system01.dbf
10 340 <PDBNAME>:SYSAUX NO <PATH_1>/<PDBNAME>/sysaux01.dbf
11 100 <PDBNAME>:UNDOTBS1 NO <PATH_1>/<PDBNAME>/undotbs01.dbf
12 5 <PDBNAME>:USERS NO <PATH_1>/<PDBNAME>/users01.dbf
13 100 <PDBNAME>:TBS001 NO <PATH_1>/tbs001.dbf
RMAN>
We want to restore to the following directory:
<PATH_2>
run{
allocate channel t1 type disk;
allocate channel t2 type disk;
allocate channel t3 type disk;
allocate channel t4 type disk;
SET UNTIL TIME = "to_date('2021-09-09 23:49:18','YYYY/MM/DD HH24:MI:SS')";
set newname for database root to '<PATH_2>%U';
set newname for database "PDB$SEED" to '<PATH_2>%U';
set newname for tablespace <PDBNAME>:SYSTEM to '<PATH_2>%U';
set newname for tablespace <PDBNAME>:SYSAUX to '<PATH_2>%U';
set newname for tablespace <PDBNAME>:UNDOTBS1 to '<PATH_2>%U';
set newname for tablespace <PDBNAME>:TBS001 to '<PATH_2>%U';
restore database root skip tablespace users database "PDB$SEED" database <PDBNAME> skip tablespace <PDBNAME>:USERS;
switch datafile all;
}
......
Starting restore at 17-SEP-21
channel t1: starting datafile backup set restore
channel t1: specifying datafile(s) to restore from backup set
channel t1: restoring datafile 00001 to <PATH_1>/system01.dbf
channel t1: restoring datafile 00003 to <PATH_1>/sysaux01.dbf
channel t1: restoring datafile 00004 to <PATH_1>/undotbs01.dbf
channel t1: reading from backup piece <BACKUP LOCATION>/db_0108lv6k_1_1
channel t2: starting datafile backup set restore
channel t2: specifying datafile(s) to restore from backup set
channel t2: restoring datafile 00009 to <PATH_2>data_D-<CDBNAME>_TS-SYSTEM_FNO-9
channel t2: restoring datafile 00010 to <PATH_2>data_D-<CDBNAME>_TS-SYSAUX_FNO-10
channel t2: restoring datafile 00011 to <PATH_2>data_D-<CDBNAME_TS-UNDOTBS1_FNO-11
channel t2: restoring datafile 00013 to <PATH_2>data_D-<CDBNAME>_TS-TBS001_FNO-13
channel t2: reading from backup piece <BACKUP LOCATION>/db_0208lv73_1_1
channel t3: starting datafile backup set restore
channel t3: specifying datafile(s) to restore from backup set
channel t3: restoring datafile 00005 to <PATH_2>data_D-<CDBNAME>_TS-SYSTEM_FNO-5
channel t3: restoring datafile 00006 to <PATH_2>data_D-<CDBNAME>_TS-SYSAUX_FNO-6
channel t3: restoring datafile 00008 to <PATH_2>data_D-<CDBNAME>_TS-UNDOTBS1_FNO-8
channel t3: reading from backup piece <BACKUP LOCATION>/db_0308lv7a_1_1
channel t1: ORA-19870: error while restoring backup piece <BACKUP LOCATION>/db_0108lv6k_1_1
ORA-19504: failed to create file "<PATH_1>/system01.dbf" <<<<<<< tried to restore root database file to source DB location
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 13: Permission denied
Additional information: 9
released channel: t1
released channel: t2
released channel: t3
released channel: t4
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 09/17/2021 01:02:00
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore
RMAN>
原因:
The issue was investigated via bug 33388218, closed as "not a bug", this is a usage issue.
处理方法:
The command being used was:
set newname for database root to '<PATH_2>/%U';
It should be:
set newname for database cdb$root to '<PATH_2>/%U';