全部博文(389)
分类: Oracle
2014-04-02 17:03:41
使用rman恢复pdb数据文件
在非pdb数据库,数据库在open的时候,会对当前的数据的所有数据文件进行检查.
对于system,sysaux和undo表空间的数据文件,如果有问题,数据库无法open.对于普通的
数据文件,我们可以跳过,然后再打数据库,稍后再对数据文件做恢复:
例:
SQL> startup;
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2293880 bytes
Variable Size 322965384 bytes
Database Buffers 503316480 bytes
Redo Buffers 6529024 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '/u01/app/oracle/oradata/c12/users01.dbf'
SQL> alter database datafile 6 offline;
Database altered.
SQL> alter database open;
Database altered.
使用rman
RMAN> restore datafile 6;
RMAN> recover datafile 6;
然后对数据文件进行online处理
SQL> alter database datafile 6 online;
再看看pdb的数据文件.摸拟pdb数据文件删除
[oracle@o12c pdb2]$ mv pdb2_users01.dbf pdb2_users01.dbfold
启动数据库实例
SQL> startup;
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2293880 bytes
Variable Size 322965384 bytes
Database Buffers 503316480 bytes
Redo Buffers 6529024 bytes
Database mounted.
Database opened.
由此我们可以得出一个结论,当cdb在打开的时候,对于pdb中的数据文件不会做任何检查.
SQL> alter pluggable database pdb2 open;
alter pluggable database pdb2 open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 13 - see DBWR trace file
ORA-01110: data file 13: '/u01/app/oracle/oradata/c12/pdb2/pdb2_users01.dbf'
只有在pluggable database的数据文件打开的时候才会去检查数据文件
进入pdb操作,
SQL> alter session set container=pdb2;
Session altered.
SQL> alter pluggable database datafile 13 offline;
Pluggable database altered.
虽然datafile号是唯一的,但是只能进入pdb才能操作,如果在cdb试图去offline会报错.
SQL> alter database datafile 13 offline;
alter database datafile 13 offline
*
ERROR at line 1:
ORA-01516: nonexistent log file, data file, or temporary file "13"
SQL> alter pluggable database datafile 13 offline;
alter pluggable database datafile 13 offline
*
ERROR at line 1:
ORA-65046: operation not allowed from outside a pluggable database
但是在rman中可以直接使用datafile号进行恢复
[oracle@o12c ~]$ $ORACLE_HOME/bin/rman
Recovery Manager: Release 12.1.0.1.0 - Production on Fri Feb 21 22:29:08 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.
RMAN> connect target / ;
connected to target database: C12 (DBID=461042625)
RMAN> restore datafile 13;
Starting restore at 21-FEB-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=262 device type=DISK
...............................
Finished restore at 21-FEB-14
RMAN> recover datafile 13;
Starting recover at 21-FEB-14
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 21-FEB-14
SQL> alter pluggable database datafile 13 online;
Pluggable database altered.