使用儲存指令碼還原恢復資料庫
如果要使用儲存指令碼,首先需要啟用恢復目錄。
1. 建立儲存指令碼
以下是一些與儲存指令碼有關的命令
接下來,先執行備份
然後故意破壞引數檔案
在RMAN中啟動到nomount
然後執行restore指令碼
完成後,檢視日誌序列號和執行緒號,這個將在恢復時用到。
執行恢復指令碼
完成!
1. 建立儲存指令碼
點選(此處)摺疊或開啟
-
#RMAN連線到恢復目錄
-
rman target / catalog rcowner/oracle@rcata
-
- #建立備份用指令碼
- create script bak_db_arch
-
comment 'backup database plus archivelog, then clean archivelog.'
{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
backup database plus archivelog;
delete noprompt archivelog all;
release channel c1;
release channel c2;
}
- #建立還原指令碼
- create script restore_db
-
comment 'restore database, then db can be recovered.'
{
restore spfile;
shutdown immediate;
startup nomount;
restore controlfile;
alter database mount;
allocate channel c1 device type disk;
allocate channel c2 device type disk;
restore database;
release channel c1;
release channel c2;
}
- #建立恢復指令碼,需要用到替換變數
-
create script recover_db
{
set until sequence &1 thread &2;
recover database;
alter database open resetlogs;
}
- #注意:在有替換變數的這一行,RMAN會立即要求輸入初始值,因此不能將整段語句直接貼上上去!
點選(此處)摺疊或開啟
-
# 檢視恢復目錄裡有哪些指令碼,同時會顯示comment
-
list script names;
-
-
# 檢視指令碼內容
-
print script <指令碼名>;
-
-
# 編輯指令碼
-
replace script ...(...與建立命令相同)
-
-
# 刪除指令碼
- delete script <指令碼名>;
點選(此處)摺疊或開啟
- run { execute script bak_db_arch; }
點選(此處)摺疊或開啟
- mv spfileprod.ora spfileprod.ora.old
點選(此處)摺疊或開啟
- RMAN> startup nomount
點選(此處)摺疊或開啟
- RMAN> run { execute script restore_db; }
點選(此處)摺疊或開啟
-
RMAN> list backup by file;
-
-
List of Archived Log Backups
-
============================
-
-
Thrd Seq Low SCN Low Time BS Key S #Pieces #Copies Compressed Tag
-
---- ------- ---------- ------------------- ------- - ------- ------- ---------- ---
-
1 2 4471363 2016-04-02 09:00:53 1104 A 1 1 NO TAG20160407T084606
-
1 3 4532043 2016-04-04 01:00:10 1104 A 1 1 NO TAG20160407T084606
-
1 4 4607063 2016-04-06 00:30:18 1105 A 1 1 NO TAG20160407T084606
-
1 1 4625382 2016-04-06 12:55:14 1106 A 1 1 NO TAG20160407T084606
-
1 1 4626459 2016-04-06 13:20:54 1107 A 1 1 NO TAG20160407T084606
- 1 2 4656086 2016-04-07 08:46:00 1142 A 1 1 NO TAG20160407T085111
點選(此處)摺疊或開啟
-
RMAN> print script recover_db;
-
-
printing stored script: recover_db
-
{
-
set until sequence &1 thread &2;
-
recover database;
-
alter database open resetlogs;
-
}
-
-
RMAN> run { execute script recover_db; }
-
-
executing script: recover_db
-
-
Enter value for 1: 3
-
-
Enter value for 2: 1
-
-
executing command: SET until clause
-
-
Starting recover at 2016-04-07 09:17:40
-
allocated channel: ORA_DISK_1
-
channel ORA_DISK_1: SID=63 device type=DISK
-
-
starting media recovery
-
-
archived log for thread 1 with sequence 2 is already on disk as file /u01/app/oracle/oradata/prod/disk1/redo02a.log
-
archived log file name=/u01/app/oracle/oradata/prod/disk1/redo02a.log thread=1 sequence=2
-
media recovery complete, elapsed time: 00:00:00
-
Finished recover at 2016-04-07 09:17:46
-
-
database opened
-
new incarnation of database registered in recovery catalog
-
starting full resync of recovery catalog
- full resync complete
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22621861/viewspace-2076680/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- sqlserver資料庫還原儲存過程指令碼SQLServer資料庫儲存過程指令碼
- 【儲存資料恢復】NetApp儲存誤刪除的資料恢復案例資料恢復APP
- 【儲存資料恢復】NetApp儲存誤刪資料夾的資料恢復案例資料恢復APP
- 誤刪除儲存SqlServer資料庫資料恢復SQLServer資料庫資料恢復
- 【VSAN資料恢復】VSAN儲存資料恢復案例資料恢復
- 【儲存資料恢復】EqualLogic PS系列儲存磁碟故障的資料恢復案例資料恢復
- 【伺服器儲存資料恢復】HP-Lefthand儲存資料恢復案例伺服器資料恢復
- SQLSERVER完整資料庫還原(完整恢復模式)SQLServer資料庫模式
- 【儲存資料恢復】某品牌EqualLogic系列儲存介紹和資料恢復方法資料恢復
- 【儲存資料恢復】HP EVA儲存誤刪除VDISK的資料恢復案例資料恢復
- DM7使用DMRMAN執行資料庫還原和恢復資料庫
- 【儲存資料恢復】H3C FlexStorage儲存卷被刪如何恢復資料?資料恢復Flex
- EMC 儲存資料恢復案例詳解【資料恢復方案】資料恢復
- Vsan資料恢復—Vsan分散式儲存資料恢復案例資料恢復分散式
- 儲存崩潰資料恢復過程;資料恢復案例資料恢復
- 【儲存資料恢復】esx vmfs的互斥導致儲存資料丟失的資料恢復案例資料恢復
- 【儲存資料恢復】IBM儲存檔案NTFS系統損壞的資料恢復案例資料恢復IBM
- 伺服器儲存金蝶資料庫丟失恢復伺服器資料庫
- VSAN儲存結構解析+儲存資料恢復案例資料恢復
- 【伺服器資料恢復】HP EVA儲存資料恢復案例伺服器資料恢復
- WD MYbook儲存硬碟資料恢復硬碟資料恢復
- 【儲存資料恢復】EMC某型號儲存raid5崩潰的資料恢復案例資料恢復AI
- 【儲存資料恢復】儲存上的raid5陣列崩潰的資料恢復案例資料恢復AI陣列
- 【伺服器資料恢復】xen server儲存庫(sr)常見故障的資料恢復方案伺服器資料恢復Server
- 【伺服器資料恢復】infortrend ESDS系列儲存資料恢復案例伺服器資料恢復
- 【伺服器資料恢復】StorNext儲存系統資料恢復案例伺服器資料恢復
- 【raid資料恢復】光纖儲存raid陣列資料恢復案例AI資料恢復陣列
- HP EVA系列儲存資料恢復原理資料恢復
- 【北亞資料恢復】vmfs還原快照操作導致SqlServer資料庫資料丟失的資料恢復資料恢復SQLServer資料庫
- 分散式資料恢復-hbase+hive分散式儲存資料恢復方案分散式資料恢復Hive
- 【北亞企安資料恢復】Ceph儲存原理&Ceph資料恢復流程資料恢復
- 【儲存資料恢復】WAFL檔案系統下raid資料恢復案例資料恢復AI
- 【儲存資料恢復案例】Netapp誤操作刪除lun的資料恢復資料恢復APP
- 【伺服器資料恢復】某品牌MSA SAN儲存資料恢復案例伺服器資料恢復
- 【伺服器raid資料恢復】光纖儲存raid資料恢復案例伺服器AI資料恢復
- 【伺服器儲存資料恢復】華為OceanStor某型號儲存raid5資料恢復案例伺服器資料恢復AI
- 儲存刪除資料後恢復方法-適用netAPP儲存APP
- 【分散式儲存資料恢復】hbase和hive資料庫底層檔案誤刪的資料恢復案例分散式資料恢復Hive資料庫
- 分散式文件儲存資料庫之MongoDB備份與恢復分散式資料庫MongoDB