RMAN恢复实践
 
RMAN> list backup;

using target database control file instead of recovery catalog

List of Backup Sets

===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

1       Full    964.65M    DISK        00:02:07     19-SEP-13     

        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20130919T011640

        Piece Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/2013_09_19/o1_mf_nnndf_TAG20130919T011640_93odqb65_.bkp

  List of Datafiles in backup set 1

  File LV Type Ckp SCN    Ckp Time  Name

  ---- -- ---- ---------- --------- ----

  1       Full 838482     19-SEP-13 /u01/app/oracle/oradata/august/august/system01.dbf

  2       Full 838482     19-SEP-13 /u01/app/oracle/oradata/august/august/sysaux01.dbf

  3       Full 838482     19-SEP-13 /u01/app/oracle/oradata/august/august/undotbs01.dbf

  4       Full 838482     19-SEP-13 /u01/app/oracle/oradata/august/august/users01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

------- ---- -- ---------- ----------- ------------ ---------------

2       Full    9.36M      DISK        00:00:08     19-SEP-13     

        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20130919T011640

        Piece Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/2013_09_19/o1_mf_ncsnf_TAG20130919T011640_93odvkkc_.bkp

  SPFILE Included: Modification time: 19-SEP-13

  SPFILE db_unique_name: AUGUST

  Control File Included: Ckp SCN: 838535       Ckp time: 19-SEP-13
 
2. 归档当前日志 
SQL> alter system switch logfile; 

SQL> select sequence#,first_change#,next_change# ,archived from v$archived_log;

 SEQUENCE# FIRST_CHANGE# NEXT_CHANGE# ARCHIV

---------- ------------- ------------ ------

         2        757280       767227 YES

         3        767227       780016 YES

         4        780016       811911 YES

         5        811911       835483 YES

         6        835483       840784 YES
 
3. 在新的日志文件中,进行DML操作。 
SQL> create table scott.rman_test1(id int,name char(10));

SQL> select * from scott.rman_test1;

        ID NAME

---------- --------------------

         1 log1

         1 log1

         1 log1

         1 log1

         1 log1

         1 log1
 
将表scott.rman_test1操作日志归档。
SQL> alter system switch logfile;

SQL> select sequence#,first_change#,next_change# from v$archived_log;

SEQUENCE# FIRST_CHANGE# NEXT_CHANGE#

---------- ------------- ------------

......

         6        835483       840784

         7        840784       841197 
在新的日志中,进行scott.rman_test2的创建,不对此日志归档,log sequence 8.
SQL> create table scott.rman_test2 as select table_name from user_tables; 
此时在线日志8中有rman_test2,归档日志7中有rman_test1.
 
4. 使用rman进行不完整恢复到归档日志7. 
注:rman restore操作需要在mount下进行,不然会报错。 
RMAN> restore database;

Starting restore at 19-SEP-13

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=44 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 00001 to /u01/app/oracle/oradata/august/august/system01.dbf

channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/august/august/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/august/august/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/august/august/users01.dbf

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/2013_09_19/o1_mf_nnndf_TAG20130919T011640_93odqb65_.bkp

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of restore command at 09/19/2013 20:38:42

ORA-19870: error while restoring backup piece /u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/2013_09_19/o1_mf_nnndf_TAG20130919T011640_93odqb65_.bkp

ORA-19573: cannot obtain exclusive enqueue for datafile 1
 
 
关闭数据库,启动到mount
RMAN> shutdown immediate                     /*RMAN下可以进行shutdown, startup命令*/

database closed

database dismounted

Oracle instance shut down

RMAN> startup mount;

connected to target database (not started)

Oracle instance started

database mounted

Total System Global Area     422670336 bytes

Fixed Size                     1336960 bytes

Variable Size                322963840 bytes

Database Buffers              92274688 bytes

Redo Buffers                   6094848 bytes
 
 
查看备份集信息概要。
RMAN> list backup summary;

List of Backups

===============

Key     TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag

------- -- -- - ----------- --------------- ------- ------- ---------- ---

1       B  F  A DISK        19-SEP-13       1       1       NO         TAG20130919T011640

2       B  F  A DISK        19-SEP-13       1       1       NO         TAG20130919T011640
 
 
恢复备份文件
 
-rw-r-----. 1 Oracle oinstall    9830400 Sep 19 01:18 o1_mf_ncsnf_TAG20130919T011640_93odvkkc_.bkp

-rw-r-----. 1 Oracle oinstall 1011515392 Sep 19 01:18 o1_mf_nnndf_TAG20130919T011640_93odqb65_.bkp

RMAN> restore database;

Starting restore at 19-SEP-13

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=19 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 00001 to /u01/app/oracle/oradata/august/august/system01.dbf

channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/august/august/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/august/august/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/august/august/users01.dbf

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/2013_09_19/o1_mf_nnndf_TAG20130919T011640_93odqb65_.bkp

channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/august/AUGUST/backupset/2013_09_19/o1_mf_nnndf_TAG20130919T011640_93odqb65_.bkp tag=TAG20130919T011640

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:03:45

Finished restore at 19-SEP-13
 
 
介质恢复(相当于db2中的前滚操作)
 
RMAN> recover database until;
RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-00558: error encountered while parsing input commands

RMAN-01009: syntax error: found ";": expecting one of: "scn, sequence, time"

RMAN-01007: at line 1 column 23 file: standard input
可以看出RMAN中recover database until 后面可以按三种方式前滚(SCN,SEQUENCE,TIME).
这里我们按照sequence方式恢复(前滚)。
查看归档日志情况。
RMAN> list archivelog all;

List of Archived Log Copies for database with db_unique_name AUGUST

=====================================================================

Key     Thrd Seq     S Low Time

------- ---- ------- - ---------

1       1    2       A 15-SEP-13

        Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_15/o1_mf_1_2_93cc8thy_.arc

2       1    3       A 15-SEP-13

        Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_15/o1_mf_1_3_93ck0mxm_.arc

3       1    4       A 15-SEP-13

        Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_16/o1_mf_1_4_93ftwxqj_.arc

4       1    5       A 16-SEP-13

        Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_19/o1_mf_1_5_93o9xt7k_.arc

5       1    6       A 19-SEP-13

        Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_19/o1_mf_1_6_93qgls17_.arc

6       1    7       A 19-SEP-13

        Name: /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_19/o1_mf_1_7_93qh7sqx_.arc
 
 
前滚恢复。 
RMAN> recover database until sequence 7;

Starting recover at 19-SEP-13

using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 6 is already on disk as file /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_19/o1_mf_1_6_93qgls17_.arc

archived log file name=/u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_19/o1_mf_1_6_93qgls17_.arc thread=1 sequence=6

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

Finished recover at 19-SEP-13
/*好像只恢复到log 7就停止了*/ 
RMAN> recover database until sequence 8; 

Starting recover at 19-SEP-13

using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 7 is already on disk as file /u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_19/o1_mf_1_7_93qh7sqx_.arc

archived log file name=/u01/app/oracle/flash_recovery_area/august/AUGUST/archivelog/2013_09_19/o1_mf_1_7_93qh7sqx_.arc thread=1 sequence=7

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

Finished recover at 19-SEP-13 
/*看来需要指定到需要日志的下一个sequence*/ 
察看当前日志情况。
SQL> select sequence#,archived,status,first_change#,next_change# from v$log;

 SEQUENCE# ARCHIV STATUS                           FIRST_CHANGE# NEXT_CHANGE#

---------- ------ -------------------------------- ------------- ------------

         7 YES    INACTIVE                                840784       841197

         6 YES    INACTIVE                                835483       840784

         8 NO     CURRENT                                 841197   2.8147E+14
 
 
我们采用不完全恢复,不应用8号日志,直接打开数据库。
 
RMAN> alter database open resetlogs;
 
database opened
 
数据库完成恢复,由于是resetlogs模式打开的,查看当前日志状态。
SQL> select sequence#,archived,status,first_change#,next_change# from v$log;
SEQUENCE# ARCHIV STATUS                           FIRST_CHANGE# NEXT_CHANGE#

---------- ------ -------------------------------- ------------- ------------

         1 NO     CURRENT                                 841198   2.8147E+14

         0 YES    UNUSED                                       0            0

         0 YES    UNUSED                                       0            0
 
 
日志被reset从1号开始了。
 
看到恢复后的用户表情况。
 
SQL> select table_name from user_tables;
 
TABLE_NAME

------------------------------------------------------------

RMAN_TEST1

T_C

T_P

SALGRADE

BONUS

EMP

DEPT
 
看到RMAN_TEST1表已经被恢复回来了。但是里面没有数据,因为我们之前并没有commit这个插入。
 
 
 
 

RMAN数据库恢复测试的更多相关文章

  1. RMAN基础恢复测试

    --RMAN恢复测试实战   RMAN> list backup;   using target database control file instead of recovery catalo ...

  2. RMAN数据库恢复 之归档模式有(无)备份-丢失数据文件的恢复

    1.归档模式有备份,丢失数据文件的恢复归档模式有备份,不管丢失什么数据文件,直接在RMAN下RESTOER--->RECOVER--->OPEN即可. RMAN> STARUP MO ...

  3. rman数据库恢复;关键/非重要文件、影像副本、控制文件、还原点、非归档、增量、新数据库、灾难性回复

    运行全然恢复:在 ARCHIVELOG 模式下 丢失了系统重要数据文件: 假设某个数据文件丢失或损坏.且该文件属于 SYSTEM 或 UNDO 表空间,请运行下面步骤: 1. 实例可能会也可能不会自己 ...

  4. RMAN备份介质的移动与再恢复测试 [ catalog start with ‘dir’ ]

    --RMAN备份介质的移动与再恢复测试 ---------------------------------------------------------2013/09/21   由于目前生产环境中没 ...

  5. Oracle之使用rman进行异机恢复测试记录

    本次测试目的是从生产数据库导出rman备份然后在测试数据库恢复 1,拷贝备份至相应目录 2,进入rman rman target \ 3,关闭数据库 shutdown 4,以nomount模式启动数据 ...

  6. oracle 11g 数据库恢复技术 --rman catalog

    Oracle RMAN的catalog并不是指标备份恢复操作的一个必要组件,但oracle推荐使用该组件.启用之后,归档日志.备份集.镜像复制等备份信息的保存地点是RMAN资料库(catalog), ...

  7. RMAN数据库恢复之对数据库进行完全介质恢复

    RMAN数据库恢复之对数据库进行完全介质恢复环境:控制文件和参数文件SPFILE及归档文件.重做日志文件都在.其它数据文件丢失.恢复方法:使用之前创建的全库备份进行恢复1.删除数据文件: SQL> ...

  8. Oracle之rman数据库在非归档模式下的备份和恢复

    1.数据库在非归档模式下的备份 SQL> archive log list;数据库日志模式 非存档模式自动存档 禁用存档终点 USE_DB_RECOVERY_FILE_DEST最早的联机日志序列 ...

  9. 使用zfs进行pg的pitr恢复测试

    前段时间做了一下zfs做pg的增量恢复测试,mark一下. 服务器信息: 主机:192.168.173.43 备机:192.168.173.41 主备使用流复制搭建,在备机上面进行了zfs快照备份. ...

随机推荐

  1. 简单来说一下ui-route

    UI-Router被认为是AngularUI为开发者提供的最实用的一个模块,它是一个让开发者能够根据URL状态或者说是'机器状态'来组织和控制界面UI的渲染,而不是仅仅只改变路由(传统AngularJ ...

  2. Vuejs——v-on

    版权声明:出处http://blog.csdn.net/qq20004604   目录(?)[+]   资料来于官方文档: http://cn.vuejs.org/guide/events.html ...

  3. updateByPrimaryKey和updateByPrimaryKeySelective insert和insertSelective

    这两个update都是使用generator生成的mapper.xml文件中,对dao层的更新操作 updateByPrimaryKey对你注入的字段全部更新(不判断是否为Null) updateBy ...

  4. 在ASP.NET MVC中利用Aspose.cells 将查询出的数据导出为excel,并在浏览器中下载。

    正题前的唠叨 本人是才出来工作不久的小白菜一颗,技术很一般,总是会有遇到一些很简单的问题却不知道怎么做,这些问题可能是之前解决过的.发现这个问题,想着提升一下自己的技术水平,将一些学的新的'好'东西记 ...

  5. Echarts报错[MODULE_MISS]"echarts/config" is not exists!

    项目用到Echarts插件,时下比较流行的是模块化包引入,但是很悲催的是楼主用的是标签式引入,所以从官网copy来的代码总是报一个 [MODULE_MISS]"echarts/config的 ...

  6. c++调用python系列(1): 结构体作为入参及返回结构体

    最近在打算用python作测试用例以便对游戏服务器进行功能测试以及压力测试; 因为服务器是用c++写的,采用的TCP协议,当前的架构是打算用python构造结构体,传送给c++层进行socket发送给 ...

  7. CentOS-7.2添加桌面快捷方式

    一,在桌面新建一个文件 文件名随意,但必须带有.desktop的后缀名. gedit /home/zgw/Desktop/zgw.desktop 二,在文件中写入如下内容 [Desktop Entry ...

  8. 本地Server发布外网Web应用(Oray实现)

    主要讲解如何将本地当做服务器,发布Web应用至外网访问.   准备条件: 1.web应用服务(此处为Tomcat作为web应用服务器): 2.花生壳应用:   第一步,正常搭建本地web项目,应用名为 ...

  9. 工程经验总结之吹水"管理大境界"

    1.个人认为项目管理最核心的能力是预见风险和快速解决风险的能力. 从实践来看,没有百分百的完美计划,任何计划都有出现偏差的可能,或者说计划总是不会按照最初的设定去完美执行的. 项目经理存在的主要价值就 ...

  10. UWP中使用Composition API实现吸顶(2)

    在上一篇中我们讨论了不涉及Pivot的吸顶操作,但是一般来说,吸顶的部分都是Pivot的Header,所以在此我们将讨论关于Pivot多个Item关联同一个Header的情况. 老样子,先做一个简单的 ...