ITPub博客

首页 > Linux操作系统 > Linux操作系统 > nbu 异地恢复数据

nbu 异地恢复数据

原创 Linux操作系统 作者:g644516804 时间:2011-07-15 18:36:46 0 删除 编辑

案例:

nbu异地恢复数据,目录不同

环境:

master service: stcs-mesbak,windows xp, NBU service 6.0, IP 172.16.51.49

生产服务器:stcs-fab1bak, AIX 6.0, NUB client 6.0, oracle 10.2.0.4, IP 172.16.51.31

测试服务器:stcsmestest_bak,AIX 6.0, NUB client 6.0,oracle 10.2.0.4(安装软件

 IP 172.16.51.100

stcs-fab1bak的全备,磁带备份

1.       stcsmestest_bak/etc/hosts中增加stcs-mesbak,stcs-fab1bakIPname

backup server(49)上增加client端的hostname Ip

172.16.51.103 STCS-FAB1BAK

172.16.51.49 STCS-MESBAK

2.     stcsmestest_bakbp.conf文件中增加:

SERVER= stcs-mesbak

CLIENT-NAME = stcsmestest_bak

3.     stcs_mesbak(NBU service)安装目录下的/netbackup/db/altnames中增加文件为:测试机的备份名,即:STCSMESTEST_BAK的文件即可。

4.     Copy spfile file and modify spfile

5.     Restore controlfile:

Sql>startup nomount;

$rman target / catalog rman/rman@orabak

RMAN> set dbid= 774218943

RMAN> run {

 >Allocate channel c1 type ‘sbt_tape’;

>Send ‘NB_ORA_SERV=stcs-mesbak,NB_ORA_CLIENT=stcs-fab1bak’;

>restore controlfile from autobackup ( or from ‘……’具体的某个controlfile)

>release channel c1;

>}

6.     Alter database mount;

Shutdown immediate;

Startup mount;

7.     Restore database

编写脚本,目录不同的恢复

Select ‘set newname for datafile ‘ ||file_id||’ to ‘’’||file_name||’’’; ‘ from dba_data_files;

$rman target / nocatalog cmdfile msglog /oratest/scripts/..log append << EOF

Run{

Allocate channel c1 type ‘sbt_tape’;

Allocate channel c2 type ‘sbt_tape’;

Send ‘NB_ORA_SERV=stcs-mesbak,NB_ORA_CLIENT=stcs-fab1bak’;

Set newname for datafile datafileid to ‘newlocation’;(利用上面的SQL)

Restore database;

Switch datafile all;

Recover database;

Release channel c1;

Release channel c2;

}

基于时间点的恢复:

Run{

Allocate channel c1 type ‘sbt_tape’;

Allocate channel c2 type ‘sbt_tape’;

Send ‘NB_ORA_SERV=stcs-mesbak,NB_ORA_CLIENT=stcs-fab1bak’;

set until time  to_date(‘12/3/2004 14:00:00','mm/dd/yyyy hh24:mi:ss');

set newname for datafile datafileid to ‘newlocation’;(利用上面的SQL)

Restore database;

Recover database;

Release channel c1;

Release channel c2;

}

也可以基于日志或是SCN恢复

set until sequence=XXX(日志号)

恢復archivelog

run{

allocate channel c1 type 'sbt_tape';

send 'NB_ORA_SERV=stcs-mesbak,NB_ORA_CLIENT=stcs-fab2bak';

set archivelog destination to '/ora101/archive/STCSMES';

 restore archivelog from sequence 33914;

}

 

 

 

8.      Alter database open resetlogs;

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01113: file 1 needs media recovery

ORA-01110: data file 1: '/ora101/oradata/STCSMES/system01.dbf';

 

SQL> recover database using backup controlfile until cancel;

ORA-00279: change 5992299176075 generated at 06/23/2011 02:35:13 needed for

thread 1

ORA-00289: suggestion : /ora101/archive/STCSMES/1_33929_713472255.arc

ORA-00280: change 5992299176075 for thread 1 is in sequence #33929

Specify log: {=suggested | filename | AUTO | CANCEL}

cancel

Media recovery cancelled.

注:recover database using backup controlfile until cancel;

會利用已有的archivelog直至沒有!!

SQL> alter database open resetlogs;

ERROR at line 1:

ORA-00344: unable to re-create online log '/ora102/oradata/STCSMES/redo01.log'

ORA-27040: file create error, unable to create file

IBM AIX RISC System/6000 Error: 2: No such file or directory

 

 

open之前需要将redo log temp tablespace 修改其路劲

alter database rename file '/ora102/oradata/STCSMES/temp06.dbf' to '/ora101/oradata/STCSMES/temp06.dbf';

alter database rename file '/ora102/oradata/STCSMES/redo02.log' to '/ora101/oradata/STCSMES/redo02.log'

 

alter database xxx rename file '.....' to '....';

在安装测试环境的NBU CLIENT中,碰到一问题,在用oratest test时不能辨别stb_tape,

主要是因为之后重新安装了oracle软件,$ORACLE_HOME/lib/目录下没有libobk.a,该文件是需要链接到/usr/openv/netbackup/bin/libobk.64a

Ln –s /usr/openv/netbackup/bin/libobk.64a $ORACLE_HOME/lib/libobk.a

 

做了多次的实验总结:

1.controlfile 用最新的,不要利用几天前的进行恢复

2.recover database 时看情况可能会用到archivelog的,将相关的archivelog  tape也找齐,至于恢复archivelog的方法和恢复controlfile 一样只是:

restore archivelog from time/scn/logseq XXX;

3.最重要的是制定好恢复方案,确定按照哪种方式恢复,一定 要找齐所有的tape,要不然会很麻烦的!!

 4. 当出现ORA-27191: sbtinfo2 returned error

Additional information: 2

是由于client 端的/etc/hosts 与其/usr/openv/netbackup/bp.conf IP name不同

或是server端的/etc/hosts中没有clientIP hostname

5. 恢复controlfile出现log

released channel: c1

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of restore command at 01/04/2012 09:58:49

ORA-19870: error reading backup piece cntrl_7444_1_771638982

ORA-19507: failed to retrieve sequential file, handle="cntrl_7444_1_771638982", parms=""

ORA-27029: skgfrtrv: sbtrestore returned error

ORA-19511: Error received from media manager layer, error text:

   Failed to open backup file for restore.

这个问题还是因为hostnameIP  bp.conf中有错误

修改正确之后,退出rman>,重新进入,获取更改之后的变量

可以用命令$ sbttest stb_tape 测试能够正确备份,连接到backup server

 

6. db ORACLE_HOME变更之后需要重新建立链接

$cd $ORACLE_HOME/lib

$ls |grep libobk.*

如果没有则:

$ln –s /usr/openv/netbackup/bin/libobk.a64  libobk.a

7. 恢复数据的时候,由于拥有多份备份,不知道该如何定位到具体的备份集,

利用了catalog备份,在rman backup server 中查找table rman. rc_backup_piece

table记录了所有的备份信息

当带库中有多个可用的备份集时,会逐一的查找备份集,最后将其他的磁带取出,将需要还原的磁带放入

$RMAN target / catalog rman/rman@orabak mslog  /ora104/scripts/mslog.log

RMAN> run {

allocate channel c1 type 'sbt_tape';

allocate channel c2 type 'sbt_tape';

send 'NB_ORA_SERV=stcs-mesbak,NB_ORA_CLIENT=stcs-fab2bak';

set until time="to_date('6/23/2011 2:40:00','mm/dd/yyyy hh24:mi:ss')";

set newname for datafile 1 to '/ora101/oradata/STCSMES/system01.dbf';

set newname for datafile 2 to '/ora101/oradata/STCSMES/system02.dbf';

set newname for datafile 3 to '/ora101/oradata/STCSMES/system03.dbf';

set newname for datafile 4 to '/ora101/oradata/STCSMES/undotbs01.dbf';

set newname for datafile 5 to '/ora101/oradata/STCSMES/undotbs02.dbf';

set newname for datafile 6 to '/ora101/oradata/STCSMES/undotbs03.dbf';

set newname for datafile 7 to '/ora101/oradata/STCSMES/sysaux01.dbf';

set newname for datafile 8 to '/ora101/oradata/STCSMES/SMPERP_MV01.dbf';

set newname for datafile 9 to '/ora101/oradata/STCSMES/SMPERP_MV02.dbf';

set newname for datafile 10 to '/ora101/oradata/STCSMES/SMPERP_MV_IDX01.dbf';

set newname for datafile 11 to '/ora101/oradata/STCSMES/users01.dbf';

set newname for datafile 12 to '/ora101/oradata/STCSMES/users02.dbf';

set newname for datafile 13 to '/ora101/oradata/STCSMES/users03.dbf';

set newname for datafile 14 to '/ora101/oradata/STCSMES/users04.dbf';

set newname for datafile 15 to '/ora101/oradata/STCSMES/users05.dbf';

set newname for datafile 16 to '/ora101/oradata/STCSMES/users06.dbf';

set newname for datafile 17 to '/ora101/oradata/STCSMES/users07.dbf';

set newname for datafile 18 to '/ora101/oradata/STCSMES/users08.dbf';

set newname for datafile 19 to '/ora101/oradata/STCSMES/users09.dbf';

set newname for datafile 20 to '/ora101/oradata/STCSMES/users10.dbf';

set newname for datafile 21 to '/ora101/oradata/STCSMES/users11.dbf';

set newname for datafile 22 to '/ora101/oradata/STCSMES/users12.dbf';

set newname for datafile 23 to '/ora101/oradata/STCSMES/users13.dbf';

set newname for datafile 24 to '/ora101/oradata/STCSMES/users14.dbf';

set newname for datafile 25 to '/ora101/oradata/STCSMES/users15.dbf';

set newname for datafile 26 to '/ora101/oradata/STCSMES/users16.dbf';

set newname for datafile 27 to '/ora101/oradata/STCSMES/users17.dbf';

set newname for datafile 28 to '/ora101/oradata/STCSMES/users18.dbf';

set newname for datafile 29 to '/ora101/oradata/STCSMES/users19.dbf';

set newname for datafile 30 to '/ora101/oradata/STCSMES/users20.dbf';

set newname for datafile 31 to '/ora101/oradata/STCSMES/users21.dbf';

set newname for datafile 32 to '/ora101/oradata/STCSMES/users22.dbf';

set newname for datafile 33 to '/ora101/oradata/STCSMES/users23.dbf';

set newname for datafile 34 to '/ora101/oradata/STCSMES/users24.dbf';

set newname for datafile 35 to '/ora101/oradata/STCSMES/users25.dbf';

set newname for datafile 36 to '/ora101/oradata/STCSMES/users26.dbf';

set newname for datafile 37 to '/ora101/oradata/STCSMES/users27.dbf';

set newname for datafile 38 to '/ora101/oradata/STCSMES/users28.dbf';

set newname for datafile 39 to '/ora101/oradata/STCSMES/users29.dbf';

set newname for datafile 40 to '/ora101/oradata/STCSMES/users30.dbf';

set newname for datafile 41 to '/ora101/oradata/STCSMES/users31.dbf';

set newname for datafile 42 to '/ora101/oradata/STCSMES/users32.dbf';

set newname for datafile 43 to '/ora101/oradata/STCSMES/users33.dbf';

set newname for datafile 44 to '/ora101/oradata/STCSMES/users34.dbf';

set newname for datafile 45 to '/ora101/oradata/STCSMES/users35.dbf';

set newname for datafile 46 to '/ora101/oradata/STCSMES/users36.dbf';

set newname for datafile 47 to '/ora101/oradata/STCSMES/users37.dbf';

set newname for datafile 48 to '/ora101/oradata/STCSMES/users38.dbf';

set newname for datafile 49 to '/ora101/oradata/STCSMES/users39.dbf';

set newname for datafile 50 to '/ora101/oradata/STCSMES/users40.dbf';

set newname for datafile 51 to '/ora101/oradata/STCSMES/users41.dbf';

set newname for datafile 52 to '/ora101/oradata/STCSMES/users42.dbf';

set newname for datafile 53 to '/ora101/oradata/STCSMES/users43.dbf';

set newname for datafile 54 to '/ora101/oradata/STCSMES/users44.dbf';

set newname for datafile 55 to '/ora101/oradata/STCSMES/users45.dbf';

set newname for datafile 56 to '/ora101/oradata/STCSMES/users46.dbf';

set newname for datafile 57 to '/ora101/oradata/STCSMES/users47.dbf';

set newname for datafile 58 to '/ora101/oradata/STCSMES/users48.dbf';

set newname for datafile 59 to '/ora101/oradata/STCSMES/users49.dbf';

set newname for datafile 60 to '/ora101/oradata/STCSMES/users50.dbf';

set newname for datafile 61 to '/ora101/oradata/STCSMES/users51.dbf';

set newname for datafile 62 to '/ora101/oradata/STCSMES/users52.dbf';

set newname for datafile 63 to '/ora101/oradata/STCSMES/users53.dbf';

set newname for datafile 64 to '/ora101/oradata/STCSMES/users54.dbf';

set newname for datafile 65 to '/ora101/oradata/STCSMES/users55.dbf';

set newname for datafile 66 to '/ora101/oradata/STCSMES/users56.dbf';

set newname for datafile 67 to '/ora101/oradata/STCSMES/users57.dbf';

set newname for datafile 68 to '/ora101/oradata/STCSMES/users58.dbf';

set newname for datafile 69 to '/ora101/oradata/STCSMES/users59.dbf';

set newname for datafile 70 to '/ora101/oradata/STCSMES/users60.dbf';

set newname for datafile 71 to '/ora101/oradata/STCSMES/users61.dbf';

set newname for datafile 72 to '/ora101/oradata/STCSMES/users62.dbf';

set newname for datafile 73 to '/ora101/oradata/STCSMES/users63.dbf';

set newname for datafile 74 to '/ora101/oradata/STCSMES/users64.dbf';

set newname for datafile 75 to '/ora101/oradata/STCSMES/users65.dbf';

set newname for datafile 76 to '/ora101/oradata/STCSMES/users66.dbf';

set newname for datafile 77 to '/ora101/oradata/STCSMES/users67.dbf';

set newname for datafile 78 to '/ora101/oradata/STCSMES/users68.dbf';

set newname for datafile 79 to '/ora101/oradata/STCSMES/users69.dbf';

set newname for datafile 80 to '/ora101/oradata/STCSMES/users70.dbf';

set newname for datafile 81 to '/ora101/oradata/STCSMES/users71.dbf';

set newname for datafile 82 to '/ora101/oradata/STCSMES/users72.dbf';

set newname for datafile 83 to '/ora101/oradata/STCSMES/users73.dbf';

set newname for datafile 84 to '/ora101/oradata/STCSMES/users74.dbf';

set newname for datafile 85 to '/ora101/oradata/STCSMES/users75.dbf';

set newname for datafile 86 to '/ora101/oradata/STCSMES/users76.dbf';

set newname for datafile 87 to '/ora101/oradata/STCSMES/users77.dbf';

set newname for datafile 88 to '/ora101/oradata/STCSMES/users78.dbf';

set newname for datafile 89 to '/ora101/oradata/STCSMES/users79.dbf';

set newname for datafile 90 to '/ora101/oradata/STCSMES/users80.dbf';

set newname for datafile 91 to '/ora101/oradata/STCSMES/users81.dbf';

set newname for datafile 92 to '/ora101/oradata/STCSMES/users82.dbf';

set newname for datafile 93 to '/ora101/oradata/STCSMES/users83.dbf';

set newname for datafile 94 to '/ora101/oradata/STCSMES/users84.dbf';

set newname for datafile 95 to '/ora101/oradata/STCSMES/users85.dbf';

set newname for datafile 96 to '/ora101/oradata/STCSMES/users86.dbf';

set newname for datafile 97 to '/ora101/oradata/STCSMES/users87.dbf';

set newname for datafile 98 to '/ora101/oradata/STCSMES/users88.dbf';

set newname for datafile 99 to '/ora101/oradata/STCSMES/users89.dbf';

set newname for datafile 100 to '/ora101/oradata/STCSMES/users90.dbf';

set newname for datafile 101 to '/ora101/oradata/STCSMES/users91.dbf';

set newname for datafile 102 to '/ora101/oradata/STCSMES/users92.dbf';

set newname for datafile 103 to '/ora101/oradata/STCSMES/users93.dbf';

set newname for datafile 104 to '/ora101/oradata/STCSMES/users94.dbf';

set newname for datafile 105 to '/ora101/oradata/STCSMES/users95.dbf';

set newname for datafile 106 to '/ora101/oradata/STCSMES/users96.dbf';

set newname for datafile 107 to '/ora101/oradata/STCSMES/users97.dbf';

set newname for datafile 108 to '/ora101/oradata/STCSMES/users98.dbf';

set newname for datafile 109 to '/ora101/oradata/STCSMES/users99.dbf';

set newname for datafile 110 to '/ora101/oradata/STCSMES/users100.dbf';

set newname for datafile 111 to '/ora101/oradata/STCSMES/users101.dbf';

set newname for datafile 112 to '/ora101/oradata/STCSMES/users102.dbf';

set newname for datafile 113 to '/ora101/oradata/STCSMES/users103.dbf';

set newname for datafile 114 to '/ora101/oradata/STCSMES/users104.dbf';

set newname for datafile 115 to '/ora101/oradata/STCSMES/users105.dbf';

set newname for datafile 116 to '/ora101/oradata/STCSMES/users106.dbf';

set newname for datafile 117 to '/ora101/oradata/STCSMES/users107.dbf';

 restore database;

 switch datafile all;

 recover database;

 release channel c1;

 release channel c2;}

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24849178/viewspace-702338/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-03-04

  • 博文量
    104
  • 访问量
    246396