文档章节

Oracle 12c: RMAN restore/recover pluggable database

小强斋太
 小强斋太
发布于 2016/11/09 20:05
字数 2299
阅读 129
收藏 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
上一篇: Oracle中的rowid
下一篇: 数据结构---->栈
小强斋太
粉丝 0
博文 181
码字总数 0
作品 0
广州
私信 提问
加载中
请先登录后再评论。
【12c】12c RMAN新特性之recover table(表级别恢复)

【12c】12c RMAN新特性之recover table(表级别恢复) 在 RMAN 中提供了表级别恢复( RECOVER TABLE )。在 Oracle 12c 中,在发生 drop 或 truncate 的情况下,可以从 RMAN 备份种将一个特定...

小麦苗
07/09
0
0
RMAN-20208: UNTIL CHANGE is before RESETLOGS change

执行recover操作时: RMAN> recover database; Starting recover at 28-NOV-19 using channel ORADISK1 starting media recovery channel ORADISK1: starting archived log restore to defa......

osc_20n6g71c
2019/11/28
1
0
【12c】12c RMAN新特性之通过网络远程恢复数据库(RESTORE/Recover from Service)

【12c】12c RMAN新特性之通过网络远程恢复数据库(RESTORE/Recover from Service) database from service <服务别名> tablespace from service <服务别名> controlfile to '指定的位置' fro......

osc_d5exiys5
2018/07/13
2
0
Oracle9i Recovery Manager (RMAN)

Recovery manager is a platform independent utility for coordinating your backup and restoration procedures across multiple servers. In my opinion it's value is limited if you on......

♂.Cent
2010/12/08
185
0
dataguard从库数据库丢失恢复例子(模拟丢失数据文件)

准备工作,使用如下脚本进行数据库的全备份 [oracle@localhost ~]$ more rman_backup.sh #!/bin/sh RMANOUTPUTLOG=/home/oracle/rmanoutput.log RMANERRORLOG=/home/oracle/rmanerror.log rm......

osc_2mwrwkro
2019/01/14
2
0

没有更多内容

加载失败,请刷新页面

加载更多

SpringCloud 应用在 Kubernetes 上的最佳实践 — 开发篇

作者 | 孤弋 阿里云高级技术专家,负责 EDAS 的开发和用户体验优化工作。 前言 近年来,云原生、Kubernetes、微服务、SpringCloud 这些名词在技术圈内不绝于耳,数据显示,使用 SpringCloud ...

阿里云技术博客
8分钟前
0
0
如何能够高效率学习Web前端技术

  Web前端开发作为前端技术的重要组成,一直占据着重要的地位,整个IT行业内有大量的前端开发从业者,随着移动互联网、大数据和人工智能的发展,目前前端的知识体系也在逐渐丰富。   要想...

SXXpenguin
8分钟前
0
0
Spring Boot 2.3.0正式发布:优雅停机、配置文件位置通配符新特性一览

当大潮退去,才知道谁在裸泳。。关注公众号【BAT的乌托邦】开启专栏式学习,拒绝浅尝辄止。本文 https://www.yourbatman.cn 已收录,里面一并有Spring技术栈、MyBatis、中间件等小而美的专栏...

osc_odp8kgup
9分钟前
0
0
HttpMessageConverter是这样转换数据的

Java Web 人员经常要设计 RESTful API(如何设计好的RESTful API),通过 json 数据进行交互。那么前端传入的 json 数据如何被解析成 Java 对象作为 API入参,API 返回结果又如何将 Java 对象...

tan日拱一兵
2019/05/27
0
0
angular浏览器兼容性问题解决方案

问题:edge浏览器下,固定列的边框消失 原因:ng-zorro-antd表格组件使用nzLeft和nzRight指令固定的表格列,这两个指令的实现css3中的标签: position: -webkit-sticky !important;positio...

osc_elbmybcg
10分钟前
10
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部