文档章节

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

共有 人打赏支持
上一篇: Oracle中的rowid
下一篇: 数据结构---->栈
小强斋太
粉丝 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
oracle 备份恢复 07rman不完全恢复

不完全恢复:将数据库恢复到过去的某个时间点或者SCN点 一、实验环境 1.开归档 2.实验操作 create table scott.lxtb3 tablespace lxtb as select * from scott.emp; insert into scott.lxtb3...

PeakFang-BOK
10/14
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
RMAN简明教程之五——RMAN还原和恢复

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

晨曦之光
2012/03/09
0
0
oracle 备份恢复 06ramn完全恢复

一、搭建实验环境 1.创建8张表scott.lxtb1-lxtb8 create table scott.lxtb9 tablespace lxtb as select * from scott.emp; 2.3DML操作 insert into scott.lxtb9 select * from scott.emp; c......

PeakFang-BOK
10/14
0
0

没有更多内容

加载失败,请刷新页面

加载更多

开源 java CMS - FreeCMS2.8会员注册

项目地址:http://www.freeteam.cn/ 会员注册 打开浏览器,输入http://www.freeteam.cn/register.jsp。 输入注册信息后点击“注册”按钮。...

freeteam
6分钟前
0
0
sql笔记——查询

查询语句: SELECT [ALL|DISTINCT]<目标列表达式>[,<目标列表达式>]... FROM <表名或这视图名>[,<表名或这视图名>]... [WHERE<条件表达式>] [GROUP BY <列名 1>[HAVING<条件表达式>]] [ORDE......

Carbenson
8分钟前
1
0
OSChina 周二乱弹 —— 哥们之间报恩的想法被上帝实现了

Osc乱弹歌单(2018)请戳(这里) 【今日歌曲】 小小编辑:推荐歌曲《消愁》 《消愁》- 毛不易 手机党少年们想听歌,请使劲儿戳(这里) @过遥 :周一的早上就应该用来补觉,太困了 周末不想...

小小编辑
今天
418
10
MariaDB 服务器在 MySQL Workbench 备份数据的时候出错如何解决

服务器是运行在 MariaDB 10.2 上面的,在使用 MySQL Workbench 出现错误: mysqldump: Couldn't execute 'SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM, '$."number-of-buckets-specified"'......

honeymose
今天
3
0
apache顶级项目(二) - B~C

apache顶级项目(二) - B~C https://www.apache.org/ Bahir Apache Bahir provides extensions to multiple distributed analytic platforms, extending their reach with a diversity of s......

晨猫
今天
7
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部