RMAN异机恢复实验---转载

一、RMAN异机恢复实验

2011年3月23日00:44

1、环境介绍:

主机1:


操作系统


REDHAT5.5


IP地址


172.16.1.120


主机名


sigle


数据库版本


10.2.0.4


数据库名


orcl


DBID


1305151947


catalog


win_yjr


catalog用户


sigle/sigle

主机2:


操作系统


REDHAT5.5


IP地址


172.16.1.121


主机名


clone_sigle


数据库版本


10.2.0.4


 


 

2、本次恢复实验目的:

主机崩溃恢复后(重装了操作系统及数据库软件),在没有任何控制文件、数据文件、参数文件的情况下,依靠catalog知识库进行控制文件、数据文件、参数文件等的恢复(或异机恢复)。

3、实际操作过程:

注意:在这类使用catalog库进行恢复操作中,DBID是尤为重要的信息,如没有DBID则这类型的恢复工作将无法进行。

1)、创建测试表,并备份数据库。

创建表并启动到mount状态,由于数据库处于非归档模式,因此全库备份只能在mount状态下执行。


SQL> create table test_rman(t1 number,t2 date);

Table created.

SQL> insert into test_rman values(1,sysdate);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from test_rman;

T1 T2

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

1 23-3月 -12

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

Total System Global Area  486539264 bytes

Fixed Size                  1268196 bytes

Variable Size             171968028 bytes

Database Buffers          306184192 bytes

Redo Buffers                7118848 bytes

Database mounted.

SQL>

备份数据库:


[[email protected] dbs]$ rman target / catalog sigle/[email protected]

[uniread] Loaded history (87 lines)

Recovery Manager: Release 10.2.0.4.0 - Production on 星期五 3月 23 00:16:14 2012

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

connected to target database: ORCL (DBID=1305151947, not open)

connected to recovery catalog database

RMAN> run

{

2> 3> configure controlfile autobackup on;

4> allocate channel disk1 device type disk format=‘/oracle/backup/backup_%d_%T_%s_%t_1.bak‘;

allocate channel disk2 device type disk format=‘/oracle/backup/backup_%d_%T_%s_%t_2.bak‘;

5> allocate channel disk3 device type disk format=‘/oracle/backup/backup_%d_%T_%s_%t_3.bak‘;

6> backup database tag=‘FULLL_DB_20120322‘;

}

7> 8>

old RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters are successfully stored

starting full resync of recovery catalog

full resync complete

allocated channel: disk1

channel disk1: sid=1640 devtype=DISK

allocated channel: disk2

channel disk2: sid=1639 devtype=DISK

allocated channel: disk3

channel disk3: sid=1638 devtype=DISK

Starting backup at 23-3月 -12

channel disk1: starting full datafile backupset

channel disk1: specifying datafile(s) in backupset

input datafile fno=00002 name=/dev/raw/raw3

input datafile fno=00003 name=/dev/raw/raw2

channel disk1: starting piece 1 at 23-3月 -12

channel disk2: starting full datafile backupset

channel disk2: specifying datafile(s) in backupset

input datafile fno=00001 name=/dev/raw/raw1

input datafile fno=00004 name=/dev/raw/raw4

channel disk2: starting piece 1 at 23-3月 -12

channel disk2: finished piece 1 at 23-3月 -12

piece handle=/oracle/backup/backup_ORCL_20120323_10_778637780_2.bak tag=FULLL_DB_20120322 comment=NONE

channel disk2: backup set complete, elapsed time: 00:00:46

channel disk1: finished piece 1 at 23-3月 -12

piece handle=/oracle/backup/backup_ORCL_20120323_9_778637780_1.bak tag=FULLL_DB_20120322 comment=NONE

channel disk1: backup set complete, elapsed time: 00:00:46

Finished backup at 23-3月 -12

Starting Control File and SPFILE Autobackup at 23-3月 -12

piece handle=/oracle/db10g/dbs/c-1305151947-20120323-00 comment=NONE

Finished Control File and SPFILE Autobackup at 23-3月 -12

released channel: disk1

released channel: disk2

released channel: disk3

RMAN>

2)、使用RMAN连接数据库及CATALOG库

在主机崩溃恢复后(包括操作系统及数据库版本都要与原系统一致,本次试验采用克隆主机系统后删除数据库来实现),使用oracle用户启动RMAN工具,并连接到catalog数据库(配置tnsnames.ora)


[[email protected]_sigle ~]$ hostname
clone_sigle
[[email protected]_sigle ~]$

[[email protected]_sigle ~]$ rman target / catalog sigle/[email protected]

[uniread] Loaded history (1 lines)

Recovery Manager: Release 10.2.0.4.0 - Production on 星期四 3月 22 23:06:52 2012

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

connected to target database (not started)

connected to recovery catalog database

RMAN>

3)、设置DBID


RMAN> set DBID=1305151947

executing command: SET DBID

database name is "ORCL" and DBID is 1305151947

RMAN>

4)、启动实例到nomount状态

虽然缺失spfile、pfile、init等参数文件,但是oracle会按默认设置启动实例。


RMAN> startup nomount;

startup failed: ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file ‘/oracle/db10g/dbs/initorcl.ora‘

starting Oracle instance without parameter file for retrival of spfile

Oracle instance started

Total System Global Area     159383552 bytes

Fixed Size                     1266320 bytes

Variable Size                 58723696 bytes

Database Buffers              92274688 bytes

Redo Buffers                   7118848 bytes

RMAN>

5)、查看备份集


RMAN> list backupset;

List of Backup Sets

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

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

62      Full    540.16M    DISK        00:00:36     22-3月 -12

BP Key: 64   Status: AVAILABLE  Compressed: NO  Tag: FULLL_DB_20120322

Piece Name: /oracle/backup/backup_ORCL_20120322_4_778630144_1.bak

List of Datafiles in backup set 62

File LV Type Ckp SCN    Ckp Time   Name

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

2       Full 489158     22-3月 -12 /dev/raw/raw3

3       Full 489158     22-3月 -12 /dev/raw/raw2

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

63      Full    357.91M    DISK        00:00:39     22-3月 -12

BP Key: 65   Status: AVAILABLE  Compressed: NO  Tag: FULLL_DB_20120322

Piece Name: /oracle/backup/backup_ORCL_20120322_5_778630144_2.bak

List of Datafiles in backup set 63

File LV Type Ckp SCN    Ckp Time   Name

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

1       Full 489158     22-3月 -12 /dev/raw/raw1

4       Full 489158     22-3月 -12 /dev/raw/raw4

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

75      Full    13.70M     DISK        00:00:02     22-3月 -12

BP Key: 78   Status: AVAILABLE  Compressed: NO  Tag: TAG20120322T220950

Piece Name: /oracle/db10g/dbs/c-1305151947-20120322-01

Control File Included: Ckp SCN: 489158       Ckp time: 22-3月 -12

SPFILE Included: Modification time: 22-3月 -12

RMAN>

6)、执行spfile文件恢复

这里要注意,如果备份集是存放在磁带库上的,需要先配置数据库到磁带库的路径,并保证路径可用。如果是在磁盘上,需要拷贝备份文件到该主机的相同目录,本次试验采用NFS方式实现。即在目标主机上挂在和源主机相同的目录并配置成NFS文件系统。

关于Linux NFS配置,参考链接:http://blog.csdn.net/snowfox326043/article/details/7463002


RMAN> restore spfile from ‘/oracle/db10g/dbs/c-1305151947-20120322-01‘;

Starting restore at 22-3月 -12

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=36 devtype=DISK

channel ORA_DISK_1: autobackup found: /oracle/db10g/dbs/c-1305151947-20120322-01

channel ORA_DISK_1: SPFILE restore from autobackup complete

Finished restore at 22-3月 -12

RMAN>

7)、执行控制文件恢复

在执行控制文件恢复前,先恢复spfile参数文件,并且一定要重启数据库,以使数据库使用还原后的spfile参数文件来启动数据库,这样才能将控制文件还原到正确位置


RMAN> restore controlfile from ‘/oracle/db10g/dbs/c-1305151947-20120322-01‘;

Starting restore at 22-3月 -12

using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file

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

output filename=/oracle/db10g/dbs/cntrlorcl.dbf

Finished restore at 22-3月 -12

RMAN>

8)、重启数据库到mount状态

注意在重启到mount状态前,需要先创建好dump文件夹目录

包括adump/bdump/cdump/dpdump/udump/pfile等


RMAN> shutdown immediate;

Oracle instance shut down

RMAN>

[[email protected]_sigle ~]$ sq

[uniread] Loaded history (43 lines)

SQL*Plus: Release 10.2.0.4.0 - Production on 星期四 3月 22 23:38:48 2012

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

SQL> conn /as sysdba

Connected.

SQL> startup nomount;

ORACLE instance started.

Total System Global Area  486539264 bytes

Fixed Size                  1268196 bytes

Variable Size             167773724 bytes

Database Buffers          310378496 bytes

Redo Buffers                7118848 bytes

SQL> alter database mount;

Database altered.

SQL>

9)、执行数据文件还原


RMAN> restore database from tag=‘FULLL_DB_20120322‘;

Starting restore at 22-3月 -12

using channel ORA_DISK_1

skipping datafile 2; already restored to file /dev/raw/raw3

skipping datafile 3; already restored to file /dev/raw/raw2

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00001 to /dev/raw/raw1

restoring datafile 00004 to /dev/raw/raw4

channel ORA_DISK_1: reading from backup piece /oracle/backup/backup_ORCL_20120322_5_778630144_2.bak

channel ORA_DISK_1: restored backup piece 1

piece handle=/oracle/backup/backup_ORCL_20120322_5_778630144_2.bak tag=FULLL_DB_20120322

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

Finished restore at 22-3月 -12

RMAN>

10)、执行数据文件恢复


RMAN> recover database;

Starting recover at 22-3月 -12

using channel ORA_DISK_1

starting media recovery

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

Finished recover at 22-3月 -12

RMAN>

11)、打开数据库

由于本次试验的数据为非归档模式,所以没有重设redolog的操作,如果数据库处于归档模式,这里执行了不完全恢复,在打开的时候需要加参数resetlogs


RMAN> alter database open;

database opened

RMAN>

12)、验证数据恢复


[[email protected]_sigle ~]$ sq

[uniread] Loaded history (102 lines)

SQL*Plus: Release 10.2.0.4.0 - Production on 星期五 3月 23 00:41:01 2012

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

SQL> conn /as sysdba

Connected.

SQL> !hostname

clone_sigle

SQL> select * from test_rman;

T1 T2

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

1 23-3月 -12

SQL>

可以看到在原数据库备份前的数据已经恢复到在现在的主机上。至此数据库rman异机恢复实验成功完成。

时间: 2024-10-11 06:09:28

RMAN异机恢复实验---转载的相关文章

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

Oracle 官网有关单实例迁移到RAC的一个步骤说明: How to Convert 10g Single-Instance database to 10g RAC using Manual Conversion procedure [ID 747457.1] http://blog.csdn.net/tianlesoftware/archive/2010/12/09/6065903.aspx   RMAN 备份异机恢复 并创建新DBID http://blog.csdn.net/tianle

rman异机恢复

rman异机恢复 注意事项: 1.源数据库与目标数据库的目录结构相同 2.目标数据库只需要安装ORACLE软件(但是参数文件中指定的目录要创建) 3.要将源数据库的数据文件,参数文件,控制文件,密码文件,归档日志统统备份 1.源数据库备份 参数文件与控制文件自动备份 CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/home/oracle/r

Linux平台下RMAN异机恢复总结

下面总结.整理一下RMAN异机恢复这方面的知识点,这篇笔记在个人笔记里面躺了几年了,直到最近偶然被翻看到,遂整理.总结一下.如下所示,个人将整个RMAN异机恢复分为准备工作和操作步骤两大部分.当然,准备工作里面,有些步骤不是必须的,可以跳过或忽略的.这个取决于你的实际环境和你对RMAN异机恢复的熟悉程度. 准备工作 1:了解一下目标服务器与源服务器的操作系统版本信息 需要对比一下目标服务器与源服务器的操作系统版本是否一致,具体来说,操作系统版本信息.内核信息(例如Oracle Linux是否使用

Oracle12c RAC RMAN异机恢复

######################################################## #编辑pfile文件initspdb.ora vi /oracle/app/oracle/product/12.2.0/db_1/dbs/initspdb.ora audit_file_dest='/oracle/app/oracle/admin/spdb/adump' audit_trail='db' compatible='12.2.0' control_files='/orac

RMAN异机恢复步骤及故障处理

一.测试机安装OS+Oracle Software,包括配置oracle用户组和环境变量(略) 二.开始异机恢复 1. 复制源库最新备份集.初始化参数.密码文件到测试机 [[email protected] backupsets]$ scp *20141012* 192.168.1.213:/tmp The authenticity of host '192.168.1.213 (192.168.1.213)' can't be established. RSA key fingerprint

oracle rman异机恢复

  Oracle源主机 Oracle目标主机 主机平台 CentOS6.2(final) CentOs6.2(FInal) 主机名 vick rman IP地址 192.168.1.11 192.168.1.10 实例名字 orcl orcl Oracle版本 11.2.0.4 11.2.0.4 Oracle数据文件存储 filesystem filesystem 控制文件路径 /u01/app/oracle/oradata /u01/app/oracle/oradata 数据文件路径 /u01

如何使用 RMAN 异机恢复部分表空间

在oracle 数据库的日常维护和使用期间难免会遇到误删数据(drop,delete, truncate)当我们使用常规手段(flashback query ,flashback drop)也无法恢复数据时,我们可以使用最近的逻辑备份,在异机使用dmp 来恢复相应的表,但是如果没有这些逻辑备份,但是有一个最近的rman 全备,那么我们就可以利用这个备份来恢复被误删的表空间,从而实现数据的恢复,这里我以NBU 的备份环境为例简单描述下如何来回复部分 表空间: -------在nomount 状态

RMAN异机恢复到不同的路劲下

1.全库备份,scp到异机目录下  查询源库的DBID:   SQL> select dbid,name from v$database; DBID NAME ---------- ---------  439840715 YIJI SQL>    异机建立dump目录.oradata下建立SID名对应目录  2.恢复spfile,启动到nomount:       export ORACLE_SID=yiji    rman target /    set dbid=439840715   

NBU7.0 RMAN 异机恢复 not found in NetBackup catalog

问题描述: RMAN>  run { 2>  allocate channel t1 type 'sbt_tape'; 3>  send 'NB_ORA_SERV=netbackup,NB_ORA_CLIENT=hz1'; 4>  restore controlfile to '/oracle11/oradata/control01.ctl' from '/c-3201563006-20141026-02'; 5>  release channel t1 ; 6>  }