之前寫了一篇多租戶pdb的文件被rm了和被drop了該如何恢復呢?
這個是對整個數據庫實例都做了備份的情況,也就是說既備份了root根容器又備份了pdb1庫。不論是rm還是drop恢復起來都沒問題,很方便。
文章最后留的思考:如果沒有全庫備份,僅僅只有租戶pdb2的備份,上述兩種情況都還能恢復嗎???
如下以pdb1為例子,模擬rm和drop的場景恢復測試:
即rman備份只做了租戶庫pdb1的備份,根本沒有做過根容器的備份,也就是說只有pdb1租戶庫的備份,看是否也能方便恢復?
答案是:都可以恢復,rm恢復和之前一樣,但對于drop的恢復命令步驟則不同
1.對于rm,直接restore+recover即可
2.對于drop,需要restore+xml+create
更多結論請繼續看到最后。。。。。。
備份:
[oracle@oracle pdb1]$ pwd
/data/u01/app/oracle/oradata/JYC/pdb1
[oracle@oracle pdb1]$ ll
total 752992
-rw-r----- 1 oracle oinstall 367009792 Aug 22 13:17 sysaux01.dbf
-rw-r----- 1 oracle oinstall 293609472 Aug 22 13:17 system01.dbf
-rw-r----- 1 oracle oinstall 134225920 Aug 22 13:02 temp01.dbf
-rw-r----- 1 oracle oinstall 104865792 Aug 22 13:16 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Aug 22 03:05 users01.dbf
[oracle@oracle pdb1]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Fri Aug 22 13:21:11 2025
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: JYC (DBID=187041746)
RMAN> delete noprompt backup;
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1578 device type=DISK
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
14 14 1 1 AVAILABLE DISK /data/u01/app/oracle/flash_recovery_area/JYC/3CB4CD2155D04C02E06310CFA8C0A781/backupset/2025_08_22/o1_mf_nnndf_TAG20250822T131810_nbhzdlwn_.bkp
15 15 1 1 AVAILABLE DISK /data/u01/app/oracle/flash_recovery_area/JYC/autobackup/2025_08_22/o1_mf_s_1209820698_nbhzdt46_.bkp
deleted backup piece
backup piece handle=/data/u01/app/oracle/flash_recovery_area/JYC/3CB4CD2155D04C02E06310CFA8C0A781/backupset/2025_08_22/o1_mf_nnndf_TAG20250822T131810_nbhzdlwn_.bkp RECID=14 STAMP=1209820690
deleted backup piece
backup piece handle=/data/u01/app/oracle/flash_recovery_area/JYC/autobackup/2025_08_22/o1_mf_s_1209820698_nbhzdt46_.bkp RECID=15 STAMP=1209820698
Deleted 2 objects
RMAN> delete noprompt copy;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1578 device type=DISK
specification does not match any datafile copy in the repository
specification does not match any control file copy in the repository
specification does not match any archived log in the repository
RMAN> list backup;
specification does not match any backup in the repository
RMAN> list copy;
specification does not match any datafile copy in the repository
specification does not match any control file copy in the repository
specification does not match any archived log in the repository
RMAN> backup pluggable database pdb1;
Starting backup at 22-AUG-25
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=00073 name=/data/u01/app/oracle/oradata/JYC/pdb1/sysaux01.dbf
input datafile file number=00072 name=/data/u01/app/oracle/oradata/JYC/pdb1/system01.dbf
input datafile file number=00074 name=/data/u01/app/oracle/oradata/JYC/pdb1/undotbs01.dbf
input datafile file number=00075 name=/data/u01/app/oracle/oradata/JYC/pdb1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 22-AUG-25
channel ORA_DISK_1: finished piece 1 at 22-AUG-25
piece handle=/data/u01/app/oracle/flash_recovery_area/JYC/3CB4CD2155D04C02E06310CFA8C0A781/backupset/2025_08_22/o1_mf_nnndf_TAG20250822T132203_nbhzmvbn_.bkp tag=TAG20250822T132203 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 22-AUG-25
Starting Control File and SPFILE Autobackup at 22-AUG-25
piece handle=/data/u01/app/oracle/flash_recovery_area/JYC/autobackup/2025_08_22/o1_mf_s_1209820926_nbhzmyk0_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 22-AUG-25
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
16 Full 505.00M DISK 00:00:01 22-AUG-25
BP Key: 16 Status: AVAILABLE Compressed: NO Tag: TAG20250822T132203
Piece Name: /data/u01/app/oracle/flash_recovery_area/JYC/3CB4CD2155D04C02E06310CFA8C0A781/backupset/2025_08_22/o1_mf_nnndf_TAG20250822T132203_nbhzmvbn_.bkp
List of Datafiles in backup set 16
Container ID: 6, PDB Name: PDB1
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- --------- ----------- ------ ----
72 Full 3140197 22-AUG-25 NO /data/u01/app/oracle/oradata/JYC/pdb1/system01.dbf
73 Full 3140197 22-AUG-25 NO /data/u01/app/oracle/oradata/JYC/pdb1/sysaux01.dbf
74 Full 3140197 22-AUG-25 NO /data/u01/app/oracle/oradata/JYC/pdb1/undotbs01.dbf
75 Full 3140197 22-AUG-25 NO /data/u01/app/oracle/oradata/JYC/pdb1/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
17 Full 17.95M DISK 00:00:00 22-AUG-25
BP Key: 17 Status: AVAILABLE Compressed: NO Tag: TAG20250822T132206
Piece Name: /data/u01/app/oracle/flash_recovery_area/JYC/autobackup/2025_08_22/o1_mf_s_1209820926_nbhzmyk0_.bkp
SPFILE Included: Modification time: 22-AUG-25
SPFILE db_unique_name: JYC
Control File Included: Ckp SCN: 3140206 Ckp time: 22-AUG-25
RMAN> list copy;
specification does not match any datafile copy in the repository
specification does not match any control file copy in the repository
specification does not match any archived log in the repository
RMAN> exit
Recovery Manager complete.
pdb1的所有文件被rm了
[oracle@oracle pdb1]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Aug 22 13:23:03 2025
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB5 READ WRITE NO
4 PDB2 READ WRITE NO
5 PDB3 READ WRITE NO
6 PDB1 READ WRITE NO
8 PDB6 READ WRITE NO
SQL> alter session set container=pdb1;
Session altered.
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/data/u01/app/oracle/oradata/JYC/pdb1/system01.dbf
/data/u01/app/oracle/oradata/JYC/pdb1/sysaux01.dbf
/data/u01/app/oracle/oradata/JYC/pdb1/undotbs01.dbf
/data/u01/app/oracle/oradata/JYC/pdb1/users01.dbf
SQL> !ls -l /data/u01/app/oracle/oradata/JYC/pdb1/*
-rw-r----- 1 oracle oinstall 377495552 Aug 22 13:22 /data/u01/app/oracle/oradata/JYC/pdb1/sysaux01.dbf
-rw-r----- 1 oracle oinstall 293609472 Aug 22 13:22 /data/u01/app/oracle/oradata/JYC/pdb1/system01.dbf
-rw-r----- 1 oracle oinstall 134225920 Aug 22 13:02 /data/u01/app/oracle/oradata/JYC/pdb1/temp01.dbf
-rw-r----- 1 oracle oinstall 104865792 Aug 22 13:22 /data/u01/app/oracle/oradata/JYC/pdb1/undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Aug 22 13:22 /data/u01/app/oracle/oradata/JYC/pdb1/users01.dbf
SQL> !rm -f /data/u01/app/oracle/oradata/JYC/pdb1/*
SQL> !ls -l /data/u01/app/oracle/oradata/JYC/pdb1/*
ls: cannot access /data/u01/app/oracle/oradata/JYC/pdb1/*: No such file or directory
SQL> insert into jyc.test values(2);
1 row created.
SQL> commit;
Commit complete.
SQL> shutdown immediate
Pluggable Database closed.
SQL> alter pluggable database pdb1 open;
alter pluggable database pdb1 open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 75 - see DBWR trace file
ORA-01110: data file 75: '/data/u01/app/oracle/oradata/JYC/pdb1/users01.dbf'
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@oracle pdb1]$
[oracle@oracle pdb1]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Aug 22 13:25:42 2025
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB5 READ WRITE NO
4 PDB2 READ WRITE NO
5 PDB3 READ WRITE NO
6 PDB1 MOUNTED
8 PDB6 READ WRITE NO
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
恢復被rm的pdb1
[oracle@oracle pdb1]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Fri Aug 22 13:25:49 2025
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: JYC (DBID=187041746)
RMAN> restore pluggable database pdb1;
Starting restore at 22-AUG-25
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1578 device type=DISK
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 00072 to /data/u01/app/oracle/oradata/JYC/pdb1/system01.dbf
channel ORA_DISK_1: restoring datafile 00073 to /data/u01/app/oracle/oradata/JYC/pdb1/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00074 to /data/u01/app/oracle/oradata/JYC/pdb1/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00075 to /data/u01/app/oracle/oradata/JYC/pdb1/users01.dbf
channel ORA_DISK_1: reading from backup piece /data/u01/app/oracle/flash_recovery_area/JYC/3CB4CD2155D04C02E06310CFA8C0A781/backupset/2025_08_22/o1_mf_nnndf_TAG20250822T132203_nbhzmvbn_.bkp
channel ORA_DISK_1: piece handle=/data/u01/app/oracle/flash_recovery_area/JYC/3CB4CD2155D04C02E06310CFA8C0A781/backupset/2025_08_22/o1_mf_nnndf_TAG20250822T132203_nbhzmvbn_.bkp tag=TAG20250822T132203
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 22-AUG-25
RMAN> alter pluggable database pdb1 open;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 08/22/2025 13:26:18
ORA-01113: file 75 needs media recovery
ORA-01110: data file 75: '/data/u01/app/oracle/oradata/JYC/pdb1/users01.dbf'
RMAN> recover pluggable database pdb1;
Starting recover at 22-AUG-25
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 22-AUG-25
RMAN> alter pluggable database pdb1 open;
Statement processed
RMAN> exit
Recovery Manager complete.
[oracle@oracle pdb1]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Aug 22 13:26:39 2025
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB5 READ WRITE NO
4 PDB2 READ WRITE NO
5 PDB3 READ WRITE NO
6 PDB1 READ WRITE NO
8 PDB6 READ WRITE NO
SQL> alter session set container=pdb1;
Session altered.
SQL> select * from jyc.test;
ID
----------
1
2
SQL>
pdb1庫被drop了
[oracle@oracle pdb1]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Aug 22 13:26:39 2025
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB5 READ WRITE NO
4 PDB2 READ WRITE NO
5 PDB3 READ WRITE NO
6 PDB1 READ WRITE NO
8 PDB6 READ WRITE NO
SQL> alter session set container=pdb1;
Session altered.
SQL> select * from jyc.test;
ID
----------
1
2
SQL>
SQL>
SQL> shutdown immediate
Pluggable Database closed.
SQL> conn / as sysdba
Connected.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB5 READ WRITE NO
4 PDB2 READ WRITE NO
5 PDB3 READ WRITE NO
6 PDB1 MOUNTED
8 PDB6 READ WRITE NO
SQL> set time on
13:28:25 SQL> drop pluggable database pdb1 including datafiles;
Pluggable database dropped.
13:28:47 SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB5 READ WRITE NO
4 PDB2 READ WRITE NO
5 PDB3 READ WRITE NO
8 PDB6 READ WRITE NO
13:28:50 SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@oracle pdb1]$ pwd
/data/u01/app/oracle/oradata/JYC/pdb1
[oracle@oracle pdb1]$ ll
total 0
恢復被drop的pdb1
[oracle@oracle pdb1]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Fri Aug 22 13:29:32 2025
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: JYC (DBID=187041746)
RMAN> list backup;
using target database control file instead of recovery catalog
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
16 Full 505.00M DISK 00:00:01 22-AUG-25
BP Key: 16 Status: AVAILABLE Compressed: NO Tag: TAG20250822T132203
Piece Name: /data/u01/app/oracle/flash_recovery_area/JYC/3CB4CD2155D04C02E06310CFA8C0A781/backupset/2025_08_22/o1_mf_nnndf_TAG20250822T132203_nbhzmvbn_.bkp
List of Datafiles in backup set 16
Container ID: 4099, PDB Name: UNKNOWN
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- --------- ----------- ------ ----
72 Full 3140197 22-AUG-25 NO
73 Full 3140197 22-AUG-25 NO
74 Full 3140197 22-AUG-25 NO
75 Full 3140197 22-AUG-25 NO
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
17 Full 17.95M DISK 00:00:00 22-AUG-25
BP Key: 17 Status: AVAILABLE Compressed: NO Tag: TAG20250822T132206
Piece Name: /data/u01/app/oracle/flash_recovery_area/JYC/autobackup/2025_08_22/o1_mf_s_1209820926_nbhzmyk0_.bkp
SPFILE Included: Modification time: 22-AUG-25
SPFILE db_unique_name: JYC
Control File Included: Ckp SCN: 3140206 Ckp time: 22-AUG-25
RMAN>
RMAN> restore pluggable database pdb1;
Starting restore at 22-AUG-25
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1577 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 08/22/2025 13:31:28
RMAN-06813: could not translate pluggable database PDB1
RMAN> restore foreign pluggable database pdb1;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found ";": expecting one of: "format, from service, to"
RMAN-01007: at line 1 column 40 file: standard input
RMAN>
RMAN>
RMAN>
RMAN> recover pluggable database pdb1 until time "to_date('2025-08-22 13:28:25','YYYY-MM-DD HH24:MI:SS')" auxiliary destination '/home/oracle/aux/';
Starting recover at 22-AUG-25
current log archived
using channel ORA_DISK_1
RMAN-05026: warning: presuming following set of tablespaces applies to specified point-in-time
List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1
Creating automatic instance, with SID='vbjn'
initialization parameters used for automatic instance:
db_name=JYC
db_unique_name=vbjn_pitr_pdb1_JYC
compatible=19.0.0
db_block_size=8192
db_files=200
diagnostic_dest=/data/u01/app/oracle
_system_trig_enabled=FALSE
sga_target=6560M
processes=200
db_create_file_dest=/home/oracle/aux/
log_archive_dest_1='location=/home/oracle/aux/'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
starting up automatic instance JYC
Oracle instance started
Total System Global Area 6878658336 bytes
Fixed Size 9150240 bytes
Variable Size 1207959552 bytes
Database Buffers 5653921792 bytes
Redo Buffers 7626752 bytes
Automatic instance created
contents of Memory Script:
{
# set requested point in time
set until time "to_date('2025-08-22 13:28:25','YYYY-MM-DD HH24:MI:SS')";
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
}
executing Memory Script
executing command: SET until clause
Starting restore at 22-AUG-25
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=198 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /data/u01/app/oracle/flash_recovery_area/JYC/autobackup/2025_08_22/o1_mf_s_1209820926_nbhzmyk0_.bkp
channel ORA_AUX_DISK_1: piece handle=/data/u01/app/oracle/flash_recovery_area/JYC/autobackup/2025_08_22/o1_mf_s_1209820926_nbhzmyk0_.bkp tag=TAG20250822T132206
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/home/oracle/aux/JYC/controlfile/o1_mf_nbj09r4s_.ctl
Finished restore at 22-AUG-25
sql statement: alter database mount clone database
contents of Memory Script:
{
# set requested point in time
set until time "to_date('2025-08-22 13:28:25','YYYY-MM-DD HH24:MI:SS')";
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile 1 to new;
set newname for clone datafile 4 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 7 to new;
set newname for datafile 72 to
"/data/u01/app/oracle/oradata/JYC/pdb1/system01.dbf";
set newname for datafile 73 to
"/data/u01/app/oracle/oradata/JYC/pdb1/sysaux01.dbf";
set newname for datafile 74 to
"/data/u01/app/oracle/oradata/JYC/pdb1/undotbs01.dbf";
set newname for datafile 75 to
"/data/u01/app/oracle/oradata/JYC/pdb1/users01.dbf";
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 4, 3, 7, 72, 73, 74, 75;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 22-AUG-25
using channel ORA_AUX_DISK_1
Removing automatic instance
shutting down automatic instance
Oracle instance shut down
Automatic instance removed
auxiliary instance file /home/oracle/aux/JYC/controlfile/o1_mf_nbj09r4s_.ctl deleted
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 08/22/2025 13:33:52
RMAN-03015: error occurred in stored script Memory Script
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 7 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore
RMAN> exit
Recovery Manager complete.
[oracle@oracle pdb1]$ ll
total 0
[oracle@oracle pdb1]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Fri Aug 22 13:34:22 2025
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: JYC (DBID=187041746)
RMAN> restore foreign pluggable database pdb1 from backupset '/data/u01/app/oracle/flash_recovery_area/JYC/3CB4CD2155D04C02E06310CFA8C0A781/backupset/2025_08_22/o1_mf_nnndf_TAG20250822T132203_nbhzmvbn_.bkp';
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "from": expecting one of: "format, from service, to"
RMAN-01007: at line 1 column 41 file: standard input
RMAN>
RMAN> restore foreign pluggable database pdb1
2> format '/data/u01/app/oracle/oradata/JYC/pdb1/%U'
3> from backupset '/data/u01/app/oracle/flash_recovery_area/JYC/3CB4CD2155D04C02E06310CFA8C0A781/backupset/2025_08_22/o1_mf_nnndf_TAG20250822T132203_nbhzmvbn_.bkp';
Starting restore at 22-AUG-25
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1577 device type=DISK
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 all foreign files in backup piece
channel ORA_DISK_1: reading from backup piece /data/u01/app/oracle/flash_recovery_area/JYC/3CB4CD2155D04C02E06310CFA8C0A781/backupset/2025_08_22/o1_mf_nnndf_TAG20250822T132203_nbhzmvbn_.bkp
channel ORA_DISK_1: restoring foreign file 73 to /data/u01/app/oracle/oradata/JYC/pdb1/data_D-JYC_I-187041746_TS-SYSAUX_FNO-73_vk41oqg7
channel ORA_DISK_1: restoring foreign file 72 to /data/u01/app/oracle/oradata/JYC/pdb1/data_D-JYC_I-187041746_TS-SYSTEM_FNO-72_1d41oqg7
channel ORA_DISK_1: restoring foreign file 74 to /data/u01/app/oracle/oradata/JYC/pdb1/data_D-JYC_I-187041746_TS-UNDOTBS1_FNO-74_to41oqg7
channel ORA_DISK_1: restoring foreign file 75 to /data/u01/app/oracle/oradata/JYC/pdb1/data_D-JYC_I-187041746_TS-USERS_FNO-75_7541oqg7
channel ORA_DISK_1: foreign piece handle=/data/u01/app/oracle/flash_recovery_area/JYC/3CB4CD2155D04C02E06310CFA8C0A781/backupset/2025_08_22/o1_mf_nnndf_TAG20250822T132203_nbhzmvbn_.bkp
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
Finished restore at 22-AUG-25
RMAN> exit
Recovery Manager complete.
[oracle@oracle pdb1]$ ll
total 762912
-rw-r----- 1 oracle oinstall 377495552 Aug 22 13:35 data_D-JYC_I-187041746_TS-SYSAUX_FNO-73_vk41oqg7
-rw-r----- 1 oracle oinstall 293609472 Aug 22 13:35 data_D-JYC_I-187041746_TS-SYSTEM_FNO-72_1d41oqg7
-rw-r----- 1 oracle oinstall 104865792 Aug 22 13:35 data_D-JYC_I-187041746_TS-UNDOTBS1_FNO-74_to41oqg7
-rw-r----- 1 oracle oinstall 5251072 Aug 22 13:35 data_D-JYC_I-187041746_TS-USERS_FNO-75_7541oqg7
[oracle@oracle pdb1]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Aug 22 13:35:45 2025
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB5 READ WRITE NO
4 PDB2 READ WRITE NO
5 PDB3 READ WRITE NO
8 PDB6 READ WRITE NO
SQL> BEGIN
2 DBMS_PDB.RECOVER (
3 pdb_descr_file => '/home/oracle/jyc-pdb1-20250822.xml',
4 pdb_name => 'PDB1',
5 filenames => '/data/u01/app/oracle/oradata/JYC/pdb1/'
6 );
7 END;
8 /
PL/SQL procedure successfully completed.
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
g[oracle@oracle pdb1]$ grep path /home/oracle/jyc-pdb1-20250822.xml
<path>/data/u01/app/oracle/oradata/JYC/pdb1/data_D-JYC_I-187041746_TS-SYSAUX_FNO-73_vk41oqg7</path>
<path>/data/u01/app/oracle/oradata/JYC/pdb1/data_D-JYC_I-187041746_TS-SYSTEM_FNO-72_1d41oqg7</path>
<path>/data/u01/app/oracle/oradata/JYC/pdb1/data_D-JYC_I-187041746_TS-UNDOTBS1_FNO-74_to41oqg7</path>
<path>/data/u01/app/oracle/oradata/JYC/pdb1/data_D-JYC_I-187041746_TS-USERS_FNO-75_7541oqg7</path>
[oracle@oracle pdb1]$
[oracle@oracle pdb1]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Fri Aug 22 13:37:19 2025
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> CREATE PLUGGABLE DATABASE PDB1 USING '/home/oracle/jyc-pdb1-20250822.xml' NOCOPY tempfile reuse;
Pluggable database created.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB5 READ WRITE NO
4 PDB2 READ WRITE NO
5 PDB3 READ WRITE NO
6 PDB1 MOUNTED
8 PDB6 READ WRITE NO
SQL> alter pluggable database pdb1 open;
Pluggable database altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB5 READ WRITE NO
4 PDB2 READ WRITE NO
5 PDB3 READ WRITE NO
6 PDB1 MIGRATE YES
8 PDB6 READ WRITE NO
SQL> alter pluggable database pdb1 close immediate;
Pluggable database altered.
SQL> alter pluggable database pdb1 open;
Pluggable database altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB5 READ WRITE NO
4 PDB2 READ WRITE NO
5 PDB3 READ WRITE NO
6 PDB1 READ WRITE NO
8 PDB6 READ WRITE NO
SQL> alter session set container=pdb1;
Session altered.
SQL> select * from jyc.test;
ID
----------
1
SQL> exit
結論:
1.pdb1的文件被rm了
處理辦法:restore+recover可以恢復到最近時刻
2.pdb1被drop掉了
處理辦法:直接recover until time auxiliary destination是不行的。
需要通過restore恢復備份集的文件,然后根據恢復后的所有文件再生成xml元數據文件,再創建出新庫,此時相當于多租戶庫的插拔操作。這個方法同樣適用于將租戶庫插拔到不同的目標實例cdb中。
由此也發現,只有租戶庫的所有文件也是可以通過根據文件生成xml插拔的方式恢復的。
注意:數據只能恢復到備份的時刻。
3.最后有遇到temp臨時表空間bug問題,可忽略,僅此記錄一下


SQL> alter session set container=pdb1;
Session altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
6 PDB1 READ WRITE NO
SQL> select name from v$tempfile;
no rows selected
SQL> select name from v$tablespace;
NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
USERS
SQL> create temporary tablespace temp tempfile '/data/u01/app/oracle/oradata/JYC/pdb1/temp01.dbf' size 5m;
create temporary tablespace temp tempfile '/data/u01/app/oracle/oradata/JYC/pdb1/temp01.dbf' size 5m
*
ERROR at line 1:
ORA-01543: tablespace 'TEMP' already exists
SQL> alter tablespace temp add tempfile '/data/u01/app/oracle/oradata/JYC/pdb1/temp01.dbf' size 5m;
alter tablespace temp add tempfile '/data/u01/app/oracle/oradata/JYC/pdb1/temp01.dbf' size 5m
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [kcffo_add_tmpf-1], [3], [], [], [],
[], [], [], [], [], [], []
SQL> create temporary tablespace temp1 tempfile '/data/u01/app/oracle/oradata/JYC/pdb1/temp101.dbf' size 5m;
Tablespace created.
SQL> alter database default temporary tablespace temp1;
Database altered.
SQL> drop tablespace temp including contents and datafiles;
drop tablespace temp including contents and datafiles
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [krtlft-01], [3], [], [], [], [],
[], [], [], [], [], []
SQL> drop tablespace temp including contents;
drop tablespace temp including contents
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [krtlft-01], [3], [], [], [], [],
[], [], [], [], [], []
SQL> drop tablespace temp ;
drop tablespace temp
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [krtlft-01], [3], [], [], [], [],
[], [], [], [], [], []
最后修改時間:2025-08-26 14:58:29
「喜歡這篇文章,您的關注和贊賞是給作者最好的鼓勵」
關注作者
【版權聲明】本文為墨天輪用戶原創內容,轉載時必須標注文章的來源(墨天輪),文章鏈接,文章作者等基本信息,否則作者和墨天輪有權追究責任。如果您發現墨天輪中有涉嫌抄襲或者侵權的內容,歡迎發送郵件至:contact@modb.pro進行舉報,并提供相關證據,一經查實,墨天輪將立刻刪除相關內容。




