环境:
OS:Centos 7
DB:18C
1.当前数据库以及在应用日志模式
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 READ ONLY NO
4 PDB2 READ ONLY NO
5 PDB3 READ ONLY NO
6 PDB4 READ ONLY NO
7 PDB5 READ ONLY NO
8 PDB6 READ ONLY NO
9 PDB7 READ ONLY NO
10 PDB8 READ ONLY NO
11 PDB9 MOUNTED
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY
SQL> select process,status from v$managed_standby;
PROCESS STATUS
--------- ------------
ARCH CLOSING
DGRD ALLOCATED
DGRD ALLOCATED
ARCH CLOSING
ARCH CONNECTED
ARCH CONNECTED
RFS IDLE
RFS IDLE
RFS IDLE
RFS IDLE
RFS IDLE
PROCESS STATUS
--------- ------------
RFS IDLE
RFS IDLE
RFS IDLE
RFS IDLE
RFS IDLE
MRP0 APPLYING_LOG
17 rows selected.
2.从库创建新增pdb的相应的数据目录
mkdir -p /u01/app/oracle/oradata/ora18c/slnngk/c360c4f732da78c3e0536f38a8c0653f/datafile
3.执行恢复
run{
set newname for datafile 59 to ‘/u01/app/oracle/oradata/ora18c/slnngk/c360c4f732da78c3e0536f38a8c0653f/datafile/users.476.1073711353‘;
set newname for datafile 58 to ‘/u01/app/oracle/oradata/ora18c/slnngk/c360c4f732da78c3e0536f38a8c0653f/datafile/undo_2.479.1073711353‘;
set newname for datafile 60 to ‘/u01/app/oracle/oradata/ora18c/slnngk/c360c4f732da78c3e0536f38a8c0653f/datafile/tps_hxl.477.1073711353‘;
set newname for datafile 57 to ‘/u01/app/oracle/oradata/ora18c/slnngk/c360c4f732da78c3e0536f38a8c0653f/datafile/undotbs1.478.1073711353‘;
set newname for datafile 61 to ‘/u01/app/oracle/oradata/ora18c/slnngk/c360c4f732da78c3e0536f38a8c0653f/datafile/tps_hxl.480.1073711353‘;
set newname for datafile 55 to ‘/u01/app/oracle/oradata/ora18c/slnngk/c360c4f732da78c3e0536f38a8c0653f/datafile/system.481.1073711353‘;
set newname for datafile 56 to ‘/u01/app/oracle/oradata/ora18c/slnngk/c360c4f732da78c3e0536f38a8c0653f/datafile/sysaux.482.1073711353‘;
restore pluggable database pdb9 from service tnsslnngk1;
switch datafile all;
}
4.尝试打开pdb
打开pdb报错误
SQL> alter pluggable database pdb9 open;
alter pluggable database pdb9 open
*
ERROR at line 1:
ORA-01147: SYSTEM tablespace file 55 is offline
5.尝试恢复
SQL> alter session set container=cdb$root;
SQL>alter system set standby_file_management=auto;
SQL>alter database recover managed standby database cancel;
SQL>alter session set container=pdb9;
SQL>alter pluggable database disable recovery;
##tnsslnngk1 是连接到主库的tns
RMAN> run{
2> restore pluggable database pdb9 from service tnsslnngk1 ;
3> }
Starting restore at 31-MAY-21
using channel ORA_DISK_1
skipping datafile 55; already restored to SCN 5467138
skipping datafile 56; already restored to SCN 5467280
skipping datafile 57; already restored to SCN 5467289
skipping datafile 58; already restored to SCN 5467294
skipping datafile 59; already restored to SCN 5467298
skipping datafile 60; already restored to SCN 5467303
skipping datafile 61; already restored to SCN 5467306
restore not done; all files read only, offline, excluded, or already restored
Finished restore at 31-MAY-21
6.恢复使用enable recovery
SQL> alter session set container=cdb$root;
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter session set container=pdb9;
SQL> alter pluggable database enable recovery;
SQL> alter session set container=cdb$root;
SQL> alter database recover managed standby database disconnect from session;
7.打开pdb
alter database recover managed standby database cancel;
alter database open;
alter database recover managed standby database disconnect from session;