某客戶使用RMAN資料庫恢復測試步驟
*注意*:使用catalog進行恢復測試的時候,會導致修改原catalog,因此做這個測試的時候,為了不對正式環境產生任何影響建議先把DB_BAK 的catalog目錄匯入到其他模式或其他資料庫,用匯出的catalog進行恢復測試
1.如果存在userrestore_test,應當先刪除
SQL>drop user restore_test cascade;
2.建立restore_test 在Cat資料庫中
SQL>create user restore_test identified by restore_test
defaulttablespace rman_ts
temporarytablespace temp
quotaunlimited on rman_ts;
SQL>grant resource ,connect,recovery_catalog_owner torestore_test;
3按使用者匯出RMAN的CATALOG目錄
$exp db_bak/[email protected] owner=db_bak file=exp.dat
4.將匯出的檔案Import到Restore_test
$imp restore_test/[email protected] fromuser=db_bak to user=restore_test file=exp.dat ignore=y
5.建一個空庫DBNEW
或手工建立:
exportORACLE_SID=DBNEW
mkdir%ORABASE%\admin\%ORACLE_SID%\bdump
mkdir%ORABASE%\admin\%ORACLE_SID%\cdump
mkdir%ORABASE%\admin\%ORACLE_SID%\create
mkdir%ORABASE%\admin\%ORACLE_SID%\pfile
mkdir%ORABASE%\admin\%ORACLE_SID%\udump
mkdir%ORABASE%\ora92\database
mkdir%ORABASE%\oradata\%ORACLE_SID%
建立Oracle 服務
$oradim-new sid DBNEW -startmode m
建立密碼檔案
orapwdfile=%ORAHOME%\database\PWDDBNEW.ora password =change_on _install
6.恢復SPFILE
以pfile啟動到nomount
SQL>start force nomountpfile='%ORABASE%\admin\%ORACLE_SID%\pfile\init.ora'
RMAN> restore spfile
關閉資料庫
SQL>Shutdown Immediate
7.在恢復機上啟動目的資料庫到NOMOUNT狀態,恢復控制檔案
SQL>startup nomount;
$rman target sys/[email protected] catalogrestore_test/[email protected]
RMAN>
run {
allocatechannel 'dev_0' type 'sbt_tape'
parms'ENV=(OB2BARTYPE=Oracle8,OB2BARHOSTNAME=shzmfgdb,OB2BARLIST="DB WeeklyFUll",OB2APPNAME=dbnew)';
restorecontrolfile to '/js01/vgdata/rlvctrl01';
restorecontrolfile to '/js02/vgindex/rlvctrl02';
restorecontrolfile to '/js02/vglog/rlvctrl03';
Sql 'alterdatabase mount';
}
8.恢復資料檔案
$nohup rman catalog restore_test/[email protected] targetsys/[email protected] cmdfile fr_3.txt log fr_3.log append
附上命令檔案(如果資料檔案有變更需增加)
run {
allocate channel 'dev_0' type 'sbt_tape'
parms 'ENV=(OB2BARTYPE=Oracle8,OB2BARHOSTNAME=shzmfgdb,OB2BARLIST="DB Weekly FUll",OB2APPNAME=JDEOW)';
set newname for datafile 1 to '/dev/vgdata/rlvsystem01';
set newname for datafile 2 to '/dev/vgdata/rlvundo01';
set newname for datafile 3 to '/dev/vgdata/rlvundo02';
set newname for datafile 4 to '/dev/vgdata/rlvtools01';
set newname for datafile 5 to '/dev/vgdata/rlvusers01';
set newname for datafile 6 to '/dev/vgdata/rlvxdb01';
set newname for datafile 7 to '/dev/vgdata/rlvsy810t01';
set newname for datafile 8 to '/dev/vgindex/rlvsy810i01';
set newname for datafile 9 to '/dev/vgdata/rlvsvm810t01';
set newname for datafile 10 to '/dev/vgindex/rlvsvm810as1i01';
set newname for datafile 11 to '/dev/vgdata/rlvol810t01';
set newname for datafile 12 to '/dev/vgindex/rlvol810i01';
set newname for datafile 13 to '/dev/vgdata/rlvpd810t01';
set newname for datafile 14 to '/dev/vgdata/rlvpd810t02';
set newname for datafile 15 to '/dev/vgdata/rlvpd810t03';
set newname for datafile 16 to '/dev/vgdata/rlvpd810t04';
set newname for datafile 17 to '/dev/vgdata/rlvpd810t05';
set newname for datafile 18 to '/dev/vgindex/rlvpd810i01';
set newname for datafile 19 to '/dev/vgindex/rlvpd810i02';
set newname for datafile 20 to '/dev/vgdata/rlvpy810t01';
set newname for datafile 21 to '/dev/vgdata/rlvpy810t02';
set newname for datafile 22 to '/dev/vgdata/rlvpy810t03';
set newname for datafile 23 to '/dev/vgdata/rlvpy810t04';
set newname for datafile 24 to '/dev/vgdata/rlvpy810t05';
set newname for datafile 25 to '/dev/vgindex/rlvpy810i01';
set newname for datafile 26 to '/dev/vgindex/rlvpy810i02';
set newname for datafile 27 to '/dev/vgdata/rlvproddtat01';
set newname for datafile 28 to '/dev/vgdata/rlvproddtat02';
set newname for datafile 29 to '/dev/vgdata/rlvproddtat03';
set newname for datafile 30 to '/dev/vgdata/rlvproddtat04';
set newname for datafile 31 to '/dev/vgdata/rlvproddtat05';
set newname for datafile 32 to '/dev/vgdata/rlvproddtat06';
set newname for datafile 33 to '/dev/vgdata/rlvproddtat07';
set newname for datafile 34 to '/dev/vgdata/rlvproddtat08';
set newname for datafile 35 to '/dev/vgdata/rlvproddtat09';
set newname for datafile 36 to '/dev/vgdata/rlvproddtat10';
set newname for datafile 37 to '/dev/vgindex/rlvproddtai01';
set newname for datafile 38 to '/dev/vgindex/rlvproddtai02';
set newname for datafile 39 to '/dev/vgindex/rlvproddtai03';
set newname for datafile 40 to '/dev/vgindex/rlvproddtai04';
set newname for datafile 41 to '/dev/vgindex/rlvproddtai05';
set newname for datafile 42 to '/dev/vgindex/rlvproddtai06';
set newname for datafile 43 to '/dev/vgindex/rlvproddtai07';
set newname for datafile 44 to '/dev/vgindex/rlvproddtai08';
set newname for datafile 45 to '/dev/vgindex/rlvproddtai09';
set newname for datafile 46 to '/dev/vgindex/rlvproddtai10';
set newname for datafile 47 to '/dev/vgdata/rlvdd810t01';
set newname for datafile 48 to '/dev/vgindex/rlvdd810i01';
set newname for datafile 49 to '/dev/vgdata/rlvps810t01';
set newname for datafile 50 to '/dev/vgdata/rlvps810t02';
set newname for datafile 51 to '/dev/vgdata/rlvps810t03';
set newname for datafile 52 to '/dev/vgdata/rlvps810t04';
set newname for datafile 53 to '/dev/vgdata/rlvps810t05';
set newname for datafile 54 to '/dev/vgindex/rlvps810i01';
set newname for datafile 55 to '/dev/vgindex/rlvps810i02';
set newname for datafile 56 to '/dev/vgdata/rlvps810dtat01';
set newname for datafile 57 to '/dev/vgindex/rlvps810dtai01';
set newname for datafile 58 to '/dev/vgdata/rlvcrpdtat01';
set newname for datafile 59 to '/dev/vgdata/rlvcrpdtat02';
set newname for datafile 60 to '/dev/vgdata/rlvcrpdtat03';
set newname for datafile 61 to '/dev/vgdata/rlvcrpdtat04';
set newname for datafile 62 to '/dev/vgdata/rlvcrpdtat05';
set newname for datafile 63 to '/dev/vgdata/rlvcrpdtat06';
set newname for datafile 64 to '/dev/vgdata/rlvcrpdtat07';
set newname for datafile 65 to '/dev/vgdata/rlvcrpdtat08';
set newname for datafile 66 to '/dev/vgdata/rlvcrpdtat09';
set newname for datafile 67 to '/dev/vgdata/rlvcrpdtat10';
set newname for datafile 68 to '/dev/vgindex/rlvcrpdtai01';
set newname for datafile 69 to '/dev/vgindex/rlvcrpdtai02';
set newname for datafile 70 to '/dev/vgindex/rlvcrpdtai03';
set newname for datafile 71 to '/dev/vgindex/rlvcrpdtai04';
set newname for datafile 72 to '/dev/vgindex/rlvcrpdtai05';
set newname for datafile 73 to '/dev/vgindex/rlvcrpdtai06';
set newname for datafile 74 to '/dev/vgindex/rlvcrpdtai07';
set newname for datafile 75 to '/dev/vgindex/rlvcrpdtai08';
set newname for datafile 76 to '/dev/vgindex/rlvcrpdtai09';
set newname for datafile 77 to '/dev/vgindex/rlvcrpdtai10';
set newname for datafile 78 to '/dev/vgdata/rlvjde_e810t01';
set newname for datafile 79 to '/dev/vgindex/rlvjde_e810i01';
set newname for datafile 80 to '/dev/vgdata/rlvjde_e810_pyt01';
set newname for datafile 81 to '/dev/vgdata/rlvprodctlt01';
set newname for datafile 82 to '/dev/vgindex/rlvprodctli01';
set newname for datafile 83 to '/dev/vgdata/rlvps810ctlt01';
set newname for datafile 84 to '/dev/vgindex/rlvps810ctli01';
set newname for datafile 85 to '/dev/vgdata/rlvcrpctlt01';
set newname for datafile 86 to '/dev/vgindex/rlvcrpctli01';
set newname for datafile 87 to '/dev/vgindex/rlvjde_810_pyi01';
set newname for datafile 88 to '/dev/vgdata/rlvpd810t06';
set newname for datafile 89 to '/dev/vgdata/rlvpd810t07';
set newname for datafile 90 to '/dev/vgindex/rlvpd810i03';
set newname for datafile 91 to '/dev/vgdata/rlvpy810t06';
set newname for datafile 92 to '/dev/vgdata/rlvpy810t07';
set newname for datafile 93 to '/dev/vgindex/rlvpy810i03';
set newname for datafile 94 to '/dev/vgdata/rlvps810t06';
set newname for datafile 95 to '/dev/vgdata/rlvps810t07';
set newname for datafile 96 to '/dev/vgindex/rlvps810i03';
set newname for datafile 97 to '/dev/vgdata/rlvsvm810as1t01';
set newname for datafile 98 to '/dev/vgindex/rlvsvm810as1i03';
set newname for datafile 99 to '/dev/vgdata/rlvsvm810as2t01';
set newname for datafile 100 to '/dev/vgindex/rlvsvm810as2i01';
set newname for datafile 101 to '/dev/vgdata/rlvdv810t01';
set newname for datafile 102 to '/dev/vgdata/rlvdv810t02';
set newname for datafile 103 to '/dev/vgdata/rlvdv810t03';
set newname for datafile 104 to '/dev/vgdata/rlvdv810t04';
set newname for datafile 105 to '/dev/vgdata/rlvdv810t05';
set newname for datafile 106 to '/dev/vgdata/rlvdv810t06';
set newname for datafile 107 to '/dev/vgdata/rlvdv810t07';
set newname for datafile 108 to '/dev/vgindex/rlvdv810i01';
set newname for datafile 109 to '/dev/vgindex/rlvdv810i02';
set newname for datafile 110 to '/dev/vgindex/rlvdv810i03';
set newname for datafile 111 to '/dev/vgdata/rlvtestdtat01';
set newname for datafile 112 to '/dev/vgindex/rlvtestdtai01';
set newname for datafile 113 to '/dev/vgdata/rlvtestctlt01';
set newname for datafile 114 to '/dev/vgindex/rlvtestctli01';
set newname for datafile 115 to '/dev/vgdata/rlvsvm810t02';
set newname for datafile 116 to '/dev/vgdata/rlvsy810t02';
set newname for datafile 117 to '/dev/vgindex/rlvsy810i02';
set newname for datafile 118 to '/dev/vgdata/rlvsy810t03';
set newname for datafile 119 to '/dev/vgdata/rlvsvm810t03';
set newname for datafile 120 to '/dev/vgindex/rlvsvm810i01';
set newname for datafile 121 to '/dev/vgdata/rsvm810t04';
set newname for datafile 122 to '/dev/vgindex/rlvsvm801i02';
set newname for datafile 123 to '/dev/vgdata/rlvsvm810t05';
set newname for datafile 124 to '/dev/vgindex/rlvsvm810i03';
set newname for datafile 125 to '/dev/vgindex/rlvsvm801i04';
set newname for datafile 126 to '/dev/vgindex/rlvsvm810i05';
set newname for datafile 127 to '/dev/vgindex/rlvsvm810i06';
set newname for datafile 128 to '/dev/vgindex/rlvsy810i03';
set newname for datafile 129 to '/dev/vgdata/rlvproddtat11';
set newname for datafile 130 to '/dev/vgdata/rlvproddtat12';
set newname for datafile 131 to '/dev/vgindex/rlvproddtai11';
set newname for datafile 132 to '/dev/vgindex/rlvsvm810i07';
set newname for datafile 133 to '/dev/vgdata/rlvundo03';
set newname for datafile 134 to '/dev/vgdata/rlvundo04';
set newname for datafile 135 to '/dev/vgindex/rlvsy810i04';
set newname for datafile 136 to '/dev/vgdata/rlvproddtat13';
set newname for datafile 137 to '/dev/vgdata/rlvproddtat14';
set newname for datafile 138 to '/dev/vgindex/rlvsvm810i08';
set newname for datafile 139 to '/dev/vgindex/rlvsvm810i09';
set newname for datafile 140 to '/dev/vgdata/rlvproddtat15';
set newname for datafile 141 to '/dev/vgindex/rlvsvm810i10';
set newname for datafile 142 to '/dev/vgindex/rlvsvm810i11';
set newname for datafile 143 to '/dev/vgdata/rlvsvm810t06';
set newname for datafile 144 to '/dev/vgindex/rlvcrpdtai11';
set newname for datafile 145 to '/dev/vgdata/rlvdd810t02';
set newname for datafile 146 to '/dev/vgindex/rlvproddtai12';
set newname for datafile 147 to '/dev/vgdata/rlvproddtat16';
set newname for datafile 148 to '/dev/vgdata/rlvsvm810aslt02';
set newname for datafile 149 to '/dev/vgdata/rlvsvm810t10';
set newname for datafile 150 to '/dev/vgdata/rlvcrpdtat11';
set newname for datafile 151 to '/dev/vgdata/rlvcrpdtat12';
set newname for datafile 152 to '/dev/vgdata/rlvcrpdtat13';
set newname for datafile 153 to '/dev/vgdata/rlvcrpdtat14';
set newname for datafile 154 to '/dev/vgdata/rlvproddtat17';
set newname for datafile 155 to '/dev/vgindex/rlvproddtai13';
set newname for datafile 156 to '/dev/vgdata/rlvproddtat18';
set newname for datafile 157 to '/dev/vgdata/rlvol810t02';
set newname for datafile 158 to '/dev/vgdata/rlvpy810t09';
set newname for datafile 159 to '/dev/vgindex/rlvsy81i05';
set newname for datafile 160 to '/dev/vgindex/rlvsy81i06';
set newname for datafile 161 to '/dev/vgindex/rlvsy81i07';
set newname for datafile 162 to '/dev/vgindex/rlvsy81i08';
set newname for datafile 163 to '/dev/vgdata/rlvsvm810t11';
set newname for datafile 164 to '/dev/vgdata/rlvjde_e810t02';
set newname for datafile 165 to '/dev/vgdata/rlvpd810t08';
set newname for datafile 166 to '/dev/vgdata/rlvps810ctlt03';
set newname for datafile 168 to '/dev/vgdata/rlvsvm810t07';
set newname for datafile 169 to '/dev/vgdata/rlvsvm810t08';
set newname for datafile 170 to '/dev/vgdata/rlvsvm810t09';
set newname for datafile 171 to '/dev/vgindex/rlvproddtai14';
set newname for datafile 172 to '/dev/vgindex/rlvproddtai15';
set newname for datafile 173 to '/dev/vgindex/rlvproddtai16';
set newname for datafile 174 to '/dev/vgindex/rlvproddtai17';
set newname for datafile 175 to '/dev/vgdata/rlvproddtat19';
set newname for datafile 176 to '/dev/vgdata/rlvproddtat20';
set newname for datafile 177 to '/dev/vgdata/rlvproddtat21';
set newname for datafile 178 to '/dev/vgdata/rlvproddtat22';
set newname for datafile 179 to '/dev/vgdata/rlvproddtat23';
set newname for datafile 180 to '/dev/vgdata/rlvproddtat24';
set newname for datafile 181 to '/dev/vgindex/rlvcrpdtai12';
set newname for datafile 182 to '/dev/vgindex/rlvcrpdtai13';
set newname for datafile 183 to '/dev/vgindex/rlvcrpdtai14';
set newname for datafile 184 to '/dev/vgindex/rlvcrpdtai15';
set newname for datafile 185 to '/dev/vgdata/rlvcrpdtat15';
set newname for datafile 186 to '/dev/vgdata/rlvcrpdtat16';
set newname for datafile 187 to '/dev/vgdata/rlvcrpdtat17';
restore datafile 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20;
restore datafile 21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40;
restore datafile 41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60;
restore datafile 61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80;
restore datafile 81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100;
restore datafile 101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120;
restore datafile 121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140;
restore datafile 141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160;
restore datafile 161,162,163,164,165,166,168,169,170,171,172,173,174,175,176,177,178,179,180;
restore datafile 181,182,183,184,185,186,187;
switch datafile all;
}
9.恢復歸檔日誌
列出最後幾個歸檔日誌
RMAN>list backup of archivelog all;
記下序列號XXXXX
恢復歸檔日誌
RMAN>
ru
allocate channel 'dev_0' type'sbt_tape'
parms 'ENV=(OB2BARTYPE=Oracle8,OB2BARHOSTNAME=shzmfgdb,OB2BARLIST="DBWeekly FUll",OB2APPNAME=DBNEW)';
restore archivelog from sequence 46095until sequence 46097;
}
10.恢復資料庫
SQL> recoverdatabase using backup controlfile until cancel;
SQL> alter database rename file '/dev/vglog/rlvlog01' to'/js02/vglog/rlvlog01';
SQL> alter database rename file '/dev/vglog/rlvlog02' to'/js02/vglog/rlvlog02';
SQL> alter database rename file '/dev/vglog/rlvlog03' to'/js02/vglog/rlvlog03';
SQL> alter database rename file ‘/dev/vglog/rlvlog01’ to ‘/js02/vglog/rlvlog01’;
SQL> alter database rename file ‘/dev/vglog/rlvlog02’ to ‘/js02/vglog/rlvlog02’;
SQL> alter database rename file ‘/dev/vglog/rlvlog03’ to ‘/js02/vglog/rlvlog03’;
SQL> alter system set "_allow_resetlogs_corruption"=TRUEscope=both;
SQL>shutdown immediate;
SQL>startup mount;
SQL> alter database open resetlogs;
11.開啟資料庫
SQL>Shutdown immediate;
SQL>Startup