文档章节

Oracle 12c: RMAN restore/recover pluggable database

小强斋太
 小强斋太
发布于 2016/11/09 20:05
字数 2299
阅读 9
收藏 0

查看数据库状态

运行在归档模式,可拔插数据库name=pdborcl

SQL> archive log list;
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     24
Next log sequence to archive   26
Current log sequence           26
SQL> alter pluggable database all open;

Pluggable database altered.

SQL> show pdbs;

    CON_ID CON_NAME              OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
     2 PDB$SEED              READ ONLY  NO
     3 PDBORCL              READ WRITE NO


SQL> alter session set container=pdborcl;

Session altered.

SQL> select * from scott.dept;

    DEPTNO DNAME      LOC
---------- -------------- -------------
    10 ACCOUNTING      NEW YORK
    20 RESEARCH      DALLAS
    30 SALES      CHICAGO
    40 OPERATIONS      BOSTON

rman连接cdb,备份整个数据库

run{

allocate channel C1 device type disk format  '/home/oracle/backup/full_db_%U';

backup database include current controlfile plus archivelog  ;

release  channel C1 ;

}

crosscheck backupset;

delete noprompt  obsolete;

或者

backup database include current controlfile format  '/home/oracle/backup/full_db_%U'  plus archivelog  format  '/home/oracle/backup/full_db_%U';

结果如下:

RMAN> backup database include current controlfile format  '/home/oracle/backup/full_db_%U'  plus archivelog  format  '/home/oracle/backup/full_db_%U';


Starting backup at 05-JAN-16
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=45 RECID=20 STAMP=900344286
input archived log thread=1 sequence=46 RECID=21 STAMP=900344420
channel ORA_DISK_1: starting piece 1 at 05-JAN-16
channel ORA_DISK_1: finished piece 1 at 05-JAN-16
piece handle=/home/oracle/backup/full_db_27qqkaj4_1_1 tag=TAG20160105T154020 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 05-JAN-16

Starting backup at 05-JAN-16
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=00001 name=/data/app/oracle/oradata/orcl/system01.dbf input datafile file number=00003 name=/data/app/oracle/oradata/orcl/sysaux01.dbf input datafile file number=00004 name=/data/app/oracle/oradata/orcl/undotbs01.dbf input datafile file number=00006 name=/data/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 05-JAN-16
channel ORA_DISK_1: finished piece 1 at 05-JAN-16
piece handle=/home/oracle/backup/full_db_28qqkaj5_1_1 tag=TAG20160105T154021 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00009 name=/data/app/oracle/oradata/orcl/pdborcl/sysaux01.dbf input datafile file number=00008 name=/data/app/oracle/oradata/orcl/pdborcl/system01.dbf input datafile file number=00010 name=/data/app/oracle/oradata/orcl/pdborcl/pdborcl_users01.dbf
channel ORA_DISK_1: starting piece 1 at 05-JAN-16
channel ORA_DISK_1: finished piece 1 at 05-JAN-16
piece handle=/home/oracle/backup/full_db_29qqkajc_1_1 tag=TAG20160105T154021 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/data/app/oracle/oradata/orcl/pdbseed/sysaux01.dbf input datafile file number=00005 name=/data/app/oracle/oradata/orcl/pdbseed/system01.dbf
channel ORA_DISK_1: starting piece 1 at 05-JAN-16
channel ORA_DISK_1: finished piece 1 at 05-JAN-16
piece handle=/home/oracle/backup/full_db_2aqqkajg_1_1 tag=TAG20160105T154021 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 05-JAN-16
channel ORA_DISK_1: finished piece 1 at 05-JAN-16
piece handle=/home/oracle/backup/full_db_2bqqkajn_1_1 tag=TAG20160105T154021 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 05-JAN-16

Starting backup at 05-JAN-16
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=47 RECID=22 STAMP=900344441
channel ORA_DISK_1: starting piece 1 at 05-JAN-16
channel ORA_DISK_1: finished piece 1 at 05-JAN-16
piece handle=/home/oracle/backup/full_db_2cqqkajp_1_1 tag=TAG20160105T154041 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 05-JAN-16

Starting Control File and SPFILE Autobackup at 05-JAN-16
piece handle=/data/app/oracle/recovery_area/ORCL/autobackup/2016_01_05/o1_mf_s_900344442_c8pwvtqb_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 05-JAN-16

RMAN>

7个piece,一个属于CDB,一个PDB$SEED,一个PDBORCL, 2个archivelog,1个current contrilfile ,还有1个默认的Control File and SPFILE Autobackup

rman连接cdb,备份指定pdb

连接

[oracle@xqzt ~]$ rman target /

备份

backup pluggable database pdborcl include current controlfile format '/home/oracle/backup/full_db_%U' plus archivelog

结果

RMAN> list backup ;


List of Backup Sets
===================


BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
81      209.50K    DISK        00:00:00     05-JAN-16      
        BP Key: 81   Status: AVAILABLE  Compressed: NO  Tag: TAG20160105T155733
        Piece Name: /data/app/oracle/recovery_area/ORCL/backupset/2016_01_05/o1_mf_annnn_TAG20160105T155733_c8pxvfww_.bkp

  List of Archived Logs in backup set 81
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    45      2804981    05-JAN-16 2805000    05-JAN-16
  1    46      2805000    05-JAN-16 2805165    05-JAN-16
  1    47      2805165    05-JAN-16 2805184    05-JAN-16
  1    48      2805184    05-JAN-16 2805762    05-JAN-16

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
82      Full    675.54M    DISK        00:00:00     05-JAN-16      
        BP Key: 82   Status: AVAILABLE  Compressed: NO  Tag: TAG20160105T155735
        Piece Name: /home/oracle/backup/full_db_2iqqkbjf_1_1
  List of Datafiles in backup set 82
  Container ID: 3, PDB Name: PDBORCL
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  8       Full 2805770    05-JAN-16 /data/app/oracle/oradata/orcl/pdborcl/system01.dbf
  9       Full 2805770    05-JAN-16 /data/app/oracle/oradata/orcl/pdborcl/sysaux01.dbf
  10      Full 2805770    05-JAN-16 /data/app/oracle/oradata/orcl/pdborcl/pdborcl_users01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
83      Full    17.17M     DISK        00:00:01     05-JAN-16      
        BP Key: 83   Status: AVAILABLE  Compressed: NO  Tag: TAG20160105T155735
        Piece Name: /home/oracle/backup/full_db_2jqqkbjm_1_1
  Control File Included: Ckp SCN: 2805772      Ckp time: 05-JAN-16

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
84      3.00K      DISK        00:00:00     05-JAN-16      
        BP Key: 84   Status: AVAILABLE  Compressed: NO  Tag: TAG20160105T155744
        Piece Name: /data/app/oracle/recovery_area/ORCL/backupset/2016_01_05/o1_mf_annnn_TAG20160105T155744_c8pxvrg2_.bkp

  List of Archived Logs in backup set 84
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    49      2805762    05-JAN-16 2805777    05-JAN-16

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
85      Full    17.20M     DISK        00:00:00     05-JAN-16      
        BP Key: 85   Status: AVAILABLE  Compressed: NO  Tag: TAG20160105T155745
        Piece Name: /data/app/oracle/recovery_area/ORCL/autobackup/2016_01_05/o1_mf_s_900345465_c8pxvsq8_.bkp
  SPFILE Included: Modification time: 05-JAN-16
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 2805786      Ckp time: 05-JAN-16

rman连接pdb,备份pdb数据库

配置pdborcl的tns

PDBORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = xqzt)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME =pdborcl)
    )
  )

rman 连接pdborcl

rman target sys/wangshengzhuang@pdborcl

开始备份

RMAN> backup database include current controlfile format  '/home/oracle/backup/full_db_%U'  plus archivelog  format  '/home/oracle/backup/full_db_%U';


Starting backup at 05-JAN-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=60 device type=DISK
specification does not match any archived log in the repository
backup cancelled because there are no files to backup
Finished backup at 05-JAN-16

Starting backup at 05-JAN-16
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=00009 name=/data/app/oracle/oradata/orcl/pdborcl/sysaux01.dbf
input datafile file number=00008 name=/data/app/oracle/oradata/orcl/pdborcl/system01.dbf
input datafile file number=00010 name=/data/app/oracle/oradata/orcl/pdborcl/pdborcl_users01.dbf
channel ORA_DISK_1: starting piece 1 at 05-JAN-16
channel ORA_DISK_1: finished piece 1 at 05-JAN-16
piece handle=/home/oracle/backup/full_db_2eqqkb6b_1_1 tag=TAG20160105T155035 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 05-JAN-16
channel ORA_DISK_1: finished piece 1 at 05-JAN-16
piece handle=/home/oracle/backup/full_db_2fqqkb6i_1_1 tag=TAG20160105T155035 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 05-JAN-16

Starting backup at 05-JAN-16
using channel ORA_DISK_1
specification does not match any archived log in the repository
backup cancelled because there are no files to backup
Finished backup at 05-JAN-16

Starting Control File and SPFILE Autobackup at 05-JAN-16
piece handle=/data/app/oracle/recovery_area/ORCL/autobackup/2016_01_05/o1_mf_s_900345045_c8pxgo7c_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 05-JAN-16

结果如下:

RMAN> list backup;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
78      Full    675.54M    DISK        00:00:01     05-JAN-16      
        BP Key: 78   Status: AVAILABLE  Compressed: NO  Tag: TAG20160105T155035
        Piece Name: /home/oracle/backup/full_db_2eqqkb6b_1_1
  List of Datafiles in backup set 78
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  8       Full 2805476    05-JAN-16 /data/app/oracle/oradata/orcl/pdborcl/system01.dbf
  9       Full 2805476    05-JAN-16 /data/app/oracle/oradata/orcl/pdborcl/sysaux01.dbf
  10      Full 2805476    05-JAN-16 /data/app/oracle/oradata/orcl/pdborcl/pdborcl_users01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
79      Full    17.17M     DISK        00:00:01     05-JAN-16      
        BP Key: 79   Status: AVAILABLE  Compressed: NO  Tag: TAG20160105T155035
        Piece Name: /home/oracle/backup/full_db_2fqqkb6i_1_1
  Control File Included: Ckp SCN: 2805478      Ckp time: 05-JAN-16

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
80      Full    17.20M     DISK        00:00:00     05-JAN-16      
        BP Key: 80   Status: AVAILABLE  Compressed: NO  Tag: TAG20160105T155045
        Piece Name: /data/app/oracle/recovery_area/ORCL/autobackup/2016_01_05/o1_mf_s_900345045_c8pxgo7c_.bkp
  SPFILE Included: Modification time: 05-JAN-16
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 2805489      Ckp time: 05-JAN-16

RMAN>

模拟pdb库全库恢复

首先删除一个数据文件

SQL> !rm /data/app/oracle/oradata/orcl/pdborcl/pdborcl_users01.dbf

打开pdborcl,报错如下

SQL> alter pluggable database pdborcl open;
alter pluggable database pdborcl open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 10 - see DBWR trace file
ORA-01110: data file 10:
'/data/app/oracle/oradata/orcl/pdborcl/pdborcl_users01.dbf'

基于cdb恢复pdb库

连接rman

[oracle@xqzt ~]$ rman target /

restore pdborcl

RMAN> restore pluggable database pdborcl;

Starting restore at 05-JAN-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=46 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 00008 to /data/app/oracle/oradata/orcl/pdborcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00009 to /data/app/oracle/oradata/orcl/pdborcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00010 to /data/app/oracle/oradata/orcl/pdborcl/pdborcl_users01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/full_db_2iqqkbjf_1_1
channel ORA_DISK_1: piece handle=/home/oracle/backup/full_db_2iqqkbjf_1_1 tag=TAG20160105T155735
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 05-JAN-16

RMAN>

recover pdborcl

RMAN> recover pluggable database pdborcl;

Starting recover at 05-JAN-16
using channel ORA_DISK_1

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

Finished recover at 05-JAN-16

尝试打开数据库

RMAN> alter pluggable database pdborcl open;

Statement processed

 

如果rman 连接pdborcl,执行resotre pluggable database pdborcl 会报错如下

[oracle@xqzt ~]$ rman target sys/wangshengzhuang@pdborcl

Recovery Manager: Release 12.1.0.2.0 - Production on Tue Jan 5 16:17:23 2016

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

connected to target database: ORCL (DBID=1422060754, not open)

RMAN> restore pluggable database pdborcl;

Starting restore at 05-JAN-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=51 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 01/05/2016 16:17:47
RMAN-07538: Pluggable Database qualifier not allowed when connected to a Pluggable Database

本文转载自:http://www.cnblogs.com/xqzt/p/5102776.html

共有 人打赏支持
小强斋太
粉丝 0
博文 181
码字总数 0
作品 0
广州
oracle 12c pdb 恢复

备份数据库 [oracle@12cr2 ~]$ rman target / RMAN> backup database; RMAN> list backup summary; 数据库open状态,系统表空间损坏 -----故障模拟 [oracle@12cr2 ~]$ sqlplus / as sysdba ......

lych528
08/25
0
0
RMAN简明教程之五——RMAN还原和恢复

一、常规还原与恢复 RMAN 的整个恢复过程可以分为还原(restore)与恢复(recover) ,他们在含义上是有很大差别的,一个是指物理意义的文件的还原与拷贝,一个是指数据库一致性的恢复,所以...

晨曦之光
2012/03/09
0
0
ORA-01578和ORA-26040--NOLOGGING操作引起的坏块-错误解释和解决方案

(一)NOLOGGING操作引起的坏块(ORA-01578和ORA-26040)简介 如果只是错误ORA-01578,而没有伴随ORA-26040,那么这个坏块是由其它的原因引起的坏块,可以尝试使用RMAN的BMR(Block Media R...

小麦苗best
06/29
0
0
Oracle 12c DG备库Alert报错ORA-10877全库恢复

12C Oracle Data Guard 备库今天异常 2018-07-05T21:31:32.291970+08:00 GEN0 (ospid: 75371): terminating the instance due to error 472 2018-07-05T21:31:32.293376+08:00 System state ......

yangjunfeng
07/06
0
0
Oracle9i rman备份恢复总结

Recovery Manager(RMAN)是一种用于备份(backup)、还原(restore)和恢复(recover)数据库的Oracle 工.RMAN只能用于ORACLE8或更高的版本中。它能够备份整个数据库或数据库部件,如表空间、数据...

♂.Cent
2010/12/08
0
0

没有更多内容

加载失败,请刷新页面

加载更多

Windows 下双 Python 开发环境配置

Windows 下双 Python 开发环境配置作者:老农民(刘启华)QQ: 46715422Email: 46715422@qq.com微信: 46715422 本人曾经在 Windows 下被两个版本环境折腾够呛,现在总结两个 Python...

新疆老农民
昨天
2
0
CentOS7全局安装composer

1. 下载composer-setup.php到当前目录 php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" 2. 安装 php composer-setup.php 3. 将composer设置成全局 mv c......

月夜中徘徊
昨天
2
0
20180920上课截图

小丑鱼00
昨天
1
0
基于TCP的远程服务调用

前言 上篇,分析了基于HTTP方式的RPC调用。本篇将在上篇的基础上,分析基于TCP方式的RPC调用。代码的整体思路是一致的,可以看作是在上篇功能上的扩展——即通信的方式。 代码:https://git...

MarvelCode
昨天
2
0
67:shell脚本介绍 | shell脚本结构 | 执行data命令用法 | shell脚本中变量

1、shell脚本介绍: shell是一种脚本语言和传统的开发语言相比,会比较简单: shell有自己语法,可以支持逻辑判断、循环等语法: 可以自定义函数,目的是减少重复的代码: shell是系统命令的集合...

芬野de博客
昨天
3
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部