记一次TSM备份软件的rman恢复

一、背景

  oracle:11.2.0.3 单机  通过tsm备份软件备份(什么玩意不太读懂,反正就是调用rman接口备份)。这是客户的一套OA的数据库,现在需要通过tsm做个恢复测试演练。

二、撸起袖子,开干

  2.1 还原参数文件,忘记记录(略)

  2.2 还原控制文件

  

run{
allocate channel t1 type 'sbt_tape' parms
'ENV=(tdpo_optfile= /opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
restore controlfile from 'NEROA_cntrl_12753_1_1023216458';
release channel t1;
} 

  2.3 还原数据库

run
{
allocate channel t1 type 'sbt_tape' parms
'ENV=(tdpo_optfile= /opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
set newname for datafile 1 to '/rmanbak/oracle/oradata/NEROA/system01.dbf';
set newname for datafile 2 to '/rmanbak/oracle/oradata/NEROA/sysaux01.dbf';
set newname for datafile 3 to '/rmanbak/oracle/oradata/NEROA/undotbs01.dbf';
set newname for datafile 4 to '/rmanbak/oracle/oradata/NEROA/users01.dbf';
set newname for datafile 5 to '/rmanbak/oracle/oradata/NEROA/NEROA.dbf';
set newname for datafile 6 to '/rmanbak/oracle/oradata/NEROA/NEROA_TEST.dbf';
set newname for datafile 7 to '/rmanbak/oracle/oradata/OATEST.dbf';
set newname for datafile 8 to '/rmanbak/oracle/oradata/NEROA/oalinuxtest.dbf';
set newname for datafile 9 to '/rmanbak/oracle/oradata/NEROA/system02.dbf';
set newname for datafile 10 to '/rmanbak/oracle/oradata/NEROA/NEROA02.dbf';
set newname for datafile 11 to '/rmanbak/oracle/oradata/NEROA/sysaux02.dbf';
set newname for datafile 12 to '/rmanbak/oracle/oradata/NEROA/system03.dbf';
set newname for datafile 13 to '/rmanbak/oracle/oradata/NEROA/system04.dbf';
set newname for datafile 14 to '/rmanbak/oracle/oradata/NEROA/system05.dbf';
set newname for datafile 15 to '/rmanbak/oracle/oradata/NEROA/system06.dbf';
set newname for datafile 16 to '/rmanbak/oracle/oradata/NEROA/NEROA03.dbf';
set newname for datafile 17 to '/rmanbak/oracle/oradata/NEROA/system07.dbf';
set newname for datafile 18 to '/rmanbak/oracle/oradata/NEROA/system08.dbf';
set newname for datafile 19 to '/rmanbak/oracle/oradata/NEROA/system09.dbf';
set newname for datafile 20 to '/rmanbak/oracle/oradata/NEROA/NEROA04.dbf';
set newname for datafile 21 to '/rmanbak/oracle/oradata/NEROA/NEROA05.dbf';
restore database;
release channel t1;
}

--别问我为什么只开一个通道,我也想知道为什么开多个会报错

  2.4 注册数据文件为datafilecopy

catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/system01.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/sysaux01.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/undotbs01.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/users01.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/NEROA.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/NEROA_TEST.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/OATEST.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/oalinuxtest.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/system02.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/NEROA02.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/sysaux02.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/system03.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/system04.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/system05.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/system06.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/NEROA03.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/system07.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/system08.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/system09.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/NEROA04.dbf';
catalog datafilecopy '/rmanbak/oracle/oradata/NEROA/NEROA05.dbf';

  2.5 切换至副本

switch datafile 1  to copy;
switch datafile 2  to copy;
switch datafile 3  to copy;
switch datafile 4  to copy;
switch datafile 5  to copy;
switch datafile 6  to copy;
switch datafile 7  to copy;
switch datafile 8  to copy;
switch datafile 9  to copy;
switch datafile 10 to copy;
switch datafile 11 to copy;
switch datafile 12 to copy;
switch datafile 13 to copy;
switch datafile 14 to copy;
switch datafile 15 to copy;
switch datafile 16 to copy;
switch datafile 17 to copy;
switch datafile 18 to copy;
switch datafile 19 to copy;
switch datafile 20 to copy;
switch datafile 21 to copy;

--别问我为什么部switch database all ,问就是报错

  2.6 由于源库有个数据文件状态为recover,需要将状态设置为offline。不然将从没有变化的scn号开始恢复

SQL> alter database datafile 4 offline;

  2.7 手工recover,确认所需的归档(为什么要手工,因为rman报错,就是这么操蛋)

SQL> recover database using backup controlfile until cancel;    --确定所需的归档

run{ allocate channel t1 type
'sbt_tape' parms 'ENV=(tdpo_optfile= /opt/tivoli/tsm/client/oracle/bin64/tdpo.opt)'; restore archivelog from logseq 14060; --从14060开始还原归档 release channel t1; }

SQL> recover database using backup controlfile until cancel; --应用已经还原的归档

  2.8 重命名redo日志,因为路径不对

alter database rename file '/u01/oracle/oradata/NEROA/redo02.log' to '/rmanbak/oracle/oradata/NEROA/redo02.log';
alter database rename file '/u01/oracle/oradata/NEROA/redo01.log' to '/rmanbak/oracle/oradata/NEROA/redo01.log';
alter database rename file '/u01/oracle/oradata/NEROA/redo03.log' to '/rmanbak/oracle/oradata/NEROA/redo03.log';

  2.9 open

SQL> alter database open resetlogs;
alter database open resetlogs
*1 行出现错误:
ORA-00392: 日志 3 (用于线程 1) 正被清除, 不允许操作
ORA-00312: 联机日志 3 线程 1: '/rmanbak/oracle/oradata/NEROA/redo03.log'


SQL> alter database clear logfile group 1;

数据库已更改。

SQL> alter database clear logfile group 2; 

数据库已更改。

SQL> alter database clear logfile group 3;


SQL> alter database open resetlogs;   

 

   

 

posted on 2019-11-05 16:20  伶仃匹夫  阅读(413)  评论(0编辑  收藏  举报