DM7使用DMRMAN對資料庫執行指定對映檔案還原
DMRMAN對資料庫執行指定對映檔案還原
指定對映檔案還原,還原後的資料檔案預設地生成到還原目標庫的路徑下,如果使用者想生成資料檔案到特定的路徑,就需要指定對映檔案引數來實現。
對映檔案(mappedfile)用於指定存放還原目標路徑,即備份集裡面的資料檔案的路徑。可以手動修改自動生成的對映檔案。當引數BACKUPSET和MAPPED FILE指定的路徑不一致時,以MAPPED FILE中指定的路徑為主。對映檔案可用於庫級離線還原和表空間還原。
使用DUMP命令可以將指定備份集還原目標資訊生成到目標對映檔案中,該檔案可被重新編輯後,用於資料庫的還原過程。語法如下:
DUMP BACKUPSET '< 備份集目錄>' [DEVICE TYPE DISK|TAPE [PARMS '介質引數']] [DATABASE ''] MAPPED FILE '< 對映檔案>';
BACKUPSET:待生成對映檔案的備份集目錄。
DEVICE TYPE:指儲存備份集的介質型別,支援DISK和TAPE,預設為DISK。
PARMS:介質引數,供第三方儲存介質(TAPE型別)管理使用。
DATABASE:指定目標還原庫的dm.ini檔案路徑。
MAPPED FILE:生成對映檔案路徑。若指定DATABASE引數,則生成內容調整為與指定資料庫相適應的資料檔案目標還原路徑;否則,僅將備份集中備份時記錄的路徑輸出。
下面以離線備份還原為例說明使用對映檔案還原的具體步驟。
1) 啟動RMAN,離線備份資料庫。
RMAN> backup database '/dm_home/dmdba/dmdbms/data/jydm/dm.ini' backupset '/dm_home/dmdba/dmdbms/data/jydm/bak/db_bak_for_map_01'; backup database '/dm_home/dmdba/dmdbms/data/jydm/dm.ini' backupset '/dm_home/dmdba/dmdbms/data/jydm/bak/db_bak_for_map_01'; file dm.key not found, use default license! checking if the database under system path [/dm_home/dmdba/dmdbms/data/jydm] is running...[4]. checking if the database under system path [/dm_home/dmdba/dmdbms/data/jydm] is running...[3]. checking if the database under system path [/dm_home/dmdba/dmdbms/data/jydm] is running...[2]. checking if the database under system path [/dm_home/dmdba/dmdbms/data/jydm] is running...[1]. checking if the database under system path [/dm_home/dmdba/dmdbms/data/jydm] is running...[0]. checking if the database under system path [/dm_home/dmdba/dmdbms/data/jydm] is running, write dmrman info. EP[0] max_lsn: 20379861 BACKUP DATABASE [jydm], execute...... CMD CHECK LSN...... BACKUP DATABASE [jydm], collect dbf...... CMD CHECK ...... DBF BACKUP SUBS...... total 1 packages processed... total 7 packages processed... total 13 packages processed... total 14 packages processed... total 15 packages processed... total 16 packages processed... total 22 packages processed... total 23 packages processed... DBF BACKUP MAIN...... BACKUPSET [/dm_home/dmdba/dmdbms/data/jydm/bak/db_bak_for_map_01] END, CODE [0]...... META GENERATING...... total 27 packages processed... total 27 packages processed! CMD END.CODE:[0] backup successfully! time used: 16318.143(ms) [dmdba@shard1 bak]$ scp -r db_bak_for_map_01/ dmdba@10.138.130.187:/dm_home/dmdbms/backup/ dmdba@10.138.130.187's password: db_bak_for_map_01.bak 100% 210MB 104.9MB/s 00:02 db_bak_for_map_01.meta 100% 85KB 84.5KB/s 00:00 [dmdba@shard1 bak]$
2) 生成對映檔案map_file_01.txt至/dm_home/dmdbms/backup目錄。此處指定生成對映檔案中的資料檔案路徑與資料庫/dm_home/dmdbms/data/dameng_for_recover/中的資料檔案一致。若不指定,與備份集中的源資料庫的資料檔案路徑一致。
RMAN> dump backupset '/dm_home/dmdbms/backup/db_bak_for_map_01' database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini' mapped file '/dm_home/dmdbms/backup/map_file_01.txt'; dump backupset '/dm_home/dmdbms/backup/db_bak_for_map_01' database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini' mapped file '/dm_home/dmdbms/backup/map_file_01.txt'; dump mapped file successfully. time used: 11.093(ms)
生成的對映檔案內容如下:
[dmdba@dmks backup]$ cat map_file_01.txt /**************************************************************/ /*** Delete the unnecessary modified groups **/ /*** Modify the data_path or mirror_path only in one group **/ /**************************************************************/ /**=============================================================**/ /*[jydm_SYSTEM_FIL_0]*/ fil_id = 0 ts_id = 0 ts_name = SYSTEM data_path = /dm_home/dmdbms/data/dameng_for_recover/SYSTEM.DBF mirror_path = /**=============================================================**/ /*[jydm_ROLL_FIL_0]*/ fil_id = 0 ts_id = 1 ts_name = ROLL data_path = /dm_home/dmdbms/data/dameng_for_recover/ROLL.DBF mirror_path = /**=============================================================**/ /*[jydm_MAIN_FIL_0]*/ fil_id = 0 ts_id = 4 ts_name = MAIN data_path = /dm_home/dmdbms/data/dameng_for_recover/MAIN.DBF mirror_path = /**=============================================================**/ /*[jydm_BOOKSHOP_FIL_0]*/ fil_id = 0 ts_id = 5 ts_name = BOOKSHOP data_path = /dm_home/dmdbms/data/dameng_for_recover/BOOKSHOP.DBF mirror_path = /**=============================================================**/ /*[jydm_DMHR_FIL_0]*/ fil_id = 0 ts_id = 6 ts_name = DMHR data_path = /dm_home/dmdbms/data/dameng_for_recover/DMHR.DBF mirror_path = /**=============================================================**/ /*[jydm_USERS_FIL_0]*/ fil_id = 0 ts_id = 7 ts_name = USERS data_path = /dm_home/dmdbms/data/dameng_for_recover/users01.dbf mirror_path = /**=============================================================**/ /*[jydm_SYSAUX_FIL_0]*/ fil_id = 0 ts_id = 9 ts_name = SYSAUX data_path = /dm_home/dmdbms/data/dameng_for_recover/SYSAWR.DBF mirror_path = /**=============================================================**/ /*[jydm_FG_PERSON_FIL_0]*/ fil_id = 0 ts_id = 10 ts_name = FG_PERSON data_path = /dm_home/dmdbms/data/dameng_for_recover/FG_PERSON.DBF mirror_path = /***************************** END ****************************/
如果需要恢復資料檔案或映象檔案到指定路徑,可手動編輯對映檔案中表空間對應的data_path屬性。例如,要還原USERS表空間中的資料檔案users01.dbf到/home/dmdba/路徑下,修改組jydm_USERS_FIL_0的內容如下:
/*[jydm_USERS_FIL_0]*/ fil_id = 0 ts_id = 7 ts_name = USERS data_path = /home/dmdba/users01.dbf mirror_path =
3) 指定對映檔案還原。還原前可選擇對備份檔案進行校驗。
RMAN> restore database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini' from backupset '/dm_home/dmdbms/backup/db_bak_for_map_01' mapped file '/dm_home/dmdbms/backup/map_file_01.txt'; restore database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini' from backupset '/dm_home/dmdbms/backup/db_bak_for_map_01' mapped file '/dm_home/dmdbms/backup/map_file_01.txt'; checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[4]. checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[3]. checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[2]. checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[1]. checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[0]. checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running, write dmrman info. RESTORE DATABASE CHECK...... RESTORE DATABASE , dbf collect...... RESTORE DATABASE , dbf refresh ...... RESTORE BACKUPSET [/dm_home/dmdbms/backup/db_bak_for_map_01] START...... total 23 packages processed... RESTORE DATABASE , UPDATE ctl file...... RESTORE DATABASE , REBUILD key file...... RESTORE DATABASE , CHECK db info...... RESTORE DATABASE , UPDATE db info...... total 25 packages processed! CMD END.CODE:[0] restore successfully. time used: 49988.649(ms)
4)恢復資料庫
RMAN> recover database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini' from backupset '/dm_home/dmdbms/backup/db_bak_for_map_01'; recover database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini' from backupset '/dm_home/dmdbms/backup/db_bak_for_map_01'; checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[4]. checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[3]. checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[2]. checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[1]. checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[0]. checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running, write dmrman info. EP[0] max_lsn: 20379861 RESTORE RLOG CHECK...... CMD END.CODE:[603],DESC:[no log generates while the backupset [/dm_home/dmdbms/backup/db_bak_for_map_01] created] no log generates while the backupset [/dm_home/dmdbms/backup/db_bak_for_map_01] created recover successfully! time used: 7026.527(ms)
5)檢驗資料檔案還原的位置
[root@dmks init.d]# service DmServicedmrc start Starting DmServicedmrc: [ OK ] SQL> select * from v$datafile; LINEID GROUP_ID ID PATH CLIENT_PATH CREATE_TIME STATUS$ RW_STATUS LAST_CKPT_TIME MODIFY_TIME MODIFY_TRX TOTAL_SIZE FREE_SIZE FREE_PAGE_NO PAGES_READ PAGES_WRITE PAGE_SIZE READ_REQUEST WRITE_REQUEST AUTO_EXTEND MAX_SIZE NEXT_SIZE MIRROR_PATH ---------- ----------- ----------- ----------------------------------------------------- ----------------------- --------------------------- ----------- ----------- --------------------------- --------------------------- -------------------- -------------------- -------------------- -------------------- -------------------- -------------------- ----------- ------------ ------------- ----------- ----------- ----------- ----------- 1 0 0 /dm_home/dmdbms/data/dameng_for_recover/SYSTEM.DBF SYSTEM.DBF 2020-06-18 17:02:59 1 2 2020-06-18 17:13:08 2020-06-18 17:02:59 0 2944 2117 1840 368 3 8192 368 3 1 16777215 0 NULL 2 1 0 /dm_home/dmdbms/data/dameng_for_recover/ROLL.DBF ROLL.DBF 2020-06-18 17:02:59 1 2 2020-06-18 17:13:08 2020-06-18 17:02:59 0 25472 24138 24400 32 1289 8192 32 1289 1 16777215 0 NULL 3 3 0 /dm_home/dmdbms/data/dameng_for_recover/TEMP.DBF TEMP.DBF 2020-06-18 17:08:08 1 2 2020-06-18 17:13:08 2020-06-18 17:08:08 0 1280 1272 32 0 0 8192 0 0 1 16777215 0 NULL 4 4 0 /dm_home/dmdbms/data/dameng_for_recover/MAIN.DBF MAIN.DBF 2020-06-18 17:02:59 1 2 2020-06-18 17:13:08 2020-06-18 17:02:59 0 24064 17781 22944 1607 0 8192 1607 0 1 16777215 0 NULL 5 5 0 /dm_home/dmdbms/data/dameng_for_recover/BOOKSHOP.DBF BOOKSHOP.DBF 2020-06-18 17:02:59 1 2 2020-06-18 17:13:08 2020-06-18 17:02:59 0 19200 19079 864 43 0 8192 43 0 1 16777215 0 NULL 6 6 0 /dm_home/dmdbms/data/dameng_for_recover/DMHR.DBF DMHR.DBF 2020-06-18 17:02:59 1 2 2020-06-18 17:13:08 2020-06-18 17:02:59 0 16384 16325 304 35 0 8192 35 0 1 16777215 0 NULL 7 7 0 /home/dmdba/users01.dbf /home/dmdba/users01.dbf 2020-06-18 17:02:59 1 2 2020-06-18 17:13:08 2020-06-18 17:02:59 0 6400 6258 3392 57 0 8192 57 0 1 16777215 0 NULL 8 9 0 /dm_home/dmdbms/data/dameng_for_recover/SYSAWR.DBF SYSAWR.DBF 2020-06-18 17:02:59 1 2 2020-06-18 17:13:08 2020-06-18 17:02:59 0 21760 2834 20592 529 0 8192 529 0 1 10240 0 NULL 9 10 0 /dm_home/dmdbms/data/dameng_for_recover/FG_PERSON.DBF FG_PERSON.DBF 2020-06-18 17:02:59 1 2 2020-06-18 17:13:08 2020-06-18 17:02:59 0 16384 16375 32 1 0 8192 1 0 1 16777215 0 NULL 9 rows got used time: 8.354(ms). Execute id is 10.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-2740011/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- DM7使用dmrestore執行並行對映檔案還原REST並行
- DM7使用DMRMAN工具執行備份集對映檔案匯出
- DM7使用DMRMAN執行歸檔還原
- DM7使用DMRMAN執行資料庫還原和恢復資料庫
- DM7使用DMRMAN執行表空間還原
- DM7使用DMRMAN執行RAC資料庫恢復資料庫
- DM7使用離線工具DMRMAN執行資料庫備份資料庫
- DM7使用DMRMAN執行歸檔備份
- DM7使用DMRMAN執行歸檔修復
- DM7使用DMRMAN恢復資料庫到指定時間點/LSN資料庫
- DM7使用dmrestore執行指定時間點或LSN還原REST
- DM7使用dmrestore工具還原資料庫REST資料庫
- Sqlserver資料庫使用 .bak 檔案還原資料庫SQLServer資料庫
- DM7使用Disql執行表還原SQL
- DM7使用Disql執行表空間還原SQL
- 使用記憶體對映檔案(mmap)記憶體
- DM7使用DMRAMN對多次故障恢復後使用不同資料庫的歸檔進行恢復資料庫
- DM7使用Disql執行表還原的複雜用法SQL
- python對excel檔案中指定表格的指定列資料進行去重複操作。PythonExcel
- 如何透過.dbf檔案還原資料庫資料庫
- 載入Mapper對映檔案APP
- Mybatis對映檔案簡介MyBatis
- DM7使用聯機執行SQL語句進行備份還原SQL
- Python mmap的使用-檔案記憶體對映Python記憶體
- 2.5.10.3 指定資料庫時區檔案資料庫
- DM7使用DMRMAN工具執行加密備份與設定跟蹤日誌加密
- git針對指定資料夾建立版本庫Git
- SQL Server資料庫還原過程記錄,bak檔案+mdf檔案SQLServer資料庫
- 資料結構-對映資料結構
- nginx容器卷對映檔案不生效Nginx
- DM7使用dmrestore工具利用歸檔日誌還原REST
- 實際使用Elasticdump工具對Elasticsearch叢集進行資料備份和資料還原Elasticsearch
- DM7使用DMRAMN執行歸檔恢復
- 為什麼使用者執行緒必須對映到核心執行緒?執行緒
- mybatis 實體類排除資料庫欄位對映MyBatis資料庫
- MyBaits | 對映檔案之引數處理AI
- Hibernate配置檔案中對映元素詳解
- DM7使用dmrestore工具利用不同資料庫的歸檔恢復資料庫REST資料庫