1.RMAN 备份脚本

RUN {

 CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF  7  DAYS;

 CONFIGURE CONTROLFILE AUTOBACKUP ON;

 CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO "/backup/ZGW_Controlfile_%F";

 ALLOCATE CHANNEL CH1 DEVICE TYPE DISK;

 ALLOCATE CHANNEL CH2 DEVICE TYPE DISK;

 BACKUP DATABASE FORMAT "/backup/ZGW_%U"

     SKIP INACCESSIBLE FILESPERSET 10

     PLUS ARCHIVELOG FILESPERSET 20

     DELETE ALL INPUT;

 RELEASE CHANNEL CH1;

 RELEASE CHANNEL CH2;

 }

 BACKUP SPFILE FORMAT '/backup/ZGW_spfile_%U.bak'; 

 ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;

 CROSSCHECK BACKUPSET;

 DELETE NOPROMPT OBSOLETE;

2.执行备份

 export ORACLE_SID=zgw
rman target / @/home/oracle/scipts/rman_backup.rman

3.备份数据打包并传输

tar czvf zgw.tar.gz /ackup/ZGW*
scp zgw.tar.gz 192.168.199.68:/home/oracle/backup/

4.异机恢复环境准备

#环境变量
export ORACLE_SID=zgw
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/11g #由于只安装软件未创建数据库所以需创建对应文件夹
mkdir -p $ORACLE_BASE/admin/zgw/adump/
mkdir -p $ORACLE_BASE/admin/zgw/dpdump/
mkdir -p $ORACLE_BASE/admin/zgw/pfile/
mkdir -p $ORACLE_BASE/oradata/zgw/
mkdir -p $ORACLE_BASE/flash_recovery_area
mkdir -p $ORACLE_BASE/flash_recovery_area/zgw

5.恢复操作

$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Thu May 28 16:27:19 2015

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> startup nomount;

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/opt/oracle/11g/dbs/initzgw.ora' starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started Total System Global Area 158662656 bytes Fixed Size 2211448 bytes
Variable Size 88080776 bytes
Database Buffers 62914560 bytes
Redo Buffers 5455872 bytes RMAN> restore spfile from '/home/oracle/backup/ZGW_spfile_0pq82u8b_1_1.bak'; //恢复spfile文件
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
RMAN> startup nomount force; RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 05/28/2015 16:33:12
RMAN-04014: startup failed: ORA-01261: Parameter db_recovery_file_dest destination string cannot be translated
ORA-01262: Stat failed on a file destination directory
Linux-x86_64 Error: 2: No such file or directory mkdir -p $ORACLE_BASE/flash_recovery_area
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
RMAN> startup nomount force; //重启实例到nomount状态 Oracle instance started Total System Global Area 776646656 bytes Fixed Size 2217384 bytes
Variable Size 532679256 bytes
Database Buffers 239075328 bytes
Redo Buffers 2674688 bytes
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
RMAN> restore controlfile from '/home/oracle/backup/ZGW_Controlfile_c-4066279841-20150528-03'; Starting restore at 28-MAY-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK channel ORA_DISK_1: restoring control file
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 05/28/2015 16:40:45
ORA-19504: failed to create file "/opt/oracle/flash_recovery_area/zgw/control02.ctl"
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
ORA-19600: input file is control file (/opt/oracle/oradata/zgw/control01.ctl)
ORA-19601: output file is control file (/opt/oracle/flash_recovery_area/zgw/control02.ctl) mkdir -p $ORACLE_BASE/flash_recovery_area/zgw
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
RMAN> restore controlfile from '/home/oracle/backup/ZGW_Controlfile_c-4066279841-20150528-03'; //还原控制文件 Starting restore at 28-MAY-15
using channel ORA_DISK_1 channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/opt/oracle/oradata/zgw/control01.ctl
output file name=/opt/oracle/flash_recovery_area/zgw/control02.ctl
Finished restore at 28-MAY-15 RMAN> sql 'alter database mount'; //启动数据库到mount状态 sql statement: alter database mount
released channel: ORA_DISK_1 RMAN> list backup of database; //查看备份集 List of Backup Sets
=================== BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
16 Full 988.79M DISK 00:01:35 28-MAY-15
BP Key: 16 Status: AVAILABLE Compressed: NO Tag: TAG20150528T135534
Piece Name: /backup/0hq82s2m_1_1
List of Datafiles in backup set 16
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1081536 28-MAY-15 /opt/oracle/oradata/zgw/system01.dbf
2 Full 1081536 28-MAY-15 /opt/oracle/oradata/zgw/sysaux01.dbf
3 Full 1081536 28-MAY-15 /opt/oracle/oradata/zgw/undotbs01.dbf
4 Full 1081536 28-MAY-15 /opt/oracle/oradata/zgw/users01.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
20 Full 396.28M DISK 00:01:14 28-MAY-15
BP Key: 20 Status: AVAILABLE Compressed: NO Tag: TAG20150528T143051
Piece Name: /backup/ZGW_0mq82u4r_1_1
List of Datafiles in backup set 20
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 1083181 28-MAY-15 /opt/oracle/oradata/zgw/sysaux01.dbf
3 Full 1083181 28-MAY-15 /opt/oracle/oradata/zgw/undotbs01.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
21 Full 592.91M DISK 00:01:37 28-MAY-15
BP Key: 21 Status: AVAILABLE Compressed: NO Tag: TAG20150528T143051
Piece Name: /backup/ZGW_0lq82u4r_1_1
List of Datafiles in backup set 21
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1083180 28-MAY-15 /opt/oracle/oradata/zgw/system01.dbf
4 Full 1083180 28-MAY-15 /opt/oracle/oradata/zgw/users01.dbf +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
RMAN> restore database from '/home/oracle/backup/ZGW_0mq82u4r_1_1'; Starting restore at 28-MAY-15
Starting implicit crosscheck backup at 28-MAY-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
Crosschecked 9 objects
Finished implicit crosscheck backup at 28-MAY-15 Starting implicit crosscheck copy at 28-MAY-15
using channel ORA_DISK_1
Finished implicit crosscheck copy at 28-MAY-15 searching for all files in the recovery area
cataloging files...
no files cataloged using channel ORA_DISK_1 RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 05/28/2015 16:50:44
RMAN-06509: only SPFILE or control file can be restored from AUTOBACKUP

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

RMAN> catalog start with '/home/oracle/backup/'; //将备份集导入控制文件,此处适用于异机还原时备份集没有在默认位置的场景。 searching for all files that match the pattern /home/oracle/backup/ List of Files Unknown to the Database
=====================================
File Name: /home/oracle/backup/ZGW_0mq82u4r_1_1
File Name: /home/oracle/backup/ZGW_spfile_0pq82u8b_1_1.bak
File Name: /home/oracle/backup/ZGW_0lq82u4r_1_1
File Name: /home/oracle/backup/ZGW_Controlfile_c-4066279841-20150528-03
File Name: /home/oracle/backup/ZGW_Controlfile_c-4066279841-20150528-04
File Name: /home/oracle/backup/zgw.tar.gz Do you really want to catalog the above files (enter YES or NO)? y
cataloging files...
cataloging done List of Cataloged Files
=======================
File Name: /home/oracle/backup/ZGW_0mq82u4r_1_1
File Name: /home/oracle/backup/ZGW_spfile_0pq82u8b_1_1.bak
File Name: /home/oracle/backup/ZGW_0lq82u4r_1_1
File Name: /home/oracle/backup/ZGW_Controlfile_c-4066279841-20150528-03
File Name: /home/oracle/backup/ZGW_Controlfile_c-4066279841-20150528-04 RMAN> restore database; //还原数据文件 Starting restore at 28-MAY-15
using channel ORA_DISK_1 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 00002 to /opt/oracle/oradata/zgw/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /opt/oracle/oradata/zgw/undotbs01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/ZGW_0mq82u4r_1_1
channel ORA_DISK_1: piece handle=/home/oracle/backup/ZGW_0mq82u4r_1_1 tag=TAG20150528T143051
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
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 /opt/oracle/oradata/zgw/system01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /opt/oracle/oradata/zgw/users01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/ZGW_0lq82u4r_1_1
channel ORA_DISK_1: piece handle=/home/oracle/backup/ZGW_0lq82u4r_1_1 tag=TAG20150528T143051
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:56
Finished restore at 28-MAY-15 RMAN> recover database; Starting recover at 28-MAY-15
using channel ORA_DISK_1 starting media recovery RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 05/28/2015 17:07:45
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of archived log for thread 1 with sequence 12 and starting SCN of 1083172 found to restore
//这里报日志缺少,实际上是备份的数据库文件后,没有备份归档日志,归档日志全部丢失 //下面尝试进行不完全恢复
$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Thu May 28 17:08:29 2015 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> recover database using backup controlfile until cancel;
ORA-00279: change 1083180 generated at 05/28/2015 14:30:51 needed for thread 1
ORA-00289: suggestion :
/opt/oracle/flash_recovery_area/ZGW/archivelog/2015_05_28/o1_mf_1_12_%u_.arc
ORA-00280: change 1083180 for thread 1 is in sequence #12 Specify log: {<RET>=suggested | filename | AUTO | CANCEL} ORA-00308: cannot open archived log
'/opt/oracle/flash_recovery_area/ZGW/archivelog/2015_05_28/o1_mf_1_12_%u_.arc'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3 SQL> alter database open resetlogs; //至此恢复完毕 Database altered. SQL> select name,OPEN_MODE from v$database; //验证数据库状态 NAME OPEN_MODE
--------- --------------------
ZGW READ WRITE

此文参考:

  第六篇 实战RMAN备份 http://www.5ienet.com/note/html/rman/rman-backup-script-example.shtml

Rman备份异机恢复指南 http://ylw6006.blog.51cto.com/470441/659104/

Oracle 11g RMAN 备份异机恢复并创建新DBID http://blog.csdn.net/leishifei/article/details/6317688

catalog start with rman备份集直接导入控制文件中 http://blog.itpub.net/27042095/viewspace-759237/

使用_allow_resetlogs_corruption打开无归档日志rman备份库 http://www.xifenfei.com/2619.html

rman 备份并异机恢复的更多相关文章

  1. rman备份与异机恢复

    一.rman备份脚本并为定时任务 #!/bin/bashsource ~/.bash_profileexport LANG=en_USBACKUP_DATE=`date +%d`#RMAN_LOG_F ...

  2. Hyper-V安装Oracle Linux6_4 Oracle db 12c并使用rman做异机恢复

    本文记录在Windows Server 2012 R2上安装Oracle Enterprise Linux 6.4以及使用RMAN进行进行异机恢复的过程. Windows服务器增加Hyper-V功能 ...

  3. rman异机恢复,全部恢复和增量恢复

    1.首先准备工作:hostname 192.168.222.11 ol7.localdomain ol7建立相关目录:mkdir -p /u01/app/oracle/oradata/DB11G/mk ...

  4. RMAN - 备份异机恢复

    OS: Oracle Linux Server release 5.7 DB: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - ...

  5. RMAN 备份异机恢复 并创建新DBID

    测试平台信息: Oracle:11gR2 操作系统:Redhat 5.5 Target DB:dave   几点说明: (1)RMAN 异机恢复的时候,db_name必须相同. 如果说要想改成其他的实 ...

  6. RMAN备份策略与异机恢复一例(续篇)

    本文是<RMAN备份策略与异机恢复一例>的续篇,继续实验验证,最终实现两个需求: 1.异机恢复临时测试的小库 2.传输归档时,实现增量传输 1.异机恢复临时测试的小库 之前异机恢复的需求已 ...

  7. RMAN备份策略与异机恢复一例

    实验环境: A机器(生产用途):RHEL 6.5 + Oracle 11.2.0.4 + IP Address 192.168.1.11 B机器(备机用途):RHEL 6.5 + Oracle 11. ...

  8. RMAN异机恢复遭遇ORA-01547、ORA-01152、ORA-01110错误案例

    测试环境:     操作系统  :  Red Hat Enterprise Linux ES release 4 (Nahant Update 4)   VMWARE     数据库     :  O ...

  9. Oracle 单实例 迁移到 RAC 实例 -- 使用RMAN 异机恢复

    Oracle 官网有关单实例迁移到RAC的一个步骤说明: How to Convert 10g Single-Instance database to 10g RAC using Manual Con ...

随机推荐

  1. POJ 3207 Ikki&#39;s Story IV - Panda&#39;s Trick(2-sat)

    POJ 3207 Ikki's Story IV - Panda's Trick id=3207" target="_blank" style=""& ...

  2. opencv矩阵运算(2)

    简单介绍 本篇承接上一篇.继续opencv下矩阵计算的函数使用. 计算矩阵的逆 注意:矩阵A是可逆矩阵的充分必要条件是行列式detA不等于0. 详细代码 double x[3][3] = {{1, 2 ...

  3. Google代码规范工具Cpplint的使用

    Cpplint是一个python脚本,Google使用它作为自己的C++代码规范检查工具. 假设你所在的公司也使用Google C++代码规范,那么你有必要了解下Cpplint. 以下说一下Cppli ...

  4. nodejs简介

    1.Node.js是什么? Node.js不是一种独立的语言,与PHP.java..net即是开发语言也是平台不同,也不是javaScript的框架 jquery,更不是浏览器的库ExtJs,能不与E ...

  5. android常用控件的使用方法

    引言 xml很强大 TextView <TextView android:id="@+id/text_view" android:layout_width="mat ...

  6. js如何实现简繁体互转

    js如何实现简繁体互转 一.总结 一句话总结:其实无论是简体还是繁体,都是在显示端(前端),其实所有的我只用动js就好了,没必要动php. 当然,后端也可以做前端的事情,只是麻烦了点(要多通信两次,第 ...

  7. django 笔记8 url模板 自定义函数 simple_tag

    感谢alex老师~ 知识点: URL - 两个没见 url>路由系统> 函数或类 > 返回字符串 Form表单提交: 提交 >url>函数或类中的方法 -.. HttpR ...

  8. 位运算与bitset

    &运算  将两个数转化为二进制后,对应的位置上相同即取,通常取1,所以&通常情况下可以用来枚举子集 设x为表示集合的整数,那么这个整数有如下性质: x的子集整数y在数值上不会比x大.因 ...

  9. 使用WinNTSetup安装win10时提示efi part有红叉(win10安装UEFI系统安装)

    1.装载ImDisk虚拟磁盘 2.格式化硬盘 *格式化时注意”创建新ESP分区 3.使用 WinNTSetup 选择win10安装程序 *1. “BOOTMGR PBR "后有感叹号不用管, ...

  10. NodeJS学习笔记 (17)集群-cluster(ok)

    cluster模块概览 node实例是单线程作业的.在服务端编程中,通常会创建多个node实例来处理客户端的请求,以此提升系统的吞吐率.对这样多个node实例,我们称之为cluster(集群). 借助 ...