概述
备份数据库
[oracle@12cr2 ~]$ rman target /
RMAN> backup database;
RMAN> list backup summary;
数据库open状态,系统表空间损坏 -----故障模拟 [oracle@12cr2 ~]$ sqlplus / as sysdba
SQL>> SQL> select file_name from dba_data_files;
FILE_NAME
/u01/app/oracle/oradata/zylong/pdb4/pdb4/system01.dbf
/u01/app/oracle/oradata/zylong/pdb4/pdb4/sysaux01.dbf
/u01/app/oracle/oradata/zylong/pdb4/pdb4/undotbs01.dbf
[oracle@12cr2 ~]$ rm /u01/app/oracle/oradata/zylong/pdb4/pdb4/system01.dbf
[oracle@12cr2 ~]$ rm /u01/app/oracle/oradata/zylong/pdb4/pdb4/sysaux01.dbf
[oracle@12cr2 ~]$ sqlplus / as sysdba
ERROR:
ORA-09817: Write to audit file failed.
ORA-01075: you are currently logged on
故障现象
[root@12cr2 opt]# su - oracle
[oracle@12cr2 ~]$ sqlplus / as sysdba
SQL>> SQL> select file_name from dba_data_files;
FILE_NAME
/u01/app/oracle/oradata/zylong/pdb4/pdb4/system01.dbf
/u01/app/oracle/oradata/zylong/pdb4/pdb4/sysaux01.dbf
/u01/app/oracle/oradata/zylong/pdb4/pdb4/undotbs01.dbf
SQL> create user test>
create user test> ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-01116: error in opening database file 38
ORA-01110: data file 38:
'/u01/app/oracle/oradata/zylong/pdb4/pdb4/system01.dbf'
ORA-27041: unable to open file
SQL> conn / as sysdba
SQL>>
Pluggable database>
SQL>> alter pluggable database pdb4 open
ERROR at line 1:
ORA-01113: file 40 needs media recovery
ORA-01110: data file 40:
'/u01/app/oracle/oradata/zylong/pdb4/pdb4/undotbs01.dbf'
恢复
[oracle@12cr2 ~]$ rman target /
----可以在下一层指定PDB来进行相关操作,也可以在当前指定PDB进行连接:rman target sys/password@hostname:1521/pdb_name,此时恢复跟11G没多大区别,直接可以restore datafile n,recover datafile n,restore tablespace n,recover tablepace n等等操作。
RMAN> restore tablespace pdb4:system;
RMAN> restore tablespace pdb4:sysaux;
RMAN> recover tablespace pdb4:system;
RMAN> recover tablespace pdb4:sysaux;
RMAN>> RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 06/11/2017 21:00:12
ORA-01113: file 40 needs media recovery
ORA-01110: data file 40: '/u01/app/oracle/oradata/zylong/pdb4/pdb4/undotbs01.dbf'
RMAN> recover tablespace pdb4:UNDOTBS1;
RMAN> >数据库关闭状态,普通表空间损坏 模拟故障
SQL>> [oracle@12cr2 ~]$ rm /u01/app/oracle/oradata/zylong/pdb4/pdb4/users01.dbf
SQL>> alter pluggable database pdb4 open
ERROR at line 1:
ORA-01157: cannot> ORA-01110: data file 41: '/u01/app/oracle/oradata/zylong/pdb4/pdb4/users01.dbf'
恢复
[oracle@12cr2 ~]$ rman target /
RMAN> restore tablespace pdb4:users;
RMAN>> RMAN> recover tablespace pdb4:users;
RMAN>>数据库open状态,未备份的数据文件恢复 模拟故障
SQL> create tablespace users datafile '/u01/app/oracle/oradata/zylong/pdb4/pdb4/users01.dbf'>
SQL> create user test> SQL> grant dba to test;
SQL> conn test/oracle@192.168.16.81:1521/pdb4
SQL> create table test as select * from all_objects where rownum commit;
SQL> !rm /u01/app/oracle/oradata/zylong/pdb4/pdb4/users01.dbf
故障后的现象
SQL> select count(*) from test;
SQL> insert into test select * from test;
SQL> commit;
SQL> insert into test select * from test;
SQL> commit;
SQL>> ERROR at line 1:
ORA-03113: end-of-file on communication channel
SQL> insert into test select * from test;
ORA-03114: not connected to ORACLE
SQL> conn test/oracle@192.168.16.81:1521/pdb4
ORA-01033: ORACLE initialization or shutdown in progress
SQL> conn / as sysdba
SQL> show pdbs;
SQL>>
ORA-01157: cannot> ORA-01110: data file 41: '/u01/app/oracle/oradata/zylong/pdb4/pdb4/users01.dbf'
恢复
[oracle@12cr2 ~]$ rman target /
RMAN> restore tablespace pdb4:users;
RMAN> recover tablespace pdb4:users;
RMAN>> RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 06/11/2017 21:35:30
ORA-01113: file 40 needs media recovery
ORA-01110: data file 40: '/u01/app/oracle/oradata/zylong/pdb4/pdb4/undotbs01.dbf'
RMAN> recover tablespace pdb4:UNDOTBS1;
RMAN>> ORA-01113: file 39 needs media recovery
ORA-01110: data file 39: '/u01/app/oracle/oradata/zylong/pdb4/pdb4/sysaux01.dbf'
RMAN> recover tablespace pdb4:sysaux;
RMAN>> ORA-01113: file 38 needs media recovery
ORA-01110: data file 38: '/u01/app/oracle/oradata/zylong/pdb4/pdb4/system01.dbf'
RMAN> recover tablespace pdb4:system;
如果PDB4没有关闭,可以restore tablespace pdb4:users可能会报错,可以尝试执行以下命令在restore:
SQL >> recover之后online
SQL >> 4 单个pdb 数据文件修复
[oracle@12c pdb01]$ rman target sys/password@hostname:1521/pdb_name
RMAN> recover datafile 12;
RMAN-06094: datafile 12 must be restored
RMAN>> RMAN> restore datafile 12;
RMAN> recover datafile 12;
RMAN>> 5 单个PDB数据库恢复
-----set until time "TO_DATE('2018-06-03 15:00:00','yyyy-mm-dd hh24:mi:ss')";
-----set until SCN = 180000;
RMAN>restore pluggable database pdb01;
RMAN>recover pluggable database pdb01;
[oracle@12c01 ~]$ sqlplus / as sysdba
SQL>>
最后
以上就是聪慧魔镜为你收集整理的oracle 12c备份pdb,oracle 12c pdb 恢复的全部内容,希望文章能够帮你解决oracle 12c备份pdb,oracle 12c pdb 恢复所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复