12C RMAN 备份参考v1
windows bat
1,C:\dba\utility\rman\rman.bat
del C:\dba\utility\rman\full_db_* /q
set TNSNAME=ceipuat
rman target /@%TNSNAME% cmdfile=C:\dba\utility\rman\rman.cmd
2.C:\dba\utility\rman\rman.cmd
backup filesperset = 5 as compressed backupset database format 'C:\dba\utility\rman\full_db_%U' plus archivelog delete all input format 'C:\dba\utility\rman\full_db_arch_%U';
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 备份参考v1的更多相关文章
- 12C RMAN 备份参考
12C引进了pdb的概念,使得rman的恢复相对来说复杂了一些,这里对pdb的常规备份和恢复进行了简单测试,供大家参考 1.cdb启动和pdb关系测试 [oracle@xifenfei tmp]$ s ...
- Oracle 12c RMAN备份文档
创建备份目录,查看剩余空间 [cistest@cistest ~]$ df -h df: '/home/oratest/.gvfs': Permission denied Filesystem Siz ...
- Oracle RAC 实验环境RMAN备份v1.01
Oracle RAC 实验环境RMAN备份v1.01 环境:RHEL 6.5 + Oracle GI 11.2.0.4 + RAC 11.2.0.4 (2 nodes) 需求:制定RAMN备份策略 版 ...
- 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数据库. ...
随机推荐
- OpenCV249 for python278 最简配置方案
跟很多开源软件一样OpenCV也提供了完善的Python接口,非常便于调用.OpenCV 包含了超过 2500 个算法和函数,几乎任何一个能想到的成熟算法都可以通过调用OpenCV的函数来实现,超级方 ...
- ACM Skiing问题
ACM Skiing问题 描述 Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你.Michae ...
- C#基础原理拾遗——引用类型的值传递和引用传递
C#基础原理拾遗——引用类型的值传递和引用传递 以前写博客不深动,只搭个架子,像做笔记,没有自己的思考,也没什么人来看.这个毛病得改,就从这一篇开始… 最近准备面试,深感基础之重要,奈何我不是计算机科 ...
- 搭建WEB邮件系统,爆强!
Linux+postfix+extmail+dovecot打造基于web页面的邮件系统 原文地址: http://blog.csdn.net/deansrk/article/details/67177 ...
- [置顶] Android系统移植与调试之------->Amlogic方案编译步骤
1. 拷贝Amlogic的SourceCode 切换目录到 /home/roco/work/amlogic/SourceCode/mx0831-0525下将mx0831-0525.tgz拷贝到 / ...
- message from server: "Host 'xxx' is not allowed to connect to this MySQL server的解决
解决方法: 1. 改表法. 可能是你的帐号不允许从远程登陆,只能在localhost.这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" ...
- swift设置textfield边框颜色
//swift3.0,如果是2.0的话也可以照着这个样子去写,语法有所变动.根据联想出来的就可以了. let tx = UITextField(frame: CGRect(x: 100, y: 100 ...
- [HMLY]9.深入浅出-iOS Reactive Cocoa的常见用法
简介 今天的主角是Reactive Cocoa,聊聊Reactive Cocoa的常见使用:KVO.Target.Delegate.Notification. Reactive Cocoa 是一个重量 ...
- python3的文件读写模式
任何一种语言,文件的读写都是非常常见的.python的文件读写非常简单,仅仅一个函数open(file也可以,但是我不常用). 先看看官网的解释: open(file, mode='r', buffe ...
- js的eval函数解析后台返回的json数据时为什加上圆括号eval("("+data+")"),而HTML页面定义的数据不用
一,情况如下,这是成功代码: $(function () { $.ajax({ url: "Demo.aspx", type: "post", data: { ...