TSM+RMAN异机恢复实验

来源:互联网 发布:美团餐饮大数据 编辑:程序博客网 时间:2024/04/30 10:41


备份需要恢复的归档日志:

RMAN> run{ allocate channel dev1 type disk; backup archivelog from time "to_timestamp('2012-08-14 14:00:00','YYYY-MM-DD hh24:mi:ss')" until time "to_timestamp('2012-08-14 15:00:00','YYYY-MM-DD hh24:mi:ss')" FORMAT 'arch_%s_%p_%t;release channel dev1; }

 

run{ allocate CHANNEL  dev1 type disk; backup archivelog from time "to_timestamp(to_char(sysdate-0.7,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss')" until time "to_timestamp(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss')" FORMAT 'D:\arch_%s_%p_%t';release CHANNEL  dev1; }


恢复开始:
run {                                                 
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
restore spfile from 'c-1142373573-20120814-02';
release channel ch00;
}


run {                                                 
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
restore controlfile from 'ctl20120814SGCRM5xx_1214_1_791316611';
release channel ch00;
}

alter database mount;

run {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
restore database;
release channel ch00;
release channel ch01;
}

 

查看恢复的大小和速度:
tsm: SGBACKUP>test_sta:q se 

1.可以先restore
RMAN> run {
2> ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
3> ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
4> restore database;
5> release channel ch00;
6> release channel ch01;
7> }

allocated channel: ch00
channel ch00: SID=864 device type=SBT_TAPE
channel ch00: Data Protection for Oracle: version 5.5.1.0

allocated channel: ch01
channel ch01: SID=862 device type=SBT_TAPE
channel ch01: Data Protection for Oracle: version 5.5.1.0

Starting restore at 2012-08-14 16:09:19

channel ch00: starting datafile backup set restore
channel ch00: specifying datafile(s) to restore from backup set
channel ch00: restoring datafile 00001 to +DG_A/sgcrm5/datafile/system.270.764776717
channel ch00: restoring datafile 00063 to +DG_B/sgcrm5/datafile/dat_auto_02.312.790179703
channel ch00: reading from backup piece bk_1177_1_791063256
channel ch01: starting datafile backup set restore
channel ch01: specifying datafile(s) to restore from backup set
channel ch01: restoring datafile 00064 to +DG_B/sgcrm5/datafile/dat_auto_02.313.791200831
channel ch01: reading from backup piece bk_1205_1_791297355
channel ch01: piece handle=bk_1205_1_791297355 tag=TAG20120814T124912
channel ch01: restored backup piece 1
channel ch01: restore complete, elapsed time: 00:02:15


RMAN> list backupset 1167;


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


BS Key  Type LV Size       Device Type Elapsed Time Completion Time   
------- ---- -- ---------- ----------- ------------ -------------------
1167    Incr 0  189.98G    SBT_TAPE    00:34:21     2012-08-11 20:21:57
        BP Key: 1167   Status: AVAILABLE  Compressed: NO  Tag: TAG20120811T194734
        Handle: bk_1177_1_791063256   Media: 1837
  List of Datafiles in backup set 1167
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1    0  Incr 1837090888 2012-08-11 19:50:00 +DG_A/sgcrm5/datafile/system.270.764776717
  2    0  Incr 1837090888 2012-08-11 19:50:00 +DG_A/sgcrm5/datafile/sysaux.261.764776717
  63   0  Incr 1837090888 2012-08-11 19:50:00 +DG_B/sgcrm5/datafile/dat_auto_02.312.790179703

RMAN>

 

恢复归档日志:
RMAN> run {
2> ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
3> set archivelog destination to '/oradata/oraarch';
4> restore archivelog low logseq 1370;
5> release channel ch00;
6> }

allocated channel: ch00
channel ch00: SID=867 device type=SBT_TAPE
channel ch00: Data Protection for Oracle: version 5.5.1.0

executing command: SET ARCHIVELOG DESTINATION

Starting restore at 2012-08-14 18:24:12

channel ch00: starting archived log restore to user-specified destination
archived log destination=/oradata/oraarch
channel ch00: restoring archived log
archived log thread=1 sequence=1370
channel ch00: restoring archived log
archived log thread=1 sequence=1371
channel ch00: reading from backup piece arch_1213_1_791316455
channel ch00: piece handle=arch_1213_1_791316455 tag=TAG20120814T180735
channel ch00: restored backup piece 1
channel ch00: restore complete, elapsed time: 00:00:35
Finished restore at 2012-08-14 18:24:54

released channel: ch00

RMAN>

2.也可以restore,recover一起做,如果有需求可以指定时间点。
RMAN> run {
2> ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
3> ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE' parms 'ENV=(tdpo_optfile=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
4> restore database;
5> recover database;
6> release channel ch00;
7> release channel ch01;
8> }

using target database control file instead of recovery catalog
allocated channel: ch00
channel ch00: SID=864 device type=SBT_TAPE
channel ch00: Data Protection for Oracle: version 5.5.1.0

allocated channel: ch01
channel ch01: SID=863 device type=SBT_TAPE
channel ch01: Data Protection for Oracle: version 5.5.1.0

Starting restore at 2012-08-14 18:34:43

channel ch00: starting datafile backup set restore
channel ch00: specifying datafile(s) to restore from backup set
channel ch00: restoring datafile 00001 to +DG_A/sgcrm5/datafile/system.270.764776717
channel ch00: restoring datafile 00063 to +DG_B/sgcrm5/datafile/dat_auto_02.312.790179703
channel ch00: reading from backup piece bk_1177_1_791063256
channel ch01: starting datafile backup set restore
channel ch01: specifying datafile(s) to restore from backup set
channel ch01: restoring datafile 00064 to +DG_B/sgcrm5/datafile/dat_auto_02.313.791200831
channel ch01: reading from backup piece bk_1205_1_791297355
channel ch00: piece handle=bk_1177_1_791063256 tag=TAG20120811T194734
channel ch00: restored backup piece 1
channel ch00: restore complete, elapsed time: 00:42:56
channel ch01: piece handle=bk_1205_1_791297355 tag=TAG20120814T124912
channel ch01: restored backup piece 1
channel ch01: restore complete, elapsed time: 00:44:46
Finished restore at 2012-08-14 19:19:40

Starting recover at 2012-08-14 19:19:40
channel ch00: starting incremental datafile backup set restore
channel ch00: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: +DG_A/sgcrm5/datafile/system.307.791320429
destination for restore of datafile 00063: +DG_A/sgcrm5/datafile/dat_auto_02.302.791320395
channel ch00: reading from backup piece bk_1188_1_791141342
channel ch00: piece handle=bk_1188_1_791141342 tag=TAG20120812T172900
channel ch00: restored backup piece 1
channel ch00: restore complete, elapsed time: 00:02:45
channel ch00: starting incremental datafile backup set restore
channel ch00: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: +DG_A/sgcrm5/datafile/system.307.791320429
destination for restore of datafile 00002: +DG_A/sgcrm5/datafile/sysaux.306.791320421
destination for restore of datafile 00063: +DG_A/sgcrm5/datafile/dat_auto_02.302.791320395
channel ch00: reading from backup piece bk_1205_1_791297355
channel ch00: piece handle=bk_1205_1_791297355 tag=TAG20120814T124912
channel ch00: restored backup piece 1
channel ch00: restore complete, elapsed time: 00:03:15

starting media recovery

archived log for thread 1 with sequence 1370 is already on disk as file /flash_recovery_area/SGCRM5/archivelog/2012_08_14/o1_mf_1_1370_82mvlfvf_.arc
archived log for thread 1 with sequence 1371 is already on disk as file /flash_recovery_area/SGCRM5/archivelog/2012_08_14/o1_mf_1_1371_82mvtcmw_.arc
channel ch00: starting archived log restore to default destination
channel ch00: restoring archived log
archived log thread=1 sequence=1368
channel ch00: restoring archived log
archived log thread=1 sequence=1369
channel ch00: reading from backup piece al_1208_1_791300306
channel ch00: piece handle=al_1208_1_791300306 tag=TAG20120814T132617
channel ch00: restored backup piece 1
channel ch00: restore complete, elapsed time: 00:02:15
archived log file name=/flash_recovery_area/SGCRM5/archivelog/2012_08_14/o1_mf_1_1368_82nfjxq8_.arc thread=1 sequence=1368
channel default: deleting archived log(s)
archived log file name=/flash_recovery_area/SGCRM5/archivelog/2012_08_14/o1_mf_1_1368_82nfjxq8_.arc RECID=1378 STAMP=791321265
archived log file name=/flash_recovery_area/SGCRM5/archivelog/2012_08_14/o1_mf_1_1369_82nfjy69_.arc thread=1 sequence=1369
channel default: deleting archived log(s)
archived log file name=/flash_recovery_area/SGCRM5/archivelog/2012_08_14/o1_mf_1_1369_82nfjy69_.arc RECID=1377 STAMP=791321246
archived log file name=/flash_recovery_area/SGCRM5/archivelog/2012_08_14/o1_mf_1_1370_82mvlfvf_.arc thread=1 sequence=1370
archived log file name=/flash_recovery_area/SGCRM5/archivelog/2012_08_14/o1_mf_1_1371_82mvtcmw_.arc thread=1 sequence=1371
unable to find archived log
archived log thread=1 sequence=1372
released channel: ch00
released channel: ch01
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 08/14/2012 19:28:54
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 1372 and starting SCN of 1841281390

RMAN> exit 
 
到此有三种方法打开数据:
1.重建控制文件

alter database backup controlfile to trace


2.使用归档+redo


3.sql> recover database using backup controlfile until cancel;
     Prompt的时候再输入:cancel
最后:
Sql> alter database open resetlogs;
注意:使用备份的controlfile恢复则一定要做resetlogs

异机恢复完成,数据可以恢复到最新点。


 

channel ch00: starting piece 1 at 2012-08-21 23:14:28released channel: ch00RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03009: failure of backup command on ch00 channel at 08/22/2012 00:22:55ORA-19502: write error on file "bk_1291_1_791939518", block number 1 (block size=512)ORA-27030: skgfwrt: sbtwrite2 returned errorORA-19511: Error received from media manager layer, error text:   ANS1235E (RC-72)  An unknown system error has occurred from which TSM cannot recover.

问题应是LEVEL 1备份时会对数据文件进行检查(在数据库较大时也更为耗时),而导致TSM Session超时.

解决方法:
影响TSM Session超时时间的是dsmserv.opt文件中的commtimeout参数,其默认值为60秒,通过增加该参数值,可解决问题(如设置为600秒),最后还需重启TSM Server才会生效.

原创粉丝点击