1 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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
| (1)修改pfile [oracle@server01 ~]$ cd $ORACLE_HOME/dbs [oracle@server01 dbs]$ ll total 8 -rw-r-----. 1 oracle oinstall 35 Dec 30 14:09 pfile.ora -rw-r--r--. 1 oracle oinstall 2851 May 15 2009 init.ora
[oracle@server01 dbs]$ cp pfile.ora initmydb.ora
源库pfile.ora内容: [oracle@server01 dbs]$ more pfile.ora
mydb1.__db_cache_size=339738624 mydb2.__db_cache_size=339738624 mydb1.__java_pool_size=4194304 mydb2.__java_pool_size=4194304 mydb1.__large_pool_size=8388608 mydb2.__large_pool_size=8388608 mydb1.__pga_aggregate_target=192937984 mydb2.__pga_aggregate_target=192937984 mydb1.__sga_target=570425344 mydb2.__sga_target=570425344 mydb1.__shared_io_pool_size=0 mydb2.__shared_io_pool_size=0 mydb1.__shared_pool_size=209715200 mydb2.__shared_pool_size=209715200 mydb1.__streams_pool_size=0 mydb2.__streams_pool_size=0 *.audit_file_dest='/opt/app/oracle/admin/mydb/adump' *.audit_trail='db' *.cluster_database=true *.compatible='11.2.0.4.0' *.control_files='+DATA/mydb/controlfile/current.256.1084542565','+FRA/mydb/controlfile /current.256.1084542567' *.db_block_size=8192 *.db_create_file_dest='+DATA' *.db_domain='' *.db_name='mydb' *.db_recovery_file_dest='+FRA' *.db_recovery_file_dest_size=6005194752 *.diagnostic_dest='/opt/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=mydbXDB)' mydb1.instance_number=1 mydb2.instance_number=2 *.open_cursors=300 *.pga_aggregate_target=189792256 *.processes=150 *.remote_listener='rac-scan:1521' *.remote_login_passwordfile='exclusive' *.sga_target=570425344 mydb2.thread=2 mydb1.thread=1 mydb2.undo_tablespace='UNDOTBS2' mydb1.undo_tablespace='UNDOTBS1'
目标库修改后参数内容: [oracle@server01 dbs]$ vi initoradb.ora
mydb.__db_cache_size=339738624 mydb.__java_pool_size=4194304 mydb.__large_pool_size=8388608 mydb.__pga_aggregate_target=192937984 mydb.__sga_target=570425344 mydb.__shared_io_pool_size=0 mydb.__shared_pool_size=209715200 mydb.__streams_pool_size=0 *.audit_file_dest='/opt/app/oracle/admin/mydb/adump' *.audit_trail='db' *.cluster_database=false *.compatible='11.2.0.4.0' *.control_files='/opt/app/oracle/oradata/mydb/control01.ctl','/opt/app/oracle/oradata/mydb/control02.ctl' *.db_block_size=8192 *.db_create_file_dest='/opt/app/oracle/oradata/mydb' *.db_domain='' *.db_name='mydb' *.db_recovery_file_dest='/opt/app/oracle/oradata/flash_recovery_area' *.db_recovery_file_dest_size=4005194752 *.diagnostic_dest='/opt/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=mydbXDB)' *.open_cursors=300 *.pga_aggregate_target=189792256 *.processes=150 *.remote_login_passwordfile='exclusive' *.sga_target=570425344 *.undo_tablespace='UNDOTBS1' *.log_archive_format='%t_%s_%r.dbf'
*.log_file_name_convert=('+DATA/mydb/onlinelog','/opt/app/oracle/oradata/mydb','+FRA/mydb/onlinelog','/opt/app/oracle/oradata/mydb') *.db_file_name_convert=('+DATA/mydb/datafile','/opt/app/oracle/oradata/mydb','+DATA/mydb/tempfile','/opt/app/oracle/oradata/mydb')
(2)创建密码文件 orapwd file=orapworadb password=oracle entries=5
(3)创建所需要目录 [oracle@server01 dbs]$ mkdir -p /opt/app/oracle/admin/mydb/adump [oracle@server01 dbs]$ mkdir -p /opt/app/oracle/oradata/mydb [oracle@server01 dbs]$ mkdir -p /opt/app/oracle/oradata/flash_recovery_area
(4)启动数据库至nomount [oracle@server01 ~]$ ll /tmp/rman total 1133260 -rw-r-----. 1 oracle oinstall 1130889216 Dec 30 13:59 full_MYDB_1_20211227_010hq4u6_1_1 -rw-r-----. 1 oracle oinstall 4644864 Dec 30 13:59 full_MYDB_2_20211227_020hq4u7_1_1 -rw-r-----. 1 oracle oinstall 18546688 Dec 30 13:59 full_MYDB_3_20211227_030hq4v2_1_1 -rw-r-----. 1 oracle oinstall 98304 Dec 30 13:59 full_MYDB_4_20211227_040hq4vd_1_1 -rw-r-----. 1 oracle oinstall 6271488 Dec 30 13:59 log_MYDB_6_20211227_060hq518_1_1 -rw-r-----. 1 oracle oinstall 2560 Dec 30 13:59 log_MYDB_7_20211227_070hq51a_1_1
[oracle@server01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Dec 30 19:43:44 2021
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount ORACLE instance started.
Total System Global Area 567869440 bytes Fixed Size 2255272 bytes Variable Size 222299736 bytes Database Buffers 339738624 bytes Redo Buffers 3575808 bytes SQL>
(5)恢复控制文件 [oracle@server01 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Dec 30 19:52:12 2021
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORADB (not mounted)
RMAN> restore controlfile from '/tmp/rman/full_MYDB_3_20211227_030hq4v2_1_1';
Starting restore at 30-DEC-21 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=1 device type=DISK
channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 output file name=/opt/app/oracle/oradata/oradb/control01.ctl output file name=/opt/app/oracle/oradata/oradb/control02.ctl Finished restore at 30-DEC-21
(6)启动数据库至mount [oracle@server01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Dec 30 19:54:07 2021
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> alter database mount;
Database altered.
(7)恢复数据库 RMAN> report schema;
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA Report of database schema for database with db_unique_name MYDB
List of Permanent Datafiles =========================== File Size(MB) Tablespace RB segs Datafile Name ---- -------- -------------------- ------- ------------------------ 1 0 SYSTEM *** +DATA/mydb/datafile/system.259.1084542583 2 0 SYSAUX *** +DATA/mydb/datafile/sysaux.260.1084542629 3 0 UNDOTBS1 *** +DATA/mydb/datafile/undotbs1.261.1084542659 4 0 UNDOTBS2 *** +DATA/mydb/datafile/undotbs2.263.1084542685 5 0 USERS *** +DATA/mydb/datafile/users.264.1084542699 6 0 TEST *** +DATA/mydb/datafile/test.268.1092418937
List of Temporary Files ======================= File Size(MB) Tablespace Maxsize(MB) Tempfile Name ---- -------- -------------------- ----------- -------------------- 1 20 TEMP 32767 +DATA/mydb/tempfile/temp.262.1084542667
SQL> set linesize 500 SQL> set pagesize 500 SQL> col file_name for a60 SQL> select 'set newname for datafile '||file_id||' to ''/opt/app/oracle/oradata/mydb/'||substr(file_name, instr(file_name, '/', -1) + 1) || ''';' from dba_data_files;
set newname for datafile 1 to '/opt/app/oracle/oradata/mydb/system.259.1084542583'; set newname for datafile 2 to '/opt/app/oracle/oradata/mydb/sysaux.260.1084542629'; set newname for datafile 3 to '/opt/app/oracle/oradata/mydb/undotbs1.261.1084542659'; set newname for datafile 4 to '/opt/app/oracle/oradata/mydb/undotbs2.263.1084542685'; set newname for datafile 5 to '/opt/app/oracle/oradata/mydb/users.264.1084542699'; set newname for datafile 6 to '/opt/app/oracle/oradata/mydb/test.268.1092418937';
run{ allocate channel t1 device type disk; allocate channel t2 device type disk; set newname for datafile 1 to '/opt/app/oracle/oradata/mydb/system.259.1084542583'; set newname for datafile 2 to '/opt/app/oracle/oradata/mydb/sysaux.260.1084542629'; set newname for datafile 3 to '/opt/app/oracle/oradata/mydb/undotbs1.261.1084542659'; set newname for datafile 4 to '/opt/app/oracle/oradata/mydb/undotbs2.263.1084542685'; set newname for datafile 5 to '/opt/app/oracle/oradata/mydb/users.264.1084542699'; set newname for datafile 6 to '/opt/app/oracle/oradata/mydb/test.268.1092418937'; restore database; switch datafile all; recover database; release channel t1; release channel t2; } [oracle@server01 dbs]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Dec 31 18:45:44 2021
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: MYDB (DBID=2999538401, not open)
RMAN> run{ allocate channel t1 device type disk; allocate channel t2 device type disk; set newname for datafile 1 to '/opt/app/oracle/oradata/mydb/system.259.1084542583'; set newname for datafile 2 to '/opt/app/oracle/oradata/mydb/sysaux.260.1084542629'; set newname for datafile 3 to '/opt/app/oracle/oradata/mydb/undotbs1.261.1084542659'; set newname for datafile 4 to '/opt/app/oracle/oradata/mydb/undotbs2.263.1084542685'; set newname for datafile 5 to '/opt/app/oracle/oradata/mydb/users.264.1084542699'; set newname for datafile 6 to '/opt/app/oracle/oradata/mydb/test.268.1092418937'; restore database; switch datafile all; recover database; release channel t1; release channel t2; }
allocated channel: t1 channel t1: SID=17 device type=DISK
allocated channel: t2 channel t2: SID=1 device type=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
Starting restore at 31-DEC-21
channel t1: starting datafile backup set restore channel t1: specifying datafile(s) to restore from backup set channel t1: restoring datafile 00004 to /opt/app/oracle/oradata/mydb/undotbs2.263.1084542685 channel t1: restoring datafile 00005 to /opt/app/oracle/oradata/mydb/users.264.1084542699 channel t1: restoring datafile 00006 to /opt/app/oracle/oradata/mydb/test.268.1092418937 channel t1: reading from backup piece /tmp/rman/full_MYDB_2_20211227_020hq4u7_1_1 channel t2: starting datafile backup set restore channel t2: specifying datafile(s) to restore from backup set channel t2: restoring datafile 00001 to /opt/app/oracle/oradata/mydb/system.259.1084542583 channel t2: restoring datafile 00002 to /opt/app/oracle/oradata/mydb/sysaux.260.1084542629 channel t2: restoring datafile 00003 to /opt/app/oracle/oradata/mydb/undotbs1.261.1084542659 channel t2: reading from backup piece /tmp/rman/full_MYDB_1_20211227_010hq4u6_1_1 channel t1: piece handle=/tmp/rman/full_MYDB_2_20211227_020hq4u7_1_1 tag=TAG20211227T191726 channel t1: restored backup piece 1 channel t1: restore complete, elapsed time: 00:00:56 channel t2: piece handle=/tmp/rman/full_MYDB_1_20211227_010hq4u6_1_1 tag=TAG20211227T191726 channel t2: restored backup piece 1 channel t2: restore complete, elapsed time: 00:01:06 Finished restore at 31-DEC-21
datafile 1 switched to datafile copy input datafile copy RECID=7 STAMP=1092768444 file name=/opt/app/oracle/oradata/mydb/system.259.1084542583 datafile 2 switched to datafile copy input datafile copy RECID=8 STAMP=1092768444 file name=/opt/app/oracle/oradata/mydb/sysaux.260.1084542629 datafile 3 switched to datafile copy input datafile copy RECID=9 STAMP=1092768444 file name=/opt/app/oracle/oradata/mydb/undotbs1.261.1084542659 datafile 4 switched to datafile copy input datafile copy RECID=10 STAMP=1092768444 file name=/opt/app/oracle/oradata/mydb/undotbs2.263.1084542685 datafile 5 switched to datafile copy input datafile copy RECID=11 STAMP=1092768444 file name=/opt/app/oracle/oradata/mydb/users.264.1084542699 datafile 6 switched to datafile copy input datafile copy RECID=12 STAMP=1092768444 file name=/opt/app/oracle/oradata/mydb/test.268.1092418937
Starting recover at 31-DEC-21
starting media recovery
channel t1: starting archived log restore to default destination channel t1: restoring archived log archived log thread=2 sequence=18 channel t1: restoring archived log archived log thread=1 sequence=86 channel t1: restoring archived log archived log thread=1 sequence=87 channel t1: reading from backup piece /tmp/rman/log_MYDB_6_20211227_060hq518_1_1 channel t2: starting archived log restore to default destination channel t2: restoring archived log archived log thread=2 sequence=19 channel t2: reading from backup piece /tmp/rman/log_MYDB_7_20211227_070hq51a_1_1 channel t1: piece handle=/tmp/rman/log_MYDB_6_20211227_060hq518_1_1 tag=TAG20211227T191903 channel t1: restored backup piece 1 channel t1: restore complete, elapsed time: 00:00:01 archived log file name=/tmp/1_86_1084542561.dbf thread=1 sequence=86 archived log file name=/tmp/2_18_1084542561.dbf thread=2 sequence=18 archived log file name=/tmp/1_87_1084542561.dbf thread=1 sequence=87 channel t2: piece handle=/tmp/rman/log_MYDB_7_20211227_070hq51a_1_1 tag=TAG20211227T191903 channel t2: restored backup piece 1 channel t2: restore complete, elapsed time: 00:00:02 archived log file name=/tmp/2_19_1084542561.dbf thread=2 sequence=19 unable to find archived log archived log thread=1 sequence=88 released channel: t1 released channel: t2 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 12/31/2021 18:47:28 RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 88 and starting SCN of 1371411
(8)打开数据库 [oracle@server01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Fri Dec 31 18:54:01 2021
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> alter database open resetlogs;
Database altered.
|