最后更新时间:2018/12/29


前置条件

已准备一台安装好Centos6+oracle11gr2 软件的服务器;

只安装了 oracle 数据库软件,需要手工创建以下目录:

#环境变量

export ORACLE_SID=orcl

#由于只安装软件未创建数据库所以需创建对应文件夹

mkdir -p $ORACLE_BASE/admin/orcl/adump/

mkdir -p $ORACLE_BASE/admin/orcl/dpdump/

mkdir -p $ORACLE_BASE/admin/orcl/pfile/

mkdir -p $ORACLE_BASE/oradata/orcl/

mkdir -p $ORACLE_BASE/flash_recovery_area

mkdir -p $ORACLE_BASE/flash_recovery_area/orcl

备份集放置目录:/u02/rmans

data放置备份集文件;

init_files 放置备份集生成后,手工备份的 spfile 及 control 文件。

[oracle@localhost rmans]$ ls /u02/rmans

data  expdp.sh  init_files  logs  startrmans.sh

本次恢复主要难点:

1. 备份集的数据库版本不同,由 11.2.0.1 升级为 11.2.0.4;

2. 数据库安装路径也不一样,数据文件、日志文件、控制文件路径都重定义;

正常情况下恢复,一般是安装的数据库版本、软件安装路径、数据文件路径都一致,会少很多步骤。

恢复操作

[oracle@localhost rmans]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Wed Dec 19 09:28:53 2018

Copyright (c) 1982, 2011, 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 '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorcl.ora'

starting Oracle instance without parameter file for retrieval of spfile

Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2260088 bytes

Variable Size                285213576 bytes

Database Buffers             775946240 bytes

Redo Buffers                   5517312 bytes

恢复spfile: 需注意对应spfile oracle用户需要有权限访问

RMAN> restore spfile from '/u02/rmans/init_files/ORCL_spfile_1atl4iog_1_1_20181219';

Starting restore at 19-DEC-18

using channel ORA_DISK_1

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u02/rmans/init_files/ORCL_spfile_1atl4iog_1_1_20181219

channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete

Finished restore at 19-DEC-18

重启实例

RMAN> startup nomount force;

恢复控制文件

RMAN> restore controlfile from '/u02/rmans/init_files/ctl_file_19tl4iod_1_1_20181219';

Starting restore at 19-DEC-18

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=385 device type=DISK

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

output file name=/u01/app/oradata/orcl/control01.ctl

output file name=/u01/app/flash_recovery_area/orcl/control02.ctl

Finished restore at 19-DEC-18

挂载数据库

RMAN> alter database mount;

database mounted

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

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

24      Full    3.29G      DISK        00:00:35     18-DEC-18     
         BP Key: 24   Status: EXPIRED  Compressed: NO  Tag: TAG20181218T143246
         Piece Name: /home/oracle/rmans/data/fullback_ORCL_20181218_35
   List of Datafiles in backup set 24
   File LV Type Ckp SCN    Ckp Time  Name
   ---- -- ---- ---------- --------- ----
   1       Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/system01.dbf
   2       Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/sysaux01.dbf
   3       Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/undotbs01.dbf
   4       Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/users01.dbf
   5       Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/userdat.dbf
   6       Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/useridx.dbf
   7       Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/qcdat.dbf
   8       Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/qcidx.dbf
   9       Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/hisdat.dbf
   10      Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/hisidx.dbf
   11      Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/archdat.dbf
   12      Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/archidx.dbf
   13      Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/suitdat.dbf
   14      Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/suitidx.dbf
   15      Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/sbcdat.dbf
   16      Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/sbcidx.dbf
   17      Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/gszqdat.dbf
   18      Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/gszqidx.dbf
   19      Full 62638762   18-DEC-18 /home/oracle/oradata/zginfo/ZG_INFO_SPACE.dbf
   20      Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/businessdat.dbf
   21      Full 62638762   18-DEC-18 /home/oracle/oradata/orcl/businessidx.dbf

路径转换

rman备份集在新主机路径: /u02/rmans/data,备份集生成是在源主机的 /home/oracle/rmans/data ,所以需转换。

注册备份集路径

RMAN> catalog start with '/u02/rmans/data';

Starting implicit crosscheck backup at 19-DEC-18

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=385 device type=DISK

Crosschecked 5 objects

Finished implicit crosscheck backup at 19-DEC-18

Starting implicit crosscheck copy at 19-DEC-18

using channel ORA_DISK_1

Finished implicit crosscheck copy at 19-DEC-18

searching for all files in the recovery area

cataloging files...

no files cataloged

searching for all files that match the pattern /u02/rmans/data

List of Files Unknown to the Database

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

File Name: /u02/rmans/data/fullback_ORCL_20181219_39

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files...

cataloging done

List of Cataloged Files

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

File Name: /u02/rmans/data/fullback_ORCL_20181219_39

数据文件路径转换

run{

set newname for datafile 1  to '/u01/app/oradata/orcl/system01.dbf';

set newname for datafile 2  to '/u01/app/oradata/orcl/sysaux01.dbf';

set newname for datafile 3  to '/u01/app/oradata/orcl/undotbs01.dbf';

set newname for datafile 4  to '/u01/app/oradata/orcl/users01.dbf';

set newname for datafile 5  to '/u01/app/oradata/orcl/userdat.dbf';

set newname for datafile 6  to '/u01/app/oradata/orcl/useridx.dbf';

set newname for datafile 7  to '/u01/app/oradata/orcl/qcdat.dbf';

set newname for datafile 8  to '/u01/app/oradata/orcl/qcidx.dbf';

set newname for datafile 9  to '/u01/app/oradata/orcl/hisdat.dbf';

set newname for datafile 10 to '/u01/app/oradata/orcl/hisidx.dbf';

set newname for datafile 11 to '/u01/app/oradata/orcl/archdat.dbf';

set newname for datafile 12 to '/u01/app/oradata/orcl/archidx.dbf';

set newname for datafile 13 to '/u01/app/oradata/orcl/suitdat.dbf';

set newname for datafile 14 to '/u01/app/oradata/orcl/suitidx.dbf';

set newname for datafile 15 to '/u01/app/oradata/orcl/sbcdat.dbf';

set newname for datafile 16 to '/u01/app/oradata/orcl/sbcidx.dbf';

set newname for datafile 17 to '/u01/app/oradata/orcl/gszqdat.dbf';

set newname for datafile 18 to '/u01/app/oradata/orcl/gszqidx.dbf';

set newname for datafile 19 to '/u01/app/oradata/zginfo/ZG_INFO_SPACE.dbf';

set newname for datafile 20 to '/u01/app/oradata/orcl/businessdat.dbf';

set newname for datafile 21 to '/u01/app/oradata/orcl/businessidx.dbf';

set until scn 62754360;

restore database;

SWITCH DATAFILE ALL;

recover database;

}

....

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET until clause

Starting restore at 19-DEC-18

using channel ORA_DISK_1

skipping datafile 1; already restored to file /u01/app/oradata/orcl/system01.dbf

skipping datafile 2; already restored to file /u01/app/oradata/orcl/sysaux01.dbf

skipping datafile 3; already restored to file /u01/app/oradata/orcl/undotbs01.dbf

skipping datafile 4; already restored to file /u01/app/oradata/orcl/users01.dbf

skipping datafile 5; already restored to file /u01/app/oradata/orcl/userdat.dbf

skipping datafile 6; already restored to file /u01/app/oradata/orcl/useridx.dbf

skipping datafile 7; already restored to file /u01/app/oradata/orcl/qcdat.dbf

skipping datafile 8; already restored to file /u01/app/oradata/orcl/qcidx.dbf

skipping datafile 9; already restored to file /u01/app/oradata/orcl/hisdat.dbf

skipping datafile 10; already restored to file /u01/app/oradata/orcl/hisidx.dbf

skipping datafile 11; already restored to file /u01/app/oradata/orcl/archdat.dbf

skipping datafile 12; already restored to file /u01/app/oradata/orcl/archidx.dbf

skipping datafile 13; already restored to file /u01/app/oradata/orcl/suitdat.dbf

skipping datafile 14; already restored to file /u01/app/oradata/orcl/suitidx.dbf

skipping datafile 15; already restored to file /u01/app/oradata/orcl/sbcdat.dbf

skipping datafile 16; already restored to file /u01/app/oradata/orcl/sbcidx.dbf

skipping datafile 17; already restored to file /u01/app/oradata/orcl/gszqdat.dbf

skipping datafile 18; already restored to file /u01/app/oradata/orcl/gszqidx.dbf

skipping datafile 19; already restored to file /u01/app/oradata/zginfo/ZG_INFO_SPACE.dbf

skipping datafile 20; already restored to file /u01/app/oradata/orcl/businessdat.dbf

skipping datafile 21; already restored to file /u01/app/oradata/orcl/businessidx.dbf

restore not done; all files read only, offline, or already restored

Finished restore at 19-DEC-18

Starting recover at 19-DEC-18

using channel ORA_DISK_1

starting media recovery

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

Finished recover at 19-DEC-18

日志目录转换

SQL> alter database rename file '/home/oracle/oradata/orcl/redo01.log' to '/u01/app/oradata/onlinelogs/redo01.log';

Database altered.

SQL>

SQL> alter database rename file '/home/oracle/oradata/orcl/redo02.log' to '/u01/app/oradata/onlinelogs/redo02.log';

Database altered.

SQL>

SQL> alter database rename file '/home/oracle/oradata/orcl/redo03.log' to '/u01/app/oradata/onlinelogs/redo03.log';

Database altered.

SQL> alter database open RESETLOGS;

alter database open RESETLOGS

*

ERROR at line 1:

ORA-00392: log 1 of thread 1 is being cleared, operation not allowed

ORA-00312: online log 1 thread 1: '/u01/app/oradata/onlinelogs/redo01.log'

SQL> ALTER DATABASE CLEAR LOGFILE GROUP 1;

Database altered.

SQL> ALTER DATABASE CLEAR LOGFILE GROUP 2;

Database altered.

SQL> ALTER DATABASE CLEAR LOGFILE GROUP 3;

Database altered.

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01092: ORACLE instance terminated. Disconnection forced

ORA-00704: bootstrap process failure

ORA-39700: database must be opened with UPGRADE option

Process ID: 4356

Session ID: 1144 Serial number: 3

--下面尝试upgrade,因为当前基于一个11.2.0.1的备份恢复到11.2.0.4,所以需要upgrade

sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Feb 24 16:03:15 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup upgrade;

ORACLE instance started.

Total System Global Area 1068937216 bytes

Fixed Size                  2260088 bytes

Variable Size             704643976 bytes

Database Buffers          352321536 bytes

Redo Buffers                9711616 bytes

Database mounted.

Database opened.

SQL> @$ORACLE_HOME/rdbms/admin/catupgrd.sql; --执行升级脚本

注意

spfile 不存在

spfile 是实例启动时必要的参数文件,如果不存在,无法使用 startup nomount 启动到 nomount 状态。

如果没有spfile,需要自己编辑一个pfile,然后启动时使用:

RMAN> startup pfile='/tmp/initorcl.ora' nomount;

启动完后创建spfile

SQL> create spfile from pfile='/tmp/initorcl.ora';

File created.

control 文件trace出创建脚本

control文件不存在或者有问题时,数据库无法 mount。

ALTER DATABASE BACKUP CONTROLFILE TO TRACE;

执行完后可到系统 trace 日志目录下找到 alert_orcl.log,在里面可看到trc文件,trc文件包含了创建control文件的命令。

类似以下内容:

Backup controlfile written to trace file /u01/app/diag/rdbms/orcl/orcl/trace/orcl_ora_4146.trc

Completed: ALTER DATABASE BACKUP CONTROLFILE TO TRACE

Wed Dec 19 12:09:15 2018

参考文章:

https://www.cnblogs.com/storymedia/p/4536553.html

https://blog.csdn.net/leshami/article/details/50913867

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

  1. RMAN - 备份异机恢复

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

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

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

  3. 使用rman备份异机恢复数据库

    一.RMAN备份源库注意点: 最好保留rman备份日志 $rman target / log=backup.log RMAN>run { allocate channel t1 type dis ...

  4. RAC数据库的RMAN备份异机恢复到单节点数据库

    1.首先在rac环境用rman备份数据库.[oracle@rac1 admin]$ rman target /run{allocate channel c1 device type disk conn ...

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

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

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

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

  7. rman全备份异机恢复

    一.测试环境 [oracle@localhost ~]$ uname -a Linux localhost.localdomain -.el6.x86_64 # SMP Tue May :: EDT ...

  8. rman 备份并异机恢复

    1.RMAN 备份脚本 RUN { CONFIGURE RETENTION POLICY DAYS; CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CO ...

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

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

随机推荐

  1. mysql表空间传输(ERROR 1808) row_format设置

    文章结构如下: 从MYSQL5.6版本开始,引入了传输表空间这个功能,可以把一张表从一个数据库移到另一个数据库或者机器上.迁移的时候很方便,尤其是大表. 由于本次达到测试使用版本5.6.38传到5.7 ...

  2. POJ 3657 并查集

    题意: 思路: 1.二分+线段树(但是会TLE 本地测没有任何问题,但是POJ上就是会挂--) 2.二分+并查集 我搞了一下午+一晚上才搞出来----..(多半时间是在查错) 首先 如果我们想知道这头 ...

  3. 51nod 1158 全是1的最大子矩阵(单调栈 ,o(n*m))

    前置问题:51nod 1102 面积最大的矩形 附上链接: 51nod 1102 面积最大的矩形 这题的题解博客 需要了解的知识:单调栈,在前置问题中已经讲解. 解题思路 对每行求左边连续1的个数,得 ...

  4. SLAM概念学习之特征图Feature Maps

    特征图(或者叫地标图,landmark maps)利用参数化特征(如点和线)的全局位置来表示环境.如图1所示,机器人的外部环境被一些列参数化的特征,即二维坐标点表示.这些静态的地标点被观测器(装有传感 ...

  5. STM8S103 STVD编译空间不足

    关于text空间(理解为代码空间)不足问题 # 关于.bsct和.ubsct问题(着重参考http://www.waveshare.net/article/STM8-3-1-10.htm) map文件 ...

  6. li自定义图标

    /*自定义list的图标*/ li{ list-style-image: url(../img/21.JPG); }

  7. luogu P1495 曹冲养猪(中国剩余定理)

    题意 题解 翻到了一个金句 就跟这句话说得一样,就是个裸题. 所以看模板呗. #include<iostream> #include<cstring> #include< ...

  8. [NOIP2015普及组]推销员

    题目:洛谷P2672.codevs5126.Vijos P1977 题目大意:有个推销员要去推销,要你求他推销1~n户人家分别最多花多少“疲劳值”.具体见题目. 解题思路:如果用$O(n^2)$做的话 ...

  9. oracle数据库回滚

    线下测试数据误操作,回滚攻略--把数据捞出来,这个时间自己设置--表名一定要是:xx_tbd日期 CREATE TABLE user_tbd0718ASselect * from user as of ...

  10. STM32是如何进入中断服务函数xxx_IRQHandler的

    今天在看stm32的中断,一时间不理解stm32主函数是如何进入中断函数的,按C编程的理解,会有个特定的入口之类的,但是看demo过程中没有发现入口. 以串口中断服务函数void USART1_IRQ ...