- 最后登录
- 2023-8-16
- 在线时间
- 1686 小时
- 威望
- 2135
- 金钱
- 50532
- 注册时间
- 2011-10-12
- 阅读权限
- 200
- 帖子
- 5207
- 精华
- 39
- 积分
- 2135
- UID
- 2
|
6#
发表于 2012-5-22 10:38:53
在没有控制文件 无法mount db的情况下 可以利用内置的dbms_backup_restore 包从 rman备份中抽取文件
下面是例子:
ODM TEST:- RMAN> list backup of database;
- using target database control file instead of recovery catalog
- List of Backup Sets
- ===================
- BS Key Type LV Size Device Type Elapsed Time Completion Time
- ------- ---- -- ---------- ----------- ------------ ---------------
- 15 Full 2.46G DISK 00:00:19 21-MAY-12
- BP Key: 17 Status: AVAILABLE Compressed: NO Tag: TAG20120521T111811
- Piece Name: /s01/0jnbhhnj_1_1.bak
- List of Datafiles in backup set 15
- File LV Type Ckp SCN Ckp Time Name
- ---- -- ---- ---------- --------- ----
- 1 Full 2706191 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_system_7ch7d4mn_.dbf
- 2 Full 2706191 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_undotbs1_7ch7d4nt_.dbf
- 3 Full 2706191 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_sysaux_7ch7d4n2_.dbf
- 4 Full 2706191 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_users_7ch7d4nx_.dbf
- 5 Full 2706191 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_example_7ch7f9vx_.dbf
- 6 Full 2706191 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_bct_test_7tgwoyyd_.dbf
- 7 Full 2706191 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_bigs_7tnktkkv_.dbf
- 8 Full 2706191 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_testfree_7tt5m8om_.dbf
- BS Key Type LV Size Device Type Elapsed Time Completion Time
- ------- ---- -- ---------- ----------- ------------ ---------------
- 17 Full 2.46G DISK 00:00:17 21-MAY-12
- BP Key: 19 Status: AVAILABLE Compressed: NO Tag: TAG20120521T111914
- Piece Name: /s01/0lnbhhpi_1_1.bak
- List of Datafiles in backup set 17
- File LV Type Ckp SCN Ckp Time Name
- ---- -- ---- ---------- --------- ----
- 1 Full 2706226 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_system_7ch7d4mn_.dbf
- 2 Full 2706226 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_undotbs1_7ch7d4nt_.dbf
- 3 Full 2706226 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_sysaux_7ch7d4n2_.dbf
- 4 Full 2706226 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_users_7ch7d4nx_.dbf
- 5 Full 2706226 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_example_7ch7f9vx_.dbf
- 6 Full 2706226 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_bct_test_7tgwoyyd_.dbf
- 7 Full 2706226 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_bigs_7tnktkkv_.dbf
- 8 Full 2706226 21-MAY-12 /s01/oradata/G10R25/datafile/o1_mf_testfree_7tt5m8om_.dbf
- SQL> alter database backup controlfile to trace;
- Database altered.
- SQL> oradebug setmypid;
- Statement processed.
- SQL> oradebug tracefile_name
- /s01/admin/G10R25/udump/g10r25_ora_5483.trc
- SQL>
- SQL>
- SQL> shutdown immediate;
- DECLARE
- v_dev varchar2(50); -- device type allocated for restore
- v_done boolean := false; -- has the datafile been fully extracted yet
- type t_fileTable is table of varchar2(255) index by binary_integer;
- v_fileTable t_fileTable; -- Stores the backuppiece names
- v_maxPieces number := 1; -- Number of backuppieces in backupset
- BEGIN
- -- Initialise the filetable and number of backup pieces in the backupset
- -- This section of code MUST be edited to reflect the customer's available
- -- backupset before the procedure is compiled and run. In this example, the
- -- backupset consists of 4 pieces:
- v_fileTable(1) := '/s01/0jnbhhnj_1_1.bak';
- v_maxPieces := 1;
- -- Allocate a device. In this example, I have specified 'sbt_tape' as I am
- -- reading backuppieces from the media manager. If the backuppiece is on disk,
- -- specify type=>null
- v_dev := sys.dbms_backup_restore.deviceAllocate(type => NULL,
- ident => 't1');
- -- Begin the restore conversation
- sys.dbms_backup_restore.restoreSetDatafile;
- -- Specify where the datafile is to be recreated
- sys.dbms_backup_restore.restoreDataFileTo(dfnumber => 1,
- toname => '/s01/oradata/G10R25/datafile/o1_mf_system_7ch7d4mn_.dbf');
- -- Restore the datafile
- FOR i IN 1 .. v_maxPieces LOOP
- sys.dbms_backup_restore.restoreBackupPiece(done => v_done,
- handle => v_fileTable(i),
- params => null);
- IF v_done THEN
- GOTO all_done;
- END IF;
- END LOOP;
- <<all_done>>
- -- Deallocate the device
- sys.dbms_backup_restore.deviceDeallocate;
- END;
- /
- [oracle@vrh8 datafile]$ cd /s01/oradata/G10R25/datafile/
- [oracle@vrh8 datafile]$ ls -lh *
- -rw-r----- 1 oracle oinstall 801M May 21 22:22 o1_mf_unknown_7voy2grh_.dbf
- SQL> CREATE CONTROLFILE REUSE DATABASE "G10R25" NORESETLOGS ARCHIVELOG
- 2 MAXLOGFILES 16
- 3 MAXLOGMEMBERS 3
- 4 MAXDATAFILES 100
- 5 MAXINSTANCES 8
- 6 MAXLOGHISTORY 292
- 7 LOGFILE
- 8 GROUP 1 (
- 9 '/s01/oradata/G10R25/onlinelog/o1_mf_1_7ch7f3w8_.log',
- 10 '/s01/flash_recovery_area/G10R25/onlinelog/o1_mf_1_7ch7f4o2_.log'
- 11 ) SIZE 50M,
- 12 GROUP 2 (
- 13 '/s01/oradata/G10R25/onlinelog/o1_mf_2_7ch7f599_.log',
- 14 '/s01/flash_recovery_area/G10R25/onlinelog/o1_mf_2_7ch7f616_.log'
- 15 ) SIZE 50M,
- 16 GROUP 3 (
- 17 '/s01/oradata/G10R25/onlinelog/o1_mf_3_7ch7f6kb_.log',
- 18 '/s01/flash_recovery_area/G10R25/onlinelog/o1_mf_3_7ch7f7dj_.log'
- 19 ) SIZE 50M
- 20 -- STANDBY LOGFILE
- 21 DATAFILE
- 22 '/s01/oradata/G10R25/datafile/o1_mf_unknown_7voy2grh_.dbf'
- 23 CHARACTER SET AL32UTF8;
- Control file created.
复制代码 |
|