這篇文章給大家分享的是有關(guān)如何使用RMAN對CDB執(zhí)行按時間點恢復(fù)的內(nèi)容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
成都創(chuàng)新互聯(lián)主營秀峰網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,成都app軟件開發(fā)公司,秀峰h5小程序開發(fā)搭建,秀峰網(wǎng)站營銷推廣歡迎秀峰等地區(qū)企業(yè)咨詢使用RMAN對CDB和PDB執(zhí)行按時間點恢復(fù)
RMAN能夠?qū)DB與PDB執(zhí)行按時間點恢復(fù)操作。但是PDB只能使用RMAN來執(zhí)行按時間點恢復(fù)。如是沒有使用恢復(fù)目錄數(shù)據(jù)庫,建議啟用自動控制文件備份。否則當(dāng)對PDB執(zhí)行按時間點恢復(fù)時,當(dāng)RMAN需要增加與刪除undo數(shù)據(jù)文件時不能有效的執(zhí)行。
PDB按時間點恢復(fù)與快速恢復(fù)區(qū)
當(dāng)對PDB執(zhí)行數(shù)據(jù)庫按時間點恢復(fù)時,對于這個PDB所有的數(shù)據(jù)文件都將被執(zhí)行恢復(fù)操作。然而,為了將PDB恢復(fù)到指定的時間點,RMAN在恢復(fù)目標(biāo)時間點也是需要有UNDO表空間存在的。因為undo表空間是被所有PDB所共享的,它不能被恢復(fù)。RMAN會將root中的undo,system與sysaux表空間還原到輔助實例中,然后使用undo信息來將pdb恢復(fù)到指定的時間點。如果配置了快速恢復(fù)區(qū),Oracle將會使用它作為輔助實例的存儲目錄。如果快速恢復(fù)區(qū)沒有被配置,那么必須使用auxiliary destination子句來指定輔助實例數(shù)據(jù)庫文件的存儲目錄。確保在快速恢復(fù)區(qū)有足夠的空間可以用來還原root表空間與undo表空間。如果快速恢復(fù)區(qū)沒有足夠的空間,可以通過使用auxiliary destination子句來指定其它的目錄。
對CDB執(zhí)行數(shù)據(jù)庫按時間點恢復(fù)
1.登錄數(shù)據(jù)庫記錄當(dāng)前SCN號,然后將表t1中的數(shù)據(jù)刪除。
SQL> conn jy/jy@jypdb Connected. SQL> SELECT CURRENT_SCN FROM V$DATABASE; CURRENT_SCN ----------- 6041183 SQL> alter session set nls_date_format='yyyy-mm-dd hh34:mi:ss'; Session altered. SQL> select sysdate from dual; SYSDATE ------------------- 2017-12-18 18:28:30 SQL> select count(*) from t1; COUNT(*) ---------- 39 SQL> truncate table t1; Table truncated. SQL> select count(*) from t1; COUNT(*) ---------- 0
2.如果使用時間表達(dá)式來代替目標(biāo)SCN,那么在調(diào)用RMAN之前設(shè)置時間格式環(huán)境變量
[oracle@jytest1 ~]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh34:mi:ss'
3.使用RMAN連接到root容器
[oracle@jytest1 ~]$ rman target/ catalog rco/abcd@jypdb_173 Recovery Manager: Release 12.2.0.1.0 - Production on Mon Dec 18 18:32:00 2017 Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved. connected to target database: JY (DBID=979425723) connected to recovery catalog database
4.將CDB重啟到mount狀態(tài)
RMAN> shutdown immediate starting full resync of recovery catalog full resync complete database closed database dismounted Oracle instance shut down RMAN> startup mount connected to target database (not started) Oracle instance started database mounted Total System Global Area 6442450944 bytes Fixed Size 8807168 bytes Variable Size 1895828736 bytes Database Buffers 4529848320 bytes Redo Buffers 7966720 bytes starting full resync of recovery catalog full resync complete
5.使用RUN塊來執(zhí)行以下操作
a.對于數(shù)據(jù)庫按時間點鶋,使用set until來指定恢復(fù)的目標(biāo)時間,scn或日志序列號,或者使用set to來指定還原點。如果指定時間那么使用環(huán)境變量nls_lang與nls_date_format中所指定的日期格式。
b.如果RMAN沒有配置自動通道,那么需要手動分配磁盤與磁帶通道。
c.還原與恢復(fù)CDB
下面的命令將CDB恢復(fù)到SCN=6041183所在的狀態(tài)
RMAN> run 2> { 3> set until scn 6041183; 4> restore database; 5> recover database; 6> } executing command: SET until clause Starting restore at 2017-12-18 18:46:50 flashing back control file to SCN 6041183 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=764 instance=jy1 device type=DISK skipping datafile 5; already restored to file +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/system.256.962209675 skipping datafile 6; already restored to file +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/sysaux.270.962209675 skipping datafile 8; already restored to file +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/undotbs1.296.962209675 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00001 to +DATA/JY/DATAFILE/system.317.962209603 channel ORA_DISK_1: restoring datafile 00003 to +DATA/JY/DATAFILE/sysaux.298.962209605 channel ORA_DISK_1: restoring datafile 00004 to +DATA/JY/DATAFILE/undotbs1.277.962209605 channel ORA_DISK_1: restoring datafile 00007 to +DATA/JY/DATAFILE/users.301.962209605 channel ORA_DISK_1: restoring datafile 00009 to +DATA/JY/DATAFILE/undotbs2.312.962209605 channel ORA_DISK_1: reading from backup piece +TEST/rman_backup/jy_979425723_962563410_10slv3ai_1_1 channel ORA_DISK_1: piece handle=+TEST/rman_backup/jy_979425723_962563410_10slv3ai_1_1 tag=TAG20171212T184328 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:01:05 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00010 to +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.271.962209649 channel ORA_DISK_1: restoring datafile 00011 to +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.316.962209649 channel ORA_DISK_1: restoring datafile 00012 to +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.264.962209649 channel ORA_DISK_1: restoring datafile 00013 to +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.268.962209649 channel ORA_DISK_1: restoring datafile 00014 to +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.278.962209649 channel ORA_DISK_1: restoring datafile 00015 to +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.275.962210609 channel ORA_DISK_1: reading from backup piece +TEST/rman_backup/jy_979425723_962563516_11slv3ds_1_1 channel ORA_DISK_1: piece handle=+TEST/rman_backup/jy_979425723_962563516_11slv3ds_1_1 tag=TAG20171212T184328 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:35 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00016 to +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409 channel ORA_DISK_1: restoring datafile 00017 to +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409 channel ORA_DISK_1: restoring datafile 00018 to +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409 channel ORA_DISK_1: restoring datafile 00019 to +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409 channel ORA_DISK_1: restoring datafile 00020 to +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409 channel ORA_DISK_1: restoring datafile 00021 to +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409 channel ORA_DISK_1: reading from backup piece +TEST/rman_backup/jy_979425723_962563551_12slv3ev_1_1 channel ORA_DISK_1: piece handle=+TEST/rman_backup/jy_979425723_962563551_12slv3ev_1_1 tag=TAG20171212T184328 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:35 Finished restore at 2017-12-18 18:49:09 Starting recover at 2017-12-18 18:49:11 using channel ORA_DISK_1 applied offline range to datafile 00010 offline range RECID=80 STAMP=963072332 applied offline range to datafile 00011 offline range RECID=79 STAMP=963072332 applied offline range to datafile 00012 offline range RECID=78 STAMP=963072332 applied offline range to datafile 00013 offline range RECID=77 STAMP=963072332 applied offline range to datafile 00014 offline range RECID=76 STAMP=963072332 applied offline range to datafile 00015 offline range RECID=75 STAMP=963072332 applied offline range to datafile 00016 offline range RECID=86 STAMP=963072332 applied offline range to datafile 00017 offline range RECID=85 STAMP=963072332 applied offline range to datafile 00018 offline range RECID=84 STAMP=963072332 applied offline range to datafile 00019 offline range RECID=83 STAMP=963072332 applied offline range to datafile 00020 offline range RECID=82 STAMP=963072332 applied offline range to datafile 00021 offline range RECID=81 STAMP=963072332 starting media recovery archived log for thread 1 with sequence 34 is already on disk as file +TEST/arch/1_34_961976319.dbf archived log for thread 1 with sequence 35 is already on disk as file +TEST/arch/1_35_961976319.dbf archived log for thread 1 with sequence 36 is already on disk as file +TEST/arch/1_36_961976319.dbf archived log for thread 1 with sequence 37 is already on disk as file +TEST/arch/1_37_961976319.dbf archived log for thread 1 with sequence 38 is already on disk as file +TEST/arch/1_38_961976319.dbf archived log for thread 1 with sequence 39 is already on disk as file +TEST/arch/1_39_961976319.dbf archived log for thread 1 with sequence 40 is already on disk as file +TEST/arch/1_40_961976319.dbf archived log for thread 1 with sequence 41 is already on disk as file +TEST/arch/1_41_961976319.dbf archived log for thread 1 with sequence 42 is already on disk as file +TEST/arch/1_42_961976319.dbf archived log for thread 1 with sequence 43 is already on disk as file +TEST/arch/1_43_961976319.dbf archived log for thread 1 with sequence 44 is already on disk as file +TEST/arch/1_44_961976319.dbf archived log for thread 1 with sequence 45 is already on disk as file +TEST/arch/1_45_961976319.dbf archived log for thread 1 with sequence 46 is already on disk as file +TEST/arch/1_46_961976319.dbf archived log for thread 1 with sequence 47 is already on disk as file +TEST/arch/1_47_961976319.dbf archived log for thread 1 with sequence 48 is already on disk as file +TEST/arch/1_48_961976319.dbf archived log for thread 1 with sequence 49 is already on disk as file +TEST/arch/1_49_961976319.dbf archived log for thread 1 with sequence 50 is already on disk as file +TEST/arch/1_50_961976319.dbf archived log for thread 1 with sequence 51 is already on disk as file +TEST/arch/1_51_961976319.dbf archived log for thread 1 with sequence 52 is already on disk as file +DATA/JY/ONLINELOG/group_2.302.961976321 archived log for thread 1 with sequence 53 is already on disk as file +DATA/JY/ONLINELOG/group_1.261.961976319 archived log for thread 2 with sequence 28 is already on disk as file +TEST/arch/2_28_961976319.dbf archived log for thread 2 with sequence 29 is already on disk as file +TEST/arch/2_29_961976319.dbf archived log for thread 2 with sequence 30 is already on disk as file +TEST/arch/2_30_961976319.dbf archived log for thread 2 with sequence 31 is already on disk as file +TEST/arch/2_31_961976319.dbf archived log for thread 2 with sequence 32 is already on disk as file +TEST/arch/2_32_961976319.dbf archived log for thread 2 with sequence 33 is already on disk as file +TEST/arch/2_33_961976319.dbf archived log for thread 2 with sequence 34 is already on disk as file +TEST/arch/2_34_961976319.dbf archived log for thread 2 with sequence 35 is already on disk as file +TEST/arch/2_35_961976319.dbf archived log for thread 2 with sequence 36 is already on disk as file +TEST/arch/2_36_961976319.dbf archived log for thread 2 with sequence 37 is already on disk as file +TEST/arch/2_37_961976319.dbf archived log for thread 2 with sequence 38 is already on disk as file +TEST/arch/2_38_961976319.dbf archived log for thread 2 with sequence 39 is already on disk as file +TEST/arch/2_39_961976319.dbf archived log for thread 2 with sequence 40 is already on disk as file +TEST/arch/2_40_961976319.dbf archived log for thread 2 with sequence 41 is already on disk as file +TEST/arch/2_41_961976319.dbf archived log for thread 2 with sequence 42 is already on disk as file +TEST/arch/2_42_961976319.dbf archived log for thread 2 with sequence 43 is already on disk as file +TEST/arch/2_43_961976319.dbf archived log for thread 2 with sequence 44 is already on disk as file +TEST/arch/2_44_961976319.dbf archived log for thread 2 with sequence 45 is already on disk as file +TEST/arch/2_45_961976319.dbf archived log for thread 2 with sequence 46 is already on disk as file +TEST/arch/2_46_961976319.dbf archived log for thread 2 with sequence 47 is already on disk as file +TEST/arch/2_47_961976319.dbf archived log for thread 2 with sequence 48 is already on disk as file +TEST/arch/2_48_961976319.dbf archived log for thread 2 with sequence 49 is already on disk as file +TEST/arch/2_49_961976319.dbf archived log for thread 2 with sequence 50 is already on disk as file +TEST/arch/2_50_961976319.dbf archived log for thread 2 with sequence 51 is already on disk as file +TEST/arch/2_51_961976319.dbf archived log for thread 2 with sequence 52 is already on disk as file +DATA/JY/ONLINELOG/group_4.262.961976705 archived log for thread 2 with sequence 53 is already on disk as file +DATA/JY/ONLINELOG/group_3.263.961976697 archived log file name=+TEST/arch/1_34_961976319.dbf thread=1 sequence=34 archived log file name=+TEST/arch/2_28_961976319.dbf thread=2 sequence=28 archived log file name=+TEST/arch/1_35_961976319.dbf thread=1 sequence=35 archived log file name=+TEST/arch/2_29_961976319.dbf thread=2 sequence=29 archived log file name=+TEST/arch/1_36_961976319.dbf thread=1 sequence=36 archived log file name=+TEST/arch/2_30_961976319.dbf thread=2 sequence=30 archived log file name=+TEST/arch/2_31_961976319.dbf thread=2 sequence=31 archived log file name=+TEST/arch/1_37_961976319.dbf thread=1 sequence=37 archived log file name=+TEST/arch/2_32_961976319.dbf thread=2 sequence=32 archived log file name=+TEST/arch/1_38_961976319.dbf thread=1 sequence=38 archived log file name=+TEST/arch/2_33_961976319.dbf thread=2 sequence=33 archived log file name=+TEST/arch/1_39_961976319.dbf thread=1 sequence=39 archived log file name=+TEST/arch/2_34_961976319.dbf thread=2 sequence=34 archived log file name=+TEST/arch/1_40_961976319.dbf thread=1 sequence=40 archived log file name=+TEST/arch/2_35_961976319.dbf thread=2 sequence=35 archived log file name=+TEST/arch/1_41_961976319.dbf thread=1 sequence=41 archived log file name=+TEST/arch/2_36_961976319.dbf thread=2 sequence=36 archived log file name=+TEST/arch/1_42_961976319.dbf thread=1 sequence=42 archived log file name=+TEST/arch/2_37_961976319.dbf thread=2 sequence=37 archived log file name=+TEST/arch/2_38_961976319.dbf thread=2 sequence=38 archived log file name=+TEST/arch/1_43_961976319.dbf thread=1 sequence=43 archived log file name=+TEST/arch/2_39_961976319.dbf thread=2 sequence=39 archived log file name=+TEST/arch/1_44_961976319.dbf thread=1 sequence=44 archived log file name=+TEST/arch/2_40_961976319.dbf thread=2 sequence=40 archived log file name=+TEST/arch/1_45_961976319.dbf thread=1 sequence=45 archived log file name=+TEST/arch/2_41_961976319.dbf thread=2 sequence=41 archived log file name=+TEST/arch/1_46_961976319.dbf thread=1 sequence=46 archived log file name=+TEST/arch/2_42_961976319.dbf thread=2 sequence=42 archived log file name=+TEST/arch/2_43_961976319.dbf thread=2 sequence=43 archived log file name=+TEST/arch/1_47_961976319.dbf thread=1 sequence=47 archived log file name=+TEST/arch/2_44_961976319.dbf thread=2 sequence=44 archived log file name=+TEST/arch/2_45_961976319.dbf thread=2 sequence=45 archived log file name=+TEST/arch/1_48_961976319.dbf thread=1 sequence=48 archived log file name=+TEST/arch/2_46_961976319.dbf thread=2 sequence=46 archived log file name=+TEST/arch/1_49_961976319.dbf thread=1 sequence=49 archived log file name=+TEST/arch/2_47_961976319.dbf thread=2 sequence=47 archived log file name=+TEST/arch/2_48_961976319.dbf thread=2 sequence=48 archived log file name=+TEST/arch/1_50_961976319.dbf thread=1 sequence=50 archived log file name=+TEST/arch/2_49_961976319.dbf thread=2 sequence=49 archived log file name=+TEST/arch/1_51_961976319.dbf thread=1 sequence=51 archived log file name=+TEST/arch/2_50_961976319.dbf thread=2 sequence=50 archived log file name=+TEST/arch/2_51_961976319.dbf thread=2 sequence=51 media recovery complete, elapsed time: 00:08:44 Finished recover at 2017-12-18 18:58:02
6.執(zhí)行以下互斥操作
.以讀寫方式打開CDB,放棄目標(biāo)SCN之后的所有改變。在這種情況下,你必須將CDB重啟到mount狀態(tài)后,然后執(zhí)行以下命令
alter database open resetlogs
.使用Data Pump導(dǎo)出CDB中你所需要的對象。然后將CDB恢復(fù)到當(dāng)前時間點并重新導(dǎo)入對象,因此可以將需要的對象進(jìn)行恢復(fù)而不用放棄所有其它對象所發(fā)生的改變。
RMAN> alter database open read only; Statement processed RMAN> alter pluggable database all open read only; Statement processed SQL> conn jy/jy@jypdb Connected. SQL> select count(*) from t1; COUNT(*) ---------- 39 RMAN> shutdown immediate database closed database dismounted Oracle instance shut down RMAN> startup mount connected to target database (not started) Oracle instance started database mounted Total System Global Area 6442450944 bytes Fixed Size 8807168 bytes Variable Size 1895828736 bytes Database Buffers 4529848320 bytes Redo Buffers 7966720 bytes RMAN> recover database; Starting recover at 2017-12-18 22:26:55 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=10 instance=jy1 device type=DISK starting media recovery media recovery complete, elapsed time: 00:00:05 Finished recover at 2017-12-18 22:27:05 RMAN> alter database open; Statement processed starting full resync of recovery catalog full resync complete RMAN> alter pluggable database all open read write; Statement processed starting full resync of recovery catalog full resync complete
感謝各位的閱讀!關(guān)于“如何使用RMAN對CDB執(zhí)行按時間點恢復(fù)”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
本文名稱:如何使用RMAN對CDB執(zhí)行按時間點恢復(fù)-創(chuàng)新互聯(lián)
標(biāo)題路徑:http://muchs.cn/article32/phesc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈、定制開發(fā)、移動網(wǎng)站建設(shè)、App設(shè)計、小程序開發(fā)、企業(yè)網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容