Chinaunix首页 | 论坛 | 博客
  • 博客访问: 86111
  • 博文数量: 18
  • 博客积分: 360
  • 博客等级: 一等列兵
  • 技术积分: 200
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-29 12:27
文章分类

全部博文(18)

文章存档

2014年(1)

2011年(17)

我的朋友

分类: 服务器与存储

2011-04-27 09:21:34

由于以后工作可能会有变化,为了防止自己记忆力衰退
将oracle通过nbu做的异机整库恢复记录下来

首先要保证操作系统平台大版本一致(从HP 11.31到11.11进行恢复也没有问题),如果是跨平台的恢复这里不做讨论
oracle版本必须一致,包括小版本号

假设恢复的源主机hostname叫 hosta,目标主机hostname叫 hostb,数据库sid叫 orasid

先保证NBU的设置允许异机恢复
----------------------------------------------------------------------
确保将 NetBackup 服务器配置为允许重定向恢复。管理员通过在 Netbackup 主服务器上创建下面的文件可删除对所客户机的限制:
/usr/openv/netbackup/db/altnames/No.Restrictions
或者,要限制客户机只从其他特定的客户机恢复,请创建下面的文件:
/usr/openv/netbackup/db/altnames/client_name
其中 client_name 是允许进行重定向恢复的客户机(目标客户机)的名称。然后,将NetBackup for Oracle 源客户机的名称添加到此文件。

本节信息适用于使用命令行执行的恢复,而不适用于“备份、归档和恢复”客户机界面

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

1、在NBU Master上用bplist命令查出已经备份的信息
bplist -C hosta -t 4 -R |more
。。。

记录下对应的controlfile备份信息,以后备用,这里是c-297293101-20110427-01

2、配置好hostb的oracle,安装完成,并且按照hosta的目录结构建好目录和文件系统

3、配置好hostb的nbu,完成oracle_link

接下来的4到6步是进行spfile的恢复动作

4、启动hostb上的oracle到nomount状态,这时使用的是安装完成默认的pfile文件
  1. [oracle@hostb:/u01/oracle/product/db10gr2/dbs]$sqlplus /nolog

  2. SQL*Plus: Release 10.2.0.4.0 - Production on Wed Apr 27 15:58:31 2011

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

  4. SQL> connect /as sysdba;
  5. Connected to an idle instance.
  6. SQL> startup nomount pfile='/u01/oracle/product/db10gr2/dbs/init.ora';
  7. ORACLE instance started.

  8. Total System Global Area 171966464 bytes
  9. Fixed Size 2067664 bytes
  10. Variable Size 150995760 bytes
  11. Database Buffers 16777216 bytes
  12. Redo Buffers 2125824 bytes
  13. SQL>
5、启动成功后,用rman恢复源机数据库的spfile
  1. [oracle@hostb:/u01/oracle/product/db10gr2/dbs]$rman target /

  2. Recovery Manager: Release 10.2.0.4.0 - Production on Wed Apr 27 16:01:32 2011

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

  4. connected to target database: DEFAULT (not mounted)

  5. RMAN> run {
  6. 2> ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' parms 'ENV=(NB_ORA_CLIENT=hosta)';
  7. 3> restore spfile from 'c-297293101-20110427-01';
  8. 4> release channel ch00;
  9. 5> }

  10. using target database control file instead of recovery catalog
  11. allocated channel: ch00
  12. channel ch00: sid=47 devtype=SBT_TAPE
  13. channel ch00: Veritas NetBackup for Oracle - Release 6.5 (2009050107)

  14. Starting restore at 2011-04-27 16:03:59

  15. channel ch00: autobackup found: c-297293101-20110427-01
  16. channel ch00: SPFILE restore from autobackup complete
  17. Finished restore at 2011-04-27 16:05:46

  18. released channel: ch00

  19. RMAN>
6、接下来将oracle shutdown,如果需要修改spfile可以先生成pfile文件进行修改然后在create spfile

第7和第8步用来恢复controlfile
7、使用新的spfile启动oracle到nomount状态
  1. [oracle@hostb:/u01/oracle/admin/sxzhdb/bdump]$sqlplus /nolog

  2. SQL*Plus: Release 10.2.0.4.0 - Production on Wed Apr 27 16:35:50 2011

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

  4. SQL> connect /as sysdba;
  5. Connected to an idle instance.
  6. SQL> startup nomount;
  7. ORACLE instance started.

  8. Total System Global Area 2.1475E+10 bytes
  9. Fixed Size 2107632 bytes
  10. Variable Size 1996490512 bytes
  11. Database Buffers 1.9462E+10 bytes
  12. Redo Buffers 14667776 bytes
  13. SQL>
8、启动没有问题的话就可以开始恢复controlfile了
  1. [oracle@hfylhp01:/u01/oracle/admin/sxzhdb/bdump]$rman target /

  2. Recovery Manager: Release 10.2.0.4.0 - Production on Wed Apr 27 16:39:09 2011

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

  4. connected to target database: sxzhdb (not mounted)

  5. RMAN> run {
  6. 2> ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' parms 'ENV=(NB_ORA_CLIENT=hosta)';
  7. restore controlfile from 'c-297293101-20110427-01';
  8. 3> 4> release channel ch00;
  9. 5> }

  10. using target database control file instead of recovery catalog
  11. allocated channel: ch00
  12. channel ch00: sid=1091 devtype=SBT_TAPE
  13. channel ch00: Veritas NetBackup for Oracle - Release 6.5 (2009050107)

  14. Starting restore at 2011-04-27 16:39:32

  15. channel ch00: restoring control file
  16. channel ch00: restore complete, elapsed time: 00:01:57
  17. output filename=/orasid/sys_u01/control01.ctl
  18. output filename=/orasid/redo_u01/control02.ctl
  19. output filename=/orasid/undo_u01/control03.ctl
  20. Finished restore at 2011-04-27 16:41:29

  21. released channel: ch00

  22. RMAN>

9、确认controlfile恢复成功后将数据库启动到mount状态
  1. RMAN> alter database mount;

  2. database mounted

  3. RMAN>
10、开始恢复数据库,这时最好写成脚本放在后台运行,并且将输出从定向到文件
  1. [oracle@hostb:/usr/openv/scripts]$cat res.rcv
  2. run {
  3. ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' parms 'ENV=(NB_ORA_CLIENT=hosta)';
  4. restore database;
  5. recover database;
  6. release channel ch00;
  7. }
  8. [oracle@hostb:/usr/openv/scripts]$cat res.sh
  9. nohup rman nocatalog target / cmdfile=res.rcv msglog=res.log.`date +%y%m%d%H%M` &
  10. [oracle@hostb:/usr/openv/scripts]$
直接执行res.sh,等到恢复完成后用命令打开数据库
  1. alter database open resetlog;
完成
阅读(1958) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~