rman恢复至临时数据库

<?xml version="1.0" encoding="utf-8"?> <meta content="text/html;charset=utf-8" http-equiv="Content-Type"/> <meta content="width=device-width, initial-scale=1" name="viewport"/> rman恢复至临时数据库 <meta content="Org mode" name="generator"/> <meta content="halberd.lee" name="author"/> <style type="text/css"> </style> <body>

rman恢复至临时数据库

Table of Contents

1 数据恢复

1.1 准备

1.1.1 启动到nomount状态

[oracle@boss1 recovery]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Sun May 10 23:34:23 2020

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

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 7180648448 bytes
Fixed Size                  2094960 bytes
Variable Size             872417424 bytes
Database Buffers         6291456000 bytes
Redo Buffers               14680064 bytes
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@boss1 recovery]$

1.1.2 查看截止SCN

通过 list backup of archivelog all; 命令查看全备的中,归档的最后的SCN号。 我们需要告诉RMAN, 恢复到此SCN号为止。不然会报RMAN-06054: media recovery requesting unknown log: thread N seq xxxxx lowscn xxxxxxxx 示例如下:

RMAN>   list backup of archivelog all;


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

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
28523   24.71G     DISK        00:03:12     17-APR-20
        BP Key: 48558   Status: AVAILABLE  Compressed: NO  Tag: TAG20200417T063445
        Piece Name: /orabackup/backup/rmanbak/0417/arc_BOSS_20200417_28548_1.bak

............. 省略 ..................

    BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
29338   23.70G     DISK        00:03:52     10-MAY-20
        BP Key: 50135   Status: AVAILABLE  Compressed: NO  Tag: TAG20200510T104532
        Piece Name: /orabackup/backup/rmanbak/0510/arc_BOSS_20200510_29363_1.bak

  List of Archived Logs in backup set 29338
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    15971   37992760305 09-MAY-20 38005724502 09-MAY-20
  1    15972   38005724502 09-MAY-20 38006158131 09-MAY-20
  1    15973   38006158131 09-MAY-20 38006517434 09-MAY-20
  1    15974   38006517434 09-MAY-20 38008332716 10-MAY-20
  1    15975   38008332716 10-MAY-20 38009880506 10-MAY-20
  1    15976   38009880506 10-MAY-20 38010101673 10-MAY-20
  1    15977   38010101673 10-MAY-20 38010260401 10-MAY-20
  1    15978   38010260401 10-MAY-20 38021698434 10-MAY-20
  1    15979   38021698434 10-MAY-20 38021702257 10-MAY-20
  2    11556   37992760877 09-MAY-20 38006520198 09-MAY-20
  2    11557   38006520198 09-MAY-20 38008308695 10-MAY-20
  2    11558   38008308695 10-MAY-20 38008332693 10-MAY-20
  2    11559   38008332693 10-MAY-20 38010101839 10-MAY-20
  2    11560   38010101839 10-MAY-20 38010147354 10-MAY-20
  2    11561   38010147354 10-MAY-20 38010260188 10-MAY-20
  2    11562   38010260188 10-MAY-20 38021698438 10-MAY-20
  2    11563   38021698438 10-MAY-20 38021702290 10-MAY-20   ====> 取最后一行的NEXT SCN 值

1.1.3 确认控制文件备份

通过 RMAN 命令 list backup of controlfile; 查找对应的控制文件。 本次操作,需要使用控制文件备份信息如下:

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
29333   Incr 0  3.22M      DISK        00:00:03     10-MAY-20
        BP Key: 50113   Status: AVAILABLE  Compressed: YES  Tag: TAG20200510T000809
        Piece Name: /orabackup/backup/rmanbak/0510/level0_BOSS_20200510_29361_1.bak
  Control File Included: Ckp SCN: 38011697387   Ckp time: 10-MAY-20

1.1.4 准备全量恢复脚本

rman脚本:

#!/bin/sh
rman target / <<EOF > recovery0510.log
restore controlfile from '/recovery/0510/level0_BOSS_20200510_29361_1.bak';
alter database mount;
catalog start with '/recovery/0510/' noprompt;
set until scn 38021702290;
run{
allocate channel ch00 type disk;
allocate channel ch01 type disk;
allocate channel ch02 type disk;
set newname for datafile 1 to '/oradata/system.259.959376163';
set newname for datafile 2 to '/oradata/undotbs1.260.959376167';
set newname for datafile 3 to '/oradata/sysaux.261.959376167';
set newname for datafile 4 to '/oradata/undotbs2.263.959376169';
set newname for datafile 5 to '/oradata/users.264.959376171';
set newname for datafile 6 to '/oradata/rep.333.959707819';
set newname for datafile 7 to '/oradata/so.332.959707819';
set newname for datafile 8 to '/oradata/cs.331.959707821';
set newname for datafile 9 to '/oradata/bp.330.959707821';
set newname for datafile 10 to '/oradata/cs_idx.329.959707823';
set newname for datafile 11 to '/oradata/bm_idx.328.959707823';
set newname for datafile 12 to '/oradata/bm.327.959707823';
set newname for datafile 13 to '/oradata/bp_idx.326.959707825';
set newname for datafile 14 to '/oradata/mr.325.959707825';
set newname for datafile 15 to '/oradata/sm.324.959707825';
set newname for datafile 16 to '/oradata/indexlrg.323.959707827';
set newname for datafile 17 to '/oradata/so_idx.322.959707827';
set newname for datafile 18 to '/oradata/ei.321.959707829';
set newname for datafile 19 to '/oradata/card.320.959707829';
set newname for datafile 20 to '/oradata/datalrg.319.959707829';
set newname for datafile 21 to '/oradata/mr_idx.318.959707831';
set newname for datafile 22 to '/oradata/ei_idx.317.959707831';
set newname for datafile 23 to '/oradata/tr.316.959707831';
set newname for datafile 24 to '/oradata/tr_idx.315.959707833';
set newname for datafile 25 to '/oradata/datausr.314.959707833';
set newname for datafile 26 to '/oradata/uc.313.959707835';
set newname for datafile 27 to '/oradata/uc_idx.312.959707835';
set newname for datafile 28 to '/oradata/sm_idx.311.959707837';
set newname for datafile 29 to '/oradata/wf.310.959707837';
set newname for datafile 30 to '/oradata/ms_idx.309.959707837';
set newname for datafile 31 to '/oradata/ua.308.959707839';
set newname for datafile 32 to '/oradata/up.307.959707839';
set newname for datafile 33 to '/oradata/up_idx.268.959707841';
set newname for datafile 34 to '/oradata/pm.306.959707841';
set newname for datafile 35 to '/oradata/bo.303.959707843';
set newname for datafile 36 to '/oradata/sequser.305.959707843';
set newname for datafile 37 to '/oradata/datasml.304.959707843';
set newname for datafile 38 to '/oradata/pm_idx.302.959707845';
set newname for datafile 39 to '/oradata/ms.301.959707845';
set newname for datafile 40 to '/oradata/ua_idx.292.959707845';
set newname for datafile 41 to '/oradata/sr.358.959707847';
set newname for datafile 42 to '/oradata/sso.357.959707847';
set newname for datafile 43 to '/oradata/sso_idx.356.959707847';
set newname for datafile 44 to '/oradata/sr_idx.273.959707849';
set newname for datafile 45 to '/oradata/rep.365.959707855';
set newname for datafile 46 to '/oradata/rep.366.959707855';
set newname for datafile 47 to '/oradata/rep.367.959707855';
set newname for datafile 48 to '/oradata/rep.300.959707857';
set newname for datafile 49 to '/oradata/rep.299.959707857';
set newname for datafile 50 to '/oradata/rep.298.959707857';
set newname for datafile 51 to '/oradata/rep.297.959707859';
set newname for datafile 52 to '/oradata/rep.296.959707859';
set newname for datafile 53 to '/oradata/rep.295.959707859';
set newname for datafile 54 to '/oradata/rep.294.959707861';
set newname for datafile 55 to '/oradata/rep.293.959707861';
set newname for datafile 56 to '/oradata/rep.291.959707863';
set newname for datafile 57 to '/oradata/rep.290.959707863';
set newname for datafile 58 to '/oradata/rep.289.959707863';
set newname for datafile 59 to '/oradata/rep.288.959707865';
set newname for datafile 60 to '/oradata/rep.287.959707865';
set newname for datafile 61 to '/oradata/rep.286.959707865';
set newname for datafile 62 to '/oradata/rep.285.959707867';
set newname for datafile 63 to '/oradata/rep.284.959707867';
set newname for datafile 64 to '/oradata/rep.283.959707867';
set newname for datafile 65 to '/oradata/rep.282.959707869';
set newname for datafile 66 to '/oradata/rep.281.959707869';
set newname for datafile 67 to '/oradata/rep.280.959707869';
set newname for datafile 68 to '/oradata/rep.279.959707871';
set newname for datafile 69 to '/oradata/rep.278.959707871';
set newname for datafile 70 to '/oradata/rep.277.959707871';
set newname for datafile 71 to '/oradata/rep.276.959707873';
set newname for datafile 72 to '/oradata/so.364.959707873';
set newname for datafile 73 to '/oradata/so.363.959707875';
set newname for datafile 74 to '/oradata/so.362.959707875';
set newname for datafile 75 to '/oradata/so.275.959707875';
set newname for datafile 76 to '/oradata/so.361.959707877';
set newname for datafile 77 to '/oradata/so.360.959707877';
set newname for datafile 78 to '/oradata/so.359.959707879';
set newname for datafile 79 to '/oradata/so.274.959707879';
set newname for datafile 80 to '/oradata/so.355.959707881';
set newname for datafile 81 to '/oradata/so.354.959707881';
set newname for datafile 82 to '/oradata/so.353.959707881';
set newname for datafile 83 to '/oradata/so.272.959707881';
set newname for datafile 84 to '/oradata/cs.352.959707883';
set newname for datafile 85 to '/oradata/cs.351.959707883';
set newname for datafile 86 to '/oradata/cs.350.959707885';
set newname for datafile 87 to '/oradata/cs.271.959707885';
set newname for datafile 88 to '/oradata/bp.349.959707885';
set newname for datafile 89 to '/oradata/bp.348.959707887';
set newname for datafile 90 to '/oradata/bp.347.959707887';
set newname for datafile 91 to '/oradata/cs_idx.346.959707887';
set newname for datafile 92 to '/oradata/cs_idx.270.959707889';
set newname for datafile 93 to '/oradata/cs_idx.345.959707889';
set newname for datafile 94 to '/oradata/bm_idx.344.959707891';
set newname for datafile 95 to '/oradata/bm_idx.343.959707891';
set newname for datafile 96 to '/oradata/bm_idx.342.959707893';
set newname for datafile 97 to '/oradata/bm.341.959707893';
set newname for datafile 98 to '/oradata/bm.340.959707893';
set newname for datafile 99 to '/oradata/bm.339.959707895';
set newname for datafile 100 to '/oradata/bp_idx.338.959707895';
set newname for datafile 101 to '/oradata/bp_idx.337.959707897';
set newname for datafile 102 to '/oradata/bp_idx.336.959707897';
set newname for datafile 103 to '/oradata/tbs_ggate.368.959529693';
set newname for datafile 104 to '/oradata/undotbs2.258.959862935';
set newname for datafile 105 to '/oradata/undotbs2.257.959862943';
set newname for datafile 106 to '/oradata/undotbs1.266.959862957';
set newname for datafile 107 to '/oradata/undotbs1.265.959862963';
set newname for datafile 108 to '/oradata/rep.373.959862979';
set newname for datafile 109 to '/oradata/rep.374.959862985';
set newname for datafile 110 to '/oradata/rep.375.959862991';
set newname for datafile 111 to '/oradata/mr_01.dbf';
set newname for datafile 112 to '/oradata/so_01.dbf';
set newname for datafile 113 to '/oradata/tbs_ggate_02';
set newname for datafile 114 to '/oradata/rep_01.dbf';
set newname for datafile 115 to '/oradata/rep_02.dbf';
set newname for datafile 116 to '/oradata/bm_5.dbf';
set newname for datafile 117 to '/oradata/cs_idx_5.dbf';
set newname for datafile 118 to '/oradata/rep_34.dbf';
set newname for datafile 119 to '/oradata/ucan_01.dbf';
set newname for datafile 120 to '/oradata/mr_03.dbf';
set newname for datafile 121 to '/oradata/rep_35.dbf';
set newname for datafile 122 to '/oradata/so_02.dbf';
set newname for datafile 123 to '/oradata/rep_36.dbf';
set newname for datafile 124 to '/oradata/rep_37.dbf';
set newname for datafile 125 to '/oradata/rep_38.dbf';
set newname for datafile 126 to '/oradata/rep_39.dbf';
set newname for datafile 127 to '/oradata/rep_40.dbf';
set newname for datafile 128 to '/oradata/rep_41.dbf';
set newname for datafile 129 to '/oradata/rep_42.dbf';
set newname for datafile 130 to '/oradata/rep_43.dbf';
set newname for datafile 131 to '/oradata/so_03.dbf';
set newname for tempfile 1 to '/oradata/temp.262.959376169';
set newname for tempfile 2 to '/oradata/temp_def.335.959707897';
set newname for tempfile 3 to '/oradata/temp_usr.334.959707899';
set newname for tempfile 4 to '/oradata/temp_dba.269.959707925';
restore database;
switch datafile all;
switch tempfile all;
recover database;
release channel ch00;
release channel ch01;
release channel ch02;
}
EOF

将以上内容保存到recovery.sh

1.1.5 准备增量恢复脚本

此步骤可能需要执行多闪。因此需要多次确认SCN号。

catalog start with '/recovery/0511/' noprompt;
set until scn 38031802340;
recovery database;

1.2 恢复数据

1.2.1 执行全备恢复

执行上面的rman 脚本。/sh recovery.sh/ 观察rman 日志,部分内容如下:


Recovery Manager: Release 10.2.0.4.0 - Production on Mon May 11 00:49:09 2020

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

connected to target database: boss (not mounted)

RMAN>
Starting restore at 11-MAY-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=2189 devtype=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output filename=/u01/app/oracle/control1.ctl
output filename=/u01/app/oracle/control2.ctl
Finished restore at 11-MAY-20

RMAN>
database mounted
released channel: ORA_DISK_1

RMAN>
searching for all files that match the pattern /recovery/0510/

List of Files Unknown to the Database
=====================================
File Name: /recovery/0510/level0_BOSS_20200510_29331_8.bak
File Name: /recovery/0510/level0_BOSS_20200510_29332_6.bak
File Name: /recovery/0510/level0_BOSS_20200510_29339_4.bak
........... 华丽丽的省略 ...........

File Name: /recovery/0510/level0_BOSS_20200510_29331_3.bak
File Name: /recovery/0510/level0_BOSS_20200510_29332_7.bak
File Name: /recovery/0510/level0_BOSS_20200510_29333_3.bak
File Name: /recovery/0510/level0_BOSS_20200510_29360_4.bak
File Name: /recovery/0510/level0_BOSS_20200510_29349_7.bak
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /recovery/0510/level0_BOSS_20200510_29331_8.bak
File Name: /recovery/0510/level0_BOSS_20200510_29332_6.bak
File Name: /recovery/0510/level0_BOSS_20200510_29339_4.bak
......... 华丽丽的省略 ...........
File Name: /recovery/0510/level0_BOSS_20200510_29331_3.bak
File Name: /recovery/0510/level0_BOSS_20200510_29332_7.bak
File Name: /recovery/0510/level0_BOSS_20200510_29333_3.bak
File Name: /recovery/0510/level0_BOSS_20200510_29360_4.bak
File Name: /recovery/0510/level0_BOSS_20200510_29349_7.bak

RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21> 22> 23> 24> 25> 26> 27> 28> 29> 30> 31> 32> 33> 34> 35> 36> 37> 38> 39> 40> 41> 42> 43> 44> 45> 46> 47> 48> 49> 50> 51> 52> 53> 54> 55> 56> 57> 58> 59> 60> 61> 62> 63> 64> 65> 66> 67> 68> 69> 70> 71> 72> 73> 74> 75> 76> 77> 78> 79> 80> 81> 82> 83> 84> 85> 86> 87> 88> 89> 90> 91> 92> 93> 94> 95> 96> 97> 98> 99> 100> 101> 102> 103> 104> 105> 106> 107> 108> 109> 110> 111> 112> 113> 114> 115> 116> 117> 118> 119> 120> 121> 122> 123> 124> 125> 126> 127> 128> 129> 130> 131> 132> 133> 134> 135> 136> 137> 138> 139> 140> 141> 142> 143> 144> 145> 146> 147>
allocated channel: ch00
channel ch00: sid=2189 devtype=DISK

allocated channel: ch01
channel ch01: sid=2188 devtype=DISK

allocated channel: ch02
channel ch02: sid=2187 devtype=DISK

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

....... 华丽丽的省略 ........

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 11-MAY-20

channel ch00: starting datafile backupset restore
channel ch00: specifying datafile(s) to restore from backup set
restoring datafile 00014 to /oradata/mr.325.959707825
restoring datafile 00017 to /oradata/so_idx.322.959707827
restoring datafile 00069 to /oradata/rep.278.959707871
restoring datafile 00117 to /oradata/cs_idx_5.dbf
channel ch00: reading from backup piece /orabackup/backup/rmanbak/0510/level0_BOSS_20200510_29331_1.bak
channel ch01: starting datafile backupset restore
channel ch01: specifying datafile(s) to restore from backup set
restoring datafile 00009 to /oradata/bp.330.959707821
restoring datafile 00076 to /oradata/so.361.959707877
restoring datafile 00079 to /oradata/so.274.959707879
restoring datafile 00086 to /oradata/cs.350.959707885
channel ch01: reading from backup piece /orabackup/backup/rmanbak/0510/level0_BOSS_20200510_29328_1.bak
channel ch02: starting datafile backupset restore
channel ch02: specifying datafile(s) to restore from backup set
restoring datafile 00008 to /oradata/cs.331.959707821
restoring datafile 00016 to /oradata/indexlrg.323.959707827
restoring datafile 00070 to /oradata/rep.277.959707871
restoring datafile 00116 to /oradata/bm_5.dbf
channel ch02: reading from backup piece /orabackup/backup/rmanbak/0510/level0_BOSS_20200510_29332_1.bak
channel ch02: restored backup piece 1
failover to piece handle=/recovery/0510/level0_BOSS_20200510_29332_1.bak tag=TAG20200510T000809
channel ch02: reading from backup piece /orabackup/backup/rmanbak/0510/level0_BOSS_20200510_29332_2.bak
channel ch00: restored backup piece 1
failover to piece handle=/recovery/0510/level0_BOSS_20200510_29331_1.bak tag=TAG20200510T000809
channel ch00: reading from backup piece /orabackup/backup/rmanbak/0510/level0_BOSS_20200510_29331_2.bak
channel ch01: restored backup piece 1
failover to piece handle=/recovery/0510/level0_BOSS_20200510_29328_1.bak tag=TAG20200510T000809
............ 华丽丽的省略 ...........
channel ch02: reading from backup piece /recovery/0510/level0_BOSS_20200510_29357_4.bak
channel ch02: restored backup piece 4
piece handle=/recovery/0510/level0_BOSS_20200510_29357_4.bak tag=TAG20200510T000809
channel ch02: reading from backup piece /recovery/0510/level0_BOSS_20200510_29357_5.bak
channel ch02: restored backup piece 5
piece handle=/recovery/0510/level0_BOSS_20200510_29357_5.bak tag=TAG20200510T000809
channel ch02: reading from backup piece /recovery/0510/level0_BOSS_20200510_29357_6.bak
channel ch02: restored backup piece 6
piece handle=/recovery/0510/level0_BOSS_20200510_29357_6.bak tag=TAG20200510T000809
channel ch02: reading from backup piece /recovery/0510/level0_BOSS_20200510_29357_7.bak
channel ch02: restored backup piece 7
piece handle=/recovery/0510/level0_BOSS_20200510_29357_7.bak tag=TAG20200510T000809
channel ch02: restore complete, elapsed time: 00:29:21
Finished restore at 11-MAY-20

datafile 1 switched to datafile copy
input datafile copy recid=132 stamp=1040109177 filename=/oradata/system.259.959376163
datafile 2 switched to datafile copy
input datafile copy recid=133 stamp=1040109177 filename=/oradata/undotbs1.260.959376167
datafile 3 switched to datafile copy
input datafile copy recid=134 stamp=1040109177 filename=/oradata/sysaux.261.959376167
datafile 4 switched to datafile copy
........... 华丽丽的省略 ................
input datafile copy recid=258 stamp=1040109193 filename=/oradata/rep_40.dbf
datafile 128 switched to datafile copy
input datafile copy recid=259 stamp=1040109193 filename=/oradata/rep_41.dbf
datafile 129 switched to datafile copy
input datafile copy recid=260 stamp=1040109193 filename=/oradata/rep_42.dbf
datafile 130 switched to datafile copy
input datafile copy recid=261 stamp=1040109193 filename=/oradata/rep_43.dbf
datafile 131 switched to datafile copy
input datafile copy recid=262 stamp=1040109193 filename=/oradata/so_03.dbf

renamed temporary file 1 to /oradata/temp.262.959376169 in control file
renamed temporary file 2 to /oradata/temp_def.335.959707897 in control file
renamed temporary file 3 to /oradata/temp_usr.334.959707899 in control file
renamed temporary file 4 to /oradata/temp_dba.269.959707925 in control file

Starting recover at 11-MAY-20

starting media recovery

channel ch00: starting archive log restore to default destination
channel ch00: restoring archive log
archive log thread=1 sequence=15974
channel ch00: restoring archive log
archive log thread=2 sequence=11557
channel ch00: restoring archive log
archive log thread=2 sequence=11558
channel ch00: restoring archive log
archive log thread=2 sequence=11559
channel ch00: restoring archive log
archive log thread=1 sequence=15975
channel ch00: restoring archive log
archive log thread=1 sequence=15976
channel ch00: restoring archive log
archive log thread=1 sequence=15977
channel ch00: restoring archive log
archive log thread=2 sequence=11560
channel ch00: restoring archive log
archive log thread=2 sequence=11561
channel ch00: restoring archive log
archive log thread=2 sequence=11562
channel ch00: restoring archive log
archive log thread=1 sequence=15978
channel ch00: restoring archive log
archive log thread=1 sequence=15979
channel ch00: restoring archive log
archive log thread=2 sequence=11563
channel ch00: reading from backup piece /recovery/0510/arc_BOSS_20200510_29363_1.bak
channel ch00: restored backup piece 1
piece handle=/recovery/0510/arc_BOSS_20200510_29363_1.bak tag=TAG20200510T104532
channel ch00: restore complete, elapsed time: 00:01:16
archive log filename=/recovery/1_15974_959376158.arc thread=1 sequence=15974
archive log filename=/recovery/2_11557_959376158.arc thread=2 sequence=11557
archive log filename=/recovery/2_11558_959376158.arc thread=2 sequence=11558
archive log filename=/recovery/2_11559_959376158.arc thread=2 sequence=11559
archive log filename=/recovery/1_15975_959376158.arc thread=1 sequence=15975
archive log filename=/recovery/1_15976_959376158.arc thread=1 sequence=15976
archive log filename=/recovery/1_15977_959376158.arc thread=1 sequence=15977
archive log filename=/recovery/2_11560_959376158.arc thread=2 sequence=11560
archive log filename=/recovery/2_11561_959376158.arc thread=2 sequence=11561
archive log filename=/recovery/2_11562_959376158.arc thread=2 sequence=11562
archive log filename=/recovery/1_15978_959376158.arc thread=1 sequence=15978
archive log filename=/recovery/1_15979_959376158.arc thread=1 sequence=15979
archive log filename=/recovery/2_11563_959376158.arc thread=2 sequence=11563
unable to find archive log
archive log thread=1 sequence=15980
released channel: ch00
released channel: ch01
released channel: ch02
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 05/11/2020 07:53:37
RMAN-06054: media recovery requesting unknown log: thread 1 seq 15980 lowscn 38021702257

RMAN>

Recovery Manager complete.

看到最后, 出现错误提示:RMAN-06054 , 说明,备份的归档在恢复后,仍不能保证数据的一致性。

1.2.2 执行增量恢复

将备份数据发送到目标环境:

scp -r /orabackup/backup/rmanbak/0511 oracle@10.88.1.39:/recovery/

临时生产环境中,需要多次恢复。

catalog start with '/recovery/0511/' noprompt;
recover database;

1.2.3 重建redo

需要确认控制文件中的redo 信息与恢复后的文件相匹配,否则无法open database.

set lines 32767 pages 5000
col status for a8
col type for a7
col member for a64

select a.inst_id,a.thread#,a.group#,a.sequence#,a.archived,a.status,b.type,b.member
from gv$log a ,gv$logfile b
where a.inst_id = b.inst_id
and a.group# = b.group#;

结果:

   INST_ID    THREAD#     GROUP#  SEQUENCE# ARC STATUS   TYPE    MEMBER
---------- ---------- ---------- ---------- --- -------- ------- ----------------------------------------------------------------
         1          1          3      15977 YES INACTIVE ONLINE  +DGDATA/boss/onlinelog/group_3.380.962034729
         1          1          1      15978 NO  CURRENT  ONLINE  +DGDATA/boss/onlinelog/group_1.378.962034643
         1          2          4      11562 NO  CURRENT  ONLINE  +DGDATA/boss/onlinelog/group_4.381.997111077
         1          2          2      11561 YES INACTIVE ONLINE  +DGDATA/boss/onlinelog/group_2.379.997111039

重建redo:

alter database rename file '+DGDATA/boss/onlinelog/group_3.380.962034729' to '/oradata/redo03.log';
alter database rename file '+DGDATA/boss/onlinelog/group_1.378.962034643' to '/oradata/redo01.log';
alter database rename file '+DGDATA/boss/onlinelog/group_2.379.997111039' to '/oradata/redo02.log';
alter database rename file '+DGDATA/boss/onlinelog/group_4.381.997111077' to '/oradata/redo04.log';
alter database clear unarchived logfile group 1;
alter database clear unarchived logfile group 2;
alter database clear unarchived logfile group 3;
alter database clear unarchived logfile group 4;

在这里需要注意, 执行rename file 的时候可能会报错:

ERROR at line 1:
ORA-00600: internal error code, arguments: [kgeade_is_0], [], [], [], [], [], [], []

无需理会,因为原文件与目标文件都不存在。只要执行后,控制文件中的内容被更新即可。如:

    SQL> alter database rename file '+DGDATA/boss/onlinelog/group_3.380.962034729' to '/oradata/redo03.log';
alter database rename file '+DGDATA/boss/onlinelog/group_3.380.962034729' to '/oradata/redo03.log'
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [kgeade_is_0], [], [], [], [], [],
[], []


SQL> set lines 32767 pages 5000
SQL> col status for a8
SQL> col type for a7
SQL> col member for a64
SQL>
SQL> select a.inst_id,a.thread#,a.group#,a.sequence#,a.archived,a.status,b.type,b.member
  2  from gv$log a ,gv$logfile b
  3  where a.inst_id = b.inst_id
  4  and a.group# = b.group#;

   INST_ID    THREAD#     GROUP#  SEQUENCE# ARC STATUS   TYPE    MEMBER
---------- ---------- ---------- ---------- --- -------- ------- ----------------------------------------------------------------
         1          1          3      15977 YES INACTIVE ONLINE  /oradata/redo03.log
         1          1          1      15978 NO  CURRENT  ONLINE  +DGDATA/boss/onlinelog/group_1.378.962034643
         1          2          4      11562 NO  CURRENT  ONLINE  +DGDATA/boss/onlinelog/group_4.381.997111077
         1          2          2      11561 YES INACTIVE ONLINE  +DGDATA/boss/onlinelog/group_2.379.997111039

SQL>

1.3 启动数据库

alter database open resetlogs;

2 修改IP

因为原来的库是RAC, 应用连接数据库的时候配置的IP 都是VIP。 为了减少应用运维修改配置的工作量,在临时生产环境中 启动vip 地址。

NOTE
原库停止后,再在临时生产库上添加IP。否则会出现IP冲突。
ifconfig eth0:2 10.88.1.4 netmask 255.255.255.224 broadcast 10.88.1.31 up
ifconfig eth0:1 10.88.1.5 netmask 255.255.255.224 broadcast 10.88.1.31 up

Author: halberd.lee

Created: 2020-05-11 Mon 22:00

Validate

上一篇:Oracle RMAN两种备份方式 – 备份集备份与镜像复制备份


下一篇:Oracle 12c RMAN备份与恢复实验