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> |
备份数据库:
[oracle@sigle dbs]$ rman target / catalog sigle/sigle@catalog [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)
[oracle@clone_sigle ~]$ hostname [oracle@clone_sigle ~]$ rman target / catalog sigle/sigle@catalog [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> [oracle@clone_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)、验证数据恢复
[oracle@clone_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异机恢复实验成功完成。
RMAN异机恢复实验---转载的更多相关文章
- Oracle 单实例 迁移到 RAC 实例 -- 使用RMAN 异机恢复
Oracle 官网有关单实例迁移到RAC的一个步骤说明: How to Convert 10g Single-Instance database to 10g RAC using Manual Con ...
- Linux平台下RMAN异机恢复总结
下面总结.整理一下RMAN异机恢复这方面的知识点,这篇笔记在个人笔记里面躺了几年了,直到最近偶然被翻看到,遂整理.总结一下.如下所示,个人将整个RMAN异机恢复分为准备工作和操作步骤两大部分.当然,准 ...
- Oracle12c RAC RMAN异机恢复
######################################################## #编辑pfile文件initspdb.ora vi /oracle/app/oracl ...
- RMAN异机恢复遭遇ORA-01547、ORA-01152、ORA-01110错误案例
测试环境: 操作系统 : Red Hat Enterprise Linux ES release 4 (Nahant Update 4) VMWARE 数据库 : O ...
- oracle rman异机恢复
Oracle源主机 Oracle目标主机 主机平台 CentOS6.2(final) CentOs6.2(FInal) 主机名 vick rman IP地址 192.168.1.11 192.16 ...
- rman异机恢复,全部恢复和增量恢复
1.首先准备工作:hostname 192.168.222.11 ol7.localdomain ol7建立相关目录:mkdir -p /u01/app/oracle/oradata/DB11G/mk ...
- RMAN异机恢复步骤及故障处理
一.測试机安装OS+Oracle Software.包含配置oracle用户.组和环境变量(略) 二.開始异机恢复 1. 复制源库最新备份集.初始化參数.password文件到測试机 [oracle@ ...
- NBU Rman异机恢复Oracle
前段时间一个亿级分区表,被分割成历史表和业务表,历史表中保留15天以外的数据,每天都会从业务表中的15天外的数据copy到历史表,并删除业务表15天外的数据,逻辑也很简单,但插入历史表的where 条 ...
- Oracle RMAN 异机恢复一例
背景介绍:本例需求是将NBU备份的oracle数据库恢复到另一主机上. NBU环境配置.异机上的Oracle软件安装配置忽略,下面只介绍OracleDB恢复的过程. ----------------- ...
随机推荐
- win32之bitmap篇
先讲一下LoadBitmap的用法,代码如下: PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd,&ps); HDC hMemDC = CreateCompa ...
- jQuery导航插件One-Page-Nav演示-显示命名锚记
jQuery导航插件One-Page-Nav演示-显示命名锚记 简介 使用 选项 示例 推荐 简介 电商网站的分类比较明确,比如1楼是手机通讯产品,2楼是家用电器,3楼是服装鞋包等等,旁边还会有一个固 ...
- python编辑csv
import csv import time def timestamp_to_timestr(timeStamp): timeArray = time.localtime(int(timeStamp ...
- Android之Fragment的优点和作用
一:什么是Fragment 碎片.片段.其目的是为了解决不同屏幕分辩率的动态和灵活UI设计.大屏幕如平板小屏幕如手机,平板电脑的设计使得其有更多的空间来放更多的UI组件,而多出来的空间存放UI使其会产 ...
- (C/C++学习)5.C++中的虚继承-虚函数-多态解析
说明:在C++学习的过程中,虚继承-虚函数经常是初学者容易产生误解的两个概念,它们与C++中多态形成的关系,也是很多初学者经常产生困惑的地方,这篇文章将依次分别对三者进行解析,并讲述其之间的联系与不同 ...
- JS练习:显示和隐藏
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- docker安装kong和kong-dashboard
1:docker安装遵循官方手册 2:安装kong 参考文档:https://getkong.org/install/docker/ 安装过程基本和文档一致,文档十分简单清晰. 但应注意,为了最新版k ...
- Django REST framework - 认证
目录 认证 DRF 5种验证方式 如何确定身份验证? 设置身份验证方案 案例: 基于自定义Token认证 第一步: 定义一个用户表和一个保存用户Token的表 第二步: 定义一个登陆视图 第三步定义一 ...
- springcloud(五):Eureka提供数据的客户端连接Docker的mysql
一.提供数据的客户端需要连接数据了,因此需要我们使用mybatis了,等下使用idea生成mybaits和web的依赖 二.提供数据的客户端项目 1.创建项目 2.选择idea自动给我们生成的依赖 3 ...
- Android音乐、视频类APP常用控件:DraggablePanel(1)
Android音乐.视频类APP常用控件:DraggablePanel(1) Android的音乐视频类APP开发中,常涉及到用户拖曳视频.音乐播放器产生一定交互响应的设计需求,最典型的以You ...