12C RMAN 备份参考
12C引进了pdb的概念,使得rman的恢复相对来说复杂了一些,这里对pdb的常规备份和恢复进行了简单测试,供大家参考
1.cdb启动和pdb关系测试
[oracle@xifenfei tmp]$ sqlplus / as sysdba SQL*Plus: Release 12.1.0.0.2 Copyright (c) 1982, 2012, Oracle. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.0.2 With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> startup ORACLE instance started. Total System Global Area 939495424 bytes Fixed Size Variable Size Database Buffers 268435456 Redo Database mounted. Database opened. SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID ---------- ---------- 2 3 4 5 SQL> alter pluggable database all open; Pluggable database altered. SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID ---------- ---------- 2 3 4 5 |
证明直接startup cdb里面的pdb不会自动open,需要手工进行open
2.rman使用cdb备份数据库
[oracle@xifenfei ~]$ rman target / Recovery Manager: Release 12.1.0.0.2 Copyright (c) 1982, 2012, Oracle and/or its affiliates. All rights reserved. connected to target database: xifenfei RMAN> backup filesperset = 5 as Starting backup at 12-DEC-12 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=259 device channel ORA_DISK_1: starting compressed channel ORA_DISK_1: specifying input datafile file number=00001 name=/u01/app/oracle/oradata/xifenfei/system01.dbf input datafile file number=00010 name=/u01/app/oracle/oradata/xifenfei/LX2/system01.dbf input datafile file number=00011 name=/u01/app/oracle/oradata/xifenfei/LX2/sysaux01.dbf channel ORA_DISK_1: starting piece 1 at channel ORA_DISK_1: finished piece 1 at piece handle=/tmp/full_db_06nsn3uq_1_1 tag=TAG20121212T213626 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45 channel ORA_DISK_1: starting compressed channel ORA_DISK_1: specifying input datafile file number=00019 name=/u01/app/oracle/oradata/xifenfei/xffexample01.dbf input datafile file number=00005 name=/u01/app/oracle/oradata/xifenfei/undotbs01.dbf input datafile file number=00007 name=/u01/app/oracle/oradata/xifenfei/LX1/system01.dbf input datafile file number=00018 input datafile file number=00008 name=/u01/app/oracle/oradata/xifenfei/LX1/sysaux01.dbf channel ORA_DISK_1: starting piece 1 at channel ORA_DISK_1: finished piece 1 at piece handle=/tmp/full_db_07nsn407_1_1 tag=TAG20121212T213626 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45 channel ORA_DISK_1: starting compressed channel ORA_DISK_1: specifying input datafile file number=00017 name=/u01/app/oracle/oradata/xifenfei/xffsysaux01.dbf input datafile file number=00002 name=/u01/app/oracle/oradata/xifenfei/pdbseed/system01.dbf input datafile file number=00004 name=/u01/app/oracle/oradata/xifenfei/pdbseed/sysaux01.dbf channel ORA_DISK_1: starting piece 1 at channel ORA_DISK_1: finished piece 1 at piece handle=/tmp/full_db_08nsn41l_1_1 tag=TAG20121212T213626 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15 channel ORA_DISK_1: starting compressed channel ORA_DISK_1: specifying input datafile file number=00003 name=/u01/app/oracle/oradata/xifenfei/sysaux01.dbf input datafile file number=00016 name=/u01/app/oracle/oradata/xifenfei/xffsystem01.dbf input datafile file number=00006 name=/u01/app/oracle/oradata/xifenfei/users01.dbf input datafile file number=00009 name=/u01/app/oracle/oradata/xifenfei/LX1/LX1_users01.dbf input datafile file number=00012 name=/u01/app/oracle/oradata/xifenfei/LX2/LX2_users01.dbf channel ORA_DISK_1: starting piece 1 at channel ORA_DISK_1: finished piece 1 at piece handle=/tmp/full_db_09nsn440_1_1 tag=TAG20121212T213626 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45 channel ORA_DISK_1: starting compressed channel ORA_DISK_1: specifying including current control file in backup set including current SPFILE in backup set channel ORA_DISK_1: starting piece 1 at channel ORA_DISK_1: finished piece 1 at piece handle=/tmp/full_db_0ansn45d_1_1 tag=TAG20121212T213626 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 12-DEC-12 RMAN> list backup summary; List of Backups =============== Key TY LV S Device Type ------- -- -- - ----------- 1 2 3 4 5 6 RMAN> report schema; Report of database schema for database with db_unique_name xifenfei List of Permanent Datafiles =========================== File Size(MB) ---- -------- 1 2 3 4 5 6 7 8 9 10 11 12 16 270 17 18 19 List of Temporary Files ======================= File Size(MB) ---- -------- 1 2 3 4 5 |
试验证明:通过rman通过cdb库的备份,可以实现对对应的cdb和所包含的pdb进行备份
3.配置pdb访问tns
[oracle@xifenfei ~]$ lsnrctl status LSNRCTL for Linux: Version 12.1.0.0.2 Copyright (c) 1991, 2012, Oracle. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xifenfei)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias Version Start Uptime Trace Security SNMP Listener Parameter File Listener Log Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=xifenfei)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=xifenfei)(PORT=5500))(Presentation=HTTP)(Session=RAW)) Services Summary... Service "ff" has 1 instance(s). Instance "xff", Service "xifenfei" has 1 instance(s). Instance "xff", Service "lx1" has 1 instance(s). Instance "xff", Service "lx2" has 1 instance(s). Instance "xff", Service "xffXDB" has 1 instance(s). Instance "xff", The command completed successfully [oracle@xifenfei admin]$ vi tnsnames.ora lx1 = (DESCRIPTION = (ADDRESS = (CONNECT_DATA = (SERVER (SERVICE_NAME ) ) ff = (DESCRIPTION = (ADDRESS = (CONNECT_DATA = (SERVER (SERVICE_NAME ) ) |
sqlplus访问pdb
[oracle@xifenfei admin]$ sqlplus sys@lx1 SQL*Plus: Release 12.1.0.0.2 Copyright (c) 1982, 2012, Oracle. Enter password: Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.0.2 With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> show con_name; CON_NAME ------------------------------ LX1 SQL> create user xff identified by xifenfei; User created. SQL> GRANT SYSDBA TO XFF; Grant succeeded. |
4.rman备份pdb数据库
[oracle@xifenfei admin]$ rman target Recovery Manager: Release 12.1.0.0.2 Copyright (c) 1982, 2012, Oracle and/or its affiliates. All rights reserved. connected to target database: xifenfei RMAN> backup filesperset = 5 as Starting backup at 12-DEC-12 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=256 device channel ORA_DISK_1: starting compressed channel ORA_DISK_1: specifying input datafile file number=00007 name=/u01/app/oracle/oradata/xifenfei/LX1/system01.dbf input datafile file number=00008 name=/u01/app/oracle/oradata/xifenfei/LX1/sysaux01.dbf input datafile file number=00009 name=/u01/app/oracle/oradata/xifenfei/LX1/LX1_users01.dbf channel ORA_DISK_1: starting piece 1 at channel ORA_DISK_1: finished piece 1 at piece handle=/tmp/lx1_db_0bnsn80f_1_1 tag=TAG20121212T224534 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25 Finished backup at 12-DEC-12 RMAN> report schema; Report of database schema for database with db_unique_name xifenfei List of Permanent Datafiles =========================== File Size(MB) ---- -------- 7 8 9 List of Temporary Files ======================= File Size(MB) ---- -------- 3 |
5.rman通过cdb备份pdb
[oracle@xifenfei admin]$ rman target / Recovery Manager: Release 12.1.0.0.2 Copyright (c) 1982, 2012, Oracle and/or its affiliates. All rights reserved. connected to target database: xifenfei RMAN> backup filesperset = 5 as Starting backup at 12-DEC-12 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=262 device channel ORA_DISK_1: starting compressed channel ORA_DISK_1: specifying input datafile file number=00017 name=/u01/app/oracle/oradata/xifenfei/xffsysaux01.dbf input datafile file number=00019 name=/u01/app/oracle/oradata/xifenfei/xffexample01.dbf input datafile file number=00016 name=/u01/app/oracle/oradata/xifenfei/xffsystem01.dbf input datafile file number=00018 name=/u01/app/oracle/oradata/xifenfei/xffSAMPLE_SCHEMA_users01.dbf channel ORA_DISK_1: starting piece 1 at channel ORA_DISK_1: finished piece 1 at piece handle=/tmp/ff_db_0cnsn8vm_1_1 tag=TAG20121212T230214 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:01:26 Finished backup at 12-DEC-12 |
6.模拟pdb库全库恢复
SQL> conn xff/xifenfei@lx1 as sysdba Connected. SQL> create table t_xifenfei as select * from dba_objects; Table created. SQL> select count(*) from t_xifenfei; COUNT(*) ---------- 19121 --在pdb中不能切换日志(因为日志是全局的) SQL> alter system switch logfile; alter system switch logfile * ERROR at line 1: ORA-65040: operation not allowed from within a pluggable database SQL> shutdown immediate; Pluggable Database closed. --删除数据文件 [oracle@xifenfei admin]$ rm --rman基于cdb恢复pdb库 [oracle@xifenfei ~]$ rman target / Recovery Manager: Release 12.1.0.0.2 Copyright (c) 1982, 2012, Oracle and/or its affiliates. All rights connected to target database: xifenfei (DBID=2412861330) RMAN> restore pluggable database lx1; Starting restore at 12-DEC-12 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=25 device channel ORA_DISK_1: starting datafile channel ORA_DISK_1: specifying channel ORA_DISK_1: restoring datafile channel ORA_DISK_1: restoring datafile channel ORA_DISK_1: restoring datafile channel ORA_DISK_1: reading from backup piece /tmp/lx1_db_0bnsn80f_1_1 channel ORA_DISK_1: piece channel ORA_DISK_1: restored backup piece channel ORA_DISK_1: restore complete, Finished restore at 12-DEC-12 RMAN> recover pluggable database lx1; Starting recover at 12-DEC-12 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: Finished recover at 12-DEC-12 RMAN> alter pluggable database lx1 open; Statement processed --验证恢复结果 SQL> conn xff/xifenfei@lx1 as sysdba Connected. SQL> select count(*) from t_xifenfei; COUNT(*) ---------- 19121 |
试验证明:对于pdb库的备份,使用rman可以在cdb级别进行还原和恢复
7.模拟数据文件恢复
SQL> create table t_xifenfei tablespace example 2 as 3 select * from dba_objects; Table created. SQL> select count(*) from t_xifenfei; COUNT(*) ---------- 89604 SQL> col name for a60 SQL> set lines 134 SQL> select file#,name from v$datafile; FILE# NAME ---------- ----------------------------------------------------------- 5 16 17 18 19 --离线含测试数据的数据文件 SQL> alter database datafile 19 offline; Database altered. --删除数据文件 SQL> !rm SQL> !ls -l ls: --尝试pdb级别恢复 [oracle@xifenfei ~]$ rman target Recovery Manager: Release 12.1.0.0.2 Copyright (c) 1982, 2012, Oracle and/or its affiliates. All rights connected to target database: xifenfei (DBID=2412861330) RMAN> restore datafile 19; Starting restore at 12-DEC-12 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=19 device RMAN-00571: RMAN-00569: =============== ERROR MESSAGE RMAN-00571: RMAN-03002: failure of restore command at 12/12/2012 RMAN-06026: some targets not found - aborting restore RMAN-06023: no backup or copy of datafile 19 found to restore --pdb级别不能识别对应数据文件(一种可能是我在cdb级别备份FF库,另一种可能bug) RMAN> list backup of datafile 19; specification does not match any backup in the repository --在cdb级别还原 [oracle@xifenfei tmp]$ rman target / Recovery Manager: Release 12.1.0.0.2 Copyright (c) 1982, 2012, Oracle and/or its affiliates. All rights connected to target database: xifenfei (DBID=2412861330) RMAN> list backup of datafile 19; using target database control file instead of recovery catalog List of Backup Sets =================== BS Key Type LV ------- ---- -- ---------- ----------- 3 BP Piece List of Datafiles in backup set 3 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- 19 BS Key Type LV ------- ---- -- ---------- ----------- 8 BP Piece List of Datafiles in backup set 8 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- 19 RMAN> restore datafile 19; Starting restore at 12-DEC-12 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=28 device channel ORA_DISK_1: starting datafile channel ORA_DISK_1: specifying channel ORA_DISK_1: restoring datafile channel ORA_DISK_1: reading from backup piece /tmp/ff_db_0cnsn8vm_1_1 channel ORA_DISK_1: piece channel ORA_DISK_1: restored backup piece channel ORA_DISK_1: restore complete, Finished restore at 12-DEC-12 --cdb级别恢复数据文件 RMAN> recover datafile 19; Starting recover at 12-DEC-12 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: Finished recover at 12-DEC-12 --cdb级别不能直接online RMAN> alter database datafile 19 online; RMAN-00571: RMAN-00569: =============== ERROR MESSAGE RMAN-00571: RMAN-03002: failure of sql statement command at 12/12/2012 ORA-01516: nonexistent log file, data RMAN> alter pluggable database ff datafile 19 RMAN-00571: RMAN-00569: =============== ERROR MESSAGE RMAN-00571: RMAN-03002: failure of sql statement command at 12/12/2012 ORA-65046: operation not allowed from outside a pluggable database --进入pdb库进行online SQL> alter database datafile 19 Database altered. --验证数据 SQL> select count(*) from t_xifenfei; COUNT(*) ---------- 89604 |
试验证明:rman通过cdb级别操作,还是一步步恢复了pdb中离线异常的数据文件
8.pdb数据库冷备恢复
pdb数据库冷备恢复不需要完全关闭cdb数据库,只需要pdb数据库启动到mounted状态即可。
1.确保需要冷备的pdb1的open mode是mounted状态
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB READ WRITE NO
4 PDB1 MOUNTED
2.备份pdb1
[oracle@ora12c cdb]$ cp -r pdb1 pdb_bak
3.删除pdb1
[oracle@ora12c cdb]$ rm -rf pdb1
4.把pdb1数据库open
SQL> alter pluggable database pdb1 open;
alter pluggable database pdb1 open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 44 - see DBWR trace file
ORA-01110: data file 44: '/u01/app/oracle/oradata/cdb/pdb1/pdb_users01.dbf'
5.利用冷备还原
[oracle@ora12c cdb]$ mv pdb_bak pdb1
6.重新把pdb1数据库open。
SQL> alter pluggable database pdb1 open;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB READ WRITE NO
4 PDB1 READ WRITE NO
-------------
pdb数据库冷备恢复不需要完全关闭cdb数据库,只需要pdb数据库启动到mounted状态即可。
1.确保需要冷备的pdb1的open mode是mounted状态
SQL> show pdbs
CON_ID CON_NAME OPEN MODE
RESTRICTED
---------- ------------------------------
---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB READ WRITE NO
4 PDB1 MOUNTED
2.备份pdb1
[oracle@ora12c cdb]$ cp -r pdb1 pdb_bak
3.删除pdb1
[oracle@ora12c cdb]$ rm -rf pdb1
4.把pdb1数据库open
SQL> alter pluggable database pdb1 open;
alter pluggable database pdb1 open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 44 -
see DBWR trace file
ORA-01110: data file 44:
'/u01/app/oracle/oradata/cdb/pdb1/pdb_users01.dbf'
5.利用冷备还原
[oracle@ora12c cdb]$ mv pdb_bak pdb1
6.重新把pdb1数据库open。
SQL> alter pluggable database pdb1 open;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE
RESTRICTED
---------- ------------------------------
---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB READ WRITE NO
4 PDB1 READ WRITE NO
12C RMAN 备份参考的更多相关文章
- 12C RMAN 备份参考v1
windows bat 1,C:\dba\utility\rman\rman.bat del C:\dba\utility\rman\full_db_* /qset TNSNAME=ceipuatrm ...
- Oracle 12c RMAN备份文档
创建备份目录,查看剩余空间 [cistest@cistest ~]$ df -h df: '/home/oratest/.gvfs': Permission denied Filesystem Siz ...
- Oracle 12c 的RMAN备份
备份 rman只备份cdb 只备份CDB数据库需要具有SYSDBA或SYSBACKUP权限用户连接到CDB的root环境下,执行backupdatabase root命令即可完成对CDB的备份,方法如 ...
- 【12c】12c RMAN新特性之通过网络远程恢复数据库(RESTORE/Recover from Service)
[12c]12c RMAN新特性之通过网络远程恢复数据库(RESTORE/Recover from Service) 通过网络远程恢复数据库(Restore/Recover from Service) ...
- DG环境数据库RMAN备份策略制定
DG环境数据库RMAN备份策略制定: 主库(Primary) 全库备份 归档备份 删除历史文件夹 备库(Standby) 删除归档 引用说明 主库(Primary) $ crontab -l 0 1 ...
- RMAN备份演练进阶篇
前篇介绍了通过rman进行各种备份,进阶篇则主要是rman的一些功能扩展和增加功能,利用前篇你已经完全可以完成数据库的备份,而通过本篇你可以更好更方便的完成数据库的备份. 一.建立增量备份 如果数据库 ...
- RMAN备份演练初级篇
前面我们已经知道了如何进入rman,以及rman的一些基本命令,相信大家定会觉着rman操作的简单,事实也确实如此,但万不要因此小视rman的强大,简单往往意味着灵活,灵活对于那些有心人则意味着主动权 ...
- Oracle RMAN备份恢复指导书
目 录 1 目的与范围... 1 2 术语和定义... 1 3 角色和职责... 2 4 使用RMAN备份数据库... 2 4.1.1 检查数据库模式... 2 4.1.2 连接到target数据库. ...
- RAC 之 RMAN 备份
这篇主要介绍的是RAC 环境下的RMAN 备份. 关于Oracle 备份与恢复的一些理论知识参考我的Blog: Oracle 备份 与 恢复 概述 http://blog.csdn.net ...
随机推荐
- Winform 让跨线程访问变得更简单
Winform 让跨线程访问变得更简单 前言 由于多线程可能导致对控件访问的不一致,导致出现问题.C#中默认是要线程安全的,即在访问控件时需要首先判断是否跨线程,如果是跨线程的直接访问,在运行时会抛出 ...
- SSD Buffer Pool Extension
SSD Buffer Pool Extension 简介 SQL Server 2014中另一个非常好的功能是,可以将SSD虚拟成内存的一部分,来供SQL Server数据页缓冲区使用.通过使用SSD ...
- POJ 1013 小水题 暴力模拟
Counterfeit Dollar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 35774 Accepted: 11 ...
- 刨根问底儿 -- intVal($str) 跟 (int) $str 的运算结果有什么区别
intVal($str) 跟 (int) $str 都是把其他类型的变量转化为int型变量的方式,这么多年来我一直森森滴怀疑它们的运算结果在某些条件下会有区别.对于我的疑问,文档里也没有多说(或者我没 ...
- Ubuntu12.10 下搭建基于KVM-QEMU的虚拟机环境(八)
Libvirt 是用c写的一个管理虚拟机及其资源(如网络.存储和外设等)的工具库,它不仅支持KVM/QEMU,它还支持xen,Vmware,OpenVZ和VirtualBox等其他HyperVisor ...
- JMX操作ActiveMQ(2)
默认情况下,ActiveMQ使用useJmx后,jmx的url为 service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi 这时,jmx的MBean se ...
- 获取Exception的详细信息
转自:http://blog.csdn.net/long95wang/article/details/8089489 方法一: public static String getExceptionAll ...
- .Net多线程编程—同步机制
1.简介 新的轻量级同步原语:Barrier,CountdownEvent,ManualResetEventSlim,SemaphoreSlim,SpinLock,SpinWait.轻量级同步原语只能 ...
- Node.js学习笔记(二):模块
模块是 Node.js 应用程序的基本组成部分,文件和模块是一一对应的.一个 Node.js 文件就是一个模块,这个文件可能是 JavaScript 代码.JSON 或者编译过的 C/C++ 扩展. ...
- 用备份控制文件做不完全恢复下的完全恢复(全备<老>--备份控制文件<次新>--删除表空间andy--日志文件<新>)
为什么会使用备份的控制文件? 实际工作中主要有两种情况:第一种:当前控制文件全部损坏,而数据文件备份,控制文件备份及当前日志处于不同SCN版本,它们之间又增加过表空间(数据文件).第二种:当前控制文件 ...