新特性:CDB/PDB的维护命令:备份与恢复(2)模拟PDB system表空间数据文件删除后恢复

模拟PDB system表空间数据文件删除后恢复

查看system 的数据文件

[oracle@cat1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Mon May 2 22:06:55 2005
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 PDB1_WHS                       READ WRITE NO
         4 PDB2_WHS                       MOUNTED
         5 PDB3_WHS                       MOUNTED

SQL> alter session set container=PDB1_WHS;

Session altered.

SQL> select file_name from dba_data_files where tablespace_name='SYSTEM';

FILE_NAME
--------------------------------------------------------------------------------
+DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/system.274.1057318911

SQL> shutdown immeidate
SP2-0717: illegal SHUTDOWN option
SQL> shutdown immediate
Pluggable Database closed.
SQL> 

ASM需要停库后才能删除文件,否则报错:

ORA-15032: not all alterations performed
ORA-15028: ASM file '+DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/system.274.1057318911' not dropped; currently being accessed (DBD ERROR: OCIStmtExecute)

删除文件:

[grid@cat1 ~]$ asmcmd
ASMCMD> rm -rf +DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/system.274.1057318911

无法开启数据库

SQL> startup
ORA-01157: cannot identify/lock data file 10 - see DBWR trace file
ORA-01110: data file 10:
'+DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/system.274.1057318911'

恢复数据文件

[oracle@cat1 ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Mon May 2 22:18:03 2005
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: WHS1 (DBID=2406852607)

RMAN> restore tablespace PDB1_WHS:SYSTEM;

Starting restore at 02-MAY-05
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=410 instance=whs11 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 00010 to +DATA1/WHS1/B4D31742116320ECE0532900A8C025DC/DATAFILE/system.274.1057318911
channel ORA_DISK_1: reading from backup piece /rmanbackup/rman0_WHS1_2_20050502
channel ORA_DISK_1: piece handle=/rmanbackup/rman0_WHS1_2_20050502 tag=LEVEL0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 02-MAY-05

RMAN> RECOVER  tablespace PDB1_WHS:SYSTEM;

Starting recover at 02-MAY-05
using channel ORA_DISK_1

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

Finished recover at 02-MAY-05

RMAN> ALTER PLUGGABLE DATABASE PDB1_WHS OPEN;

Statement processed

验证:

SQL> show pdbs  

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1_WHS                       READ WRITE NO
         4 PDB2_WHS                       MOUNTED
         5 PDB3_WHS                       MOUNTED
SQL> 

Related Posts