免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 9065 | 回复: 12
打印 上一主题 下一主题

[VTL与磁带系统] 关于如何在rman没有catalog的情况下恢复用Rman 备份到磁带上的controlfile [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-02-29 19:14 |只看该作者 |正序浏览
最近有人问controlfile如果没有单独备份,如何恢复的问题。如果是用rman备份的controlfile,原则上是要用rman恢复它(在rman里restore controlfie)。在rman nocatalog的情况下,但rman可以运行进行恢复的前提是oracle mount状态。oracle mount状态的前提是controlfile要在。死胡同了。(感谢yddll提醒,修改了上句有歧意的说法)。所以以前在oracle备份的建议里我都是建议用文件的方式备份controlfile(见http://bbs.chinaunix.net/viewthread.php?tid=550177)。

如果万一真的没有单独备份controlfile,所有的datafile、controlfile都没了,要恢复,以下方法就是救命大法了。忘记贴过这个内容没有,没见过的赶快记下。

(备份是用NetBackup,bplist是NetBackup的指令;别的备份软件应该也有相应的指令)

关于如何在rman没有catalog的情况下恢复用Rman 备份到磁带上的controlfile

1. 利用 bplist 命令查出最新备份的 controlfile 所在的备份集
# bplist -C oraserver -S bkserver -t 4 -R /
/cntrl_47_1_487002297
/cntrl_46_1_487002110
/cntrl_43_1_486814317
/al_42_1_486814273
/al_40_1_486814236
/al_41_1_486814236
/al_39_1_485975390
/al_38_1_485975073
/al_37_1_485964377
/al_36_1_485956945
/al_35_1_485956730
/al_34_1_485956488
/al_33_1_485798568
/cntrl_32_1_485795684
/al_31_1_485795653
/cntrl_30_1_485794954
/al_29_1_485794918
/cntrl_28_1_485719603
/al_26_1_485719551
/al_27_1_485719551
/bk_25_1_485719418
/bk_24_1_485719417
其中oraserver为oracle所在的NBU客户端,bkserver为 NBU MasterServer.
如上所示/cntrl_47_1_487002297 为最新的controlfile 备份集。
2. 将现有的数据库shutdown之后启动到nomount状态
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
SQL> startup nomount <pfile=.....>可写可不写,看情况
ORACLE instance started.

Total System Global Area   69652640 bytes
Fixed Size                    73888 bytes
Variable Size              52621312 bytes
Database Buffers           16777216 bytes
Redo Buffers                 180224 bytes
3. 在SQL中敲入一下脚本
SQL>           
SQL> declare
     devtype varchar2(256);
     done boolean;
    begin
    devtype:=dbms_backup_restore.deviceallocate('sbt_tape',params=>'');
    dbms_backup_restore.restoresetdatafile;
    dbms_backup_restore.restorecontrolfileto('/tmp/abc.cf');
  
dbms_backup_restore.restorebackuppiece('cntrl_47_1_487002297',done=>done
);
   end;
/

其中'/tmp/abc.cf'为我们要取出的controlfile 所存放的位置和名称;
    'cntrl_47_1_487002297'为先前我们得到的Controlfile 所在的备份集名称
    其余不需更改!!
此脚本运行的结果为:
PL/SQL procedure successfully completed.
4. 将/tmp/abc.cf文件改名为正确的controlfile 名字
5. 启动数据库到mount状态
6. 再执行RMAN的恢复脚本,恢复数据。

[ 本帖最后由 老邱 于 2008-3-3 09:55 编辑 ]

论坛徽章:
0
13 [报告]
发表于 2008-05-05 16:09 |只看该作者
很奇怪的问题,使用catalog+tsm+rman备份数据库,测试我把所有controlfile全部删除,数据库down,在nomount下无法恢复通过rman备份到磁带的controlfile
RMAN>startup nomount;
RMAN> run{
2> allocate channel t1 type 'sbt_tape' parms
3> 'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpodbac.opt)';
4> restore controlfile to '/opt/tivoli/ctl.bak';
5> }

allocated channel: t1
channel t1: sid=559 devtype=SBT_TAPE
channel t1: Data Protection for Oracle: version 5.4.1.0

Starting restore at 05-MAY-08

released channel: t1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 05/05/2008 06:50:31
RMAN-06026: some targets not found - aborting restore
RMAN-06024: no backup or copy of the control file found to restore
但是通过命令可以看到controlfile在磁带中有很多份备份

RMAN> list backup of controlfile;


List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   
------- ---- -- ---------- ----------- ------------ -------------------
190553  Incr 1  7.50M      SBT_TAPE    00:00:00     2008-03-07 02:23:51
        BP Key: 190560   Status: AVAILABLE  Compressed: NO  Tag: TAG20080306T181846
        Handle: df_648699831_272_1   Media: 221
  Control File Included: Ckp SCN: 11868796108   Ckp time: 2008-03-07 02:23:51

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   
------- ---- -- ---------- ----------- ------------ -------------------
191816  Incr 1  7.50M      SBT_TAPE    00:00:00     2008-03-08 02:25:02
        BP Key: 191823   Status: AVAILABLE  Compressed: NO  Tag: TAG20080307T181956
        Handle: df_648786302_276_1   Media: 221
  Control File Included: Ckp SCN: 11868884271   Ckp time: 2008-03-08 02:25:02

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   
------- ---- -- ---------- ----------- ------------ -------------------
193070  Incr 0  7.50M      SBT_TAPE    00:00:00     2008-03-09 02:25:52
        BP Key: 193077   Status: AVAILABLE  Compressed: NO  Tag: TAG20080308T181936
        Handle: df_648872752_280_1   Media: 221
  Control File Included: Ckp SCN: 11868975130   Ckp time: 2008-03-09 02:25:52


后来通过楼上的方法恢复了controlfile,后来recover时有问题,再测试,
出现RMAN-06004: ORACLE error from recovery catalog database: RMAN-20011: target database incarnation is not current in recovery catalog
于是我reset database到一个incarnation后,在nomount下也可以恢复controlfile和数据文件,这是何解?

RMAN> startup nomount;  

connected to target database (not started)
Oracle instance started

Total System Global Area     633339904 bytes

Fixed Size                     2275384 bytes
Variable Size                293357512 bytes
Database Buffers             335544320 bytes
Redo Buffers                   2162688 bytes

RMAN> reset database to incarnation 99362;

database reset to incarnation 99362
RMAN> run{
2> allocate channel t1 type 'sbt_tape' parms
3> 'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpodbac.opt)';
4> restore controlfile;
5> }

allocated channel: t1
channel t1: sid=559 devtype=SBT_TAPE
channel t1: Data Protection for Oracle: version 5.4.1.0

Starting restore at 2008-05-05 07:56:11

channel t1: starting datafile backupset restore
channel t1: restoring control file
channel t1: reading from backup piece df_652960629_409_1
channel t1: restored backup piece 1
piece handle=df_652960629_409_1 tag=TAG20080425T015104
channel t1: restore complete, elapsed time: 00:00:03
output filename=/xxx/xxxx/accaprd1/data/accaprd1_control01.ctl
output filename=/xxx/xxxx/accaprd1/data/accaprd1_control02.ctl
Finished restore at 2008-05-05 07:56:16
released channel: t1

[ 本帖最后由 星海夜航 于 2008-5-5 16:22 编辑 ]

论坛徽章:
0
12 [报告]
发表于 2008-05-05 15:27 |只看该作者
正好遇到这样的问题,环境为tsm+oracle10g,测试结果如下

SQL> declare
  2  devtype varchar2(256);
  3  done boolean;
  4  begin
  5  devtype:=dbms_backup_restore.deviceallocate('sbt_tape',params=>'ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpodbac.opt)');
  6  dbms_backup_restore.restoresetdatafile;
  7  dbms_backup_restore.restorecontrolfileto('/tmp/abc.cf');
  8  dbms_backup_restore.restorebackuppiece('df_652960629_409_1',done=>done);
  9  end;
10  /

PL/SQL procedure successfully completed.
$ cp abc.cf /xxx/xxxx/xxxx/data/xxxprd1_control01.ctl
$ cp xxxprd1_control01.ctl xxxxprd1_control02.ctl
$ rman target / catalog rman/rman@rman

Recovery Manager: Release 10.2.0.3.0 - Production on Mon May 5 07:12:18 2008

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

connected to target database: accaprd1 (not mounted)
connected to recovery catalog database
RMAN> alter database mount;

database mounted

论坛徽章:
0
11 [报告]
发表于 2008-03-03 12:35 |只看该作者
原帖由 fly1928 于 2008-3-3 10:32 发表
好文,如果早几年,我的客户就有福了.



这个办法以版主早写过的呀.

论坛徽章:
0
10 [报告]
发表于 2008-03-03 10:32 |只看该作者
好文,如果早几年,我的客户就有福了.

论坛徽章:
0
9 [报告]
发表于 2008-03-03 10:08 |只看该作者
不错,太牛了。。

论坛徽章:
0
8 [报告]
发表于 2008-03-03 00:14 |只看该作者

回复 #5 kylinbird 的帖子

请问以上pq/sql语句的目的是只恢复控制文件还是控制文件和数据文件一起恢复,其中一句dbms_backup_restore.restoresetdatafile;
怎么看着像是恢复数据文件啊


不知道,这时候应该不会能恢复数据文件的。以前我测试过,很管用。有条件的兄弟可以再测试一下。

论坛徽章:
0
7 [报告]
发表于 2008-03-03 00:09 |只看该作者
原帖由 alex_linux 于 2008-3-1 11:14 发表

问下 4. 将/tmp/abc.cf文件改名为正确的controlfile 名字

改了名字.后要不要手工把controlfile的文件 copy到原来位置呢?还是就放在那里就好会自动恢复呢?


copy到pfile或spfile里指定的controlfile=...位置。这与NBU无关,了解oracle本身各种文件(pfile, controlfile, datafile, logfile)的关系和启动过程就明白了。

论坛徽章:
0
6 [报告]
发表于 2008-03-02 23:02 |只看该作者
N
太强了

论坛徽章:
0
5 [报告]
发表于 2008-03-01 21:54 |只看该作者

回复 #1 老邱 的帖子

3. 在SQL中敲入一下脚本
SQL>           
SQL> declare
     devtype varchar2(256);
     done boolean;
    begin
    devtype:=dbms_backup_restore.deviceallocate('sbt_tape',params=>'');
    dbms_backup_restore.restoresetdatafile;
    dbms_backup_restore.restorecontrolfileto('/tmp/abc.cf');
  
dbms_backup_restore.restorebackuppiece('cntrl_47_1_487002297',done=>done
);
   end;
/

请问以上pq/sql语句的目的是只恢复控制文件还是控制文件和数据文件一起恢复,其中一句dbms_backup_restore.restoresetdatafile;
怎么看着像是恢复数据文件啊
  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP