久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Oracle12 RMAN新特性Recover Table有什么作用

共計(jì) 14104 個(gè)字符,預(yù)計(jì)需要花費(fèi) 36 分鐘才能閱讀完成。

這篇文章主要講解了“Oracle12 RMAN 新特性 Recover Table 有什么作用”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著丸趣 TV 小編的思路慢慢深入,一起來研究和學(xué)習(xí)“Oracle12 RMAN 新特性 Recover Table 有什么作用”吧!

在 Oracle 12c 之前,如果誤刪一張表,常規(guī)的方法是 Flashback 閃回或 TSPITR。而開啟 flashback 會(huì)消耗磁盤空間,且如果被 purge 或者經(jīng)過 DDL,將無法 flashback。如果需要恢復(fù)的表空間過大,TSPITR 會(huì)耗時(shí)非常久。12c 中提供了 Table Recovery 的新特性,可以針對(duì)單表(或單個(gè)表分區(qū))基于時(shí)間點(diǎn)進(jìn)行恢復(fù),該特性用以直接從 RMAN 備份中恢復(fù)表的方法,該特性有以下特點(diǎn):

不影響數(shù)據(jù)庫中的其他數(shù)據(jù)庫對(duì)象

減少時(shí)間和磁盤空間的消耗,和早期的 TSPIRT 工作流程類似

從另一個(gè)磁盤路徑恢復(fù)表空間

導(dǎo)出想要的表數(shù)據(jù)

導(dǎo)入到原數(shù)據(jù)庫(可選)

 recover table 可以將一個(gè)或多個(gè)表或表分區(qū)恢復(fù)到指定的時(shí)間點(diǎn),而不會(huì)影響其余的數(shù)據(jù)庫對(duì)象。可以使用以前創(chuàng)建的 RMAN 備份將表和表分區(qū)恢復(fù)到指定的時(shí)間點(diǎn)。

該表被恢復(fù)到一個(gè)輔助實(shí)例中,并且可以選擇:

使用 REMAP 選項(xiàng)將恢復(fù)的表導(dǎo)入新表或分區(qū)

僅在恢復(fù)的表中創(chuàng)建 expdp dump 文件,以便在其他時(shí)間進(jìn)行導(dǎo)入

  先決條件

目標(biāo)數(shù)據(jù)庫必須處于讀寫模式。

目標(biāo)數(shù)據(jù)庫必須處于 ARCHIVELOG 模式。

您必須擁有表或表分區(qū)的 RMAN 備份,因?yàn)樗鼈兇嬖谟谝謴?fù)這些對(duì)象的時(shí)間點(diǎn)。

要恢復(fù)單個(gè)表分區(qū),目標(biāo)數(shù)據(jù)庫的 COMPATIBLE 初始化參數(shù)必須設(shè)置為 11.1.0 或更高。

請(qǐng)確保 AUXILIARY DESTINATION 有足夠的空間來恢復(fù) system、sysaux、undo 以及恢復(fù)表所需的表空間。

請(qǐng)注意,表恢復(fù)后,輔助目標(biāo)中的這些文件將自動(dòng)刪除

必須使用 AUXILIARY DESTINATION 子句和后面其中一個(gè)子句來指定恢復(fù)的時(shí)間點(diǎn):UNTIL TIME、UNTIL SCN 或 UNTIL SEQUENCE。

  使用限制

  屬于 SYS 模式的表和表分區(qū)無法恢復(fù)。

 SYSTEM 和 SYSAUX 表空間中的表和表分區(qū)無法恢復(fù)。

 standby 數(shù)據(jù)庫上的表和表分區(qū)無法恢復(fù)。

  命名為 NOT NULL 約束的表不能用 REMAP 選項(xiàng)恢復(fù)。

RMAN 從備份中自動(dòng)處理恢復(fù)表或者表分區(qū)時(shí)會(huì)執(zhí)行如下步驟:

1. 判斷哪些備份包含需要恢復(fù)的表或表分區(qū),然后根據(jù)指定的時(shí)間來進(jìn)行恢復(fù)。

2. 判斷目標(biāo)主機(jī)上是否有足夠的空間來創(chuàng)建 auxiliary instance,該實(shí)例用于處理表或分區(qū)的恢復(fù)。如果需要的空間不足,那么 RMAN 會(huì)報(bào)錯(cuò)并退出恢復(fù)操作。

3. 創(chuàng)建 auxiliary database,并根據(jù)指定的時(shí)間來恢復(fù)指定的表或表分區(qū)到 auxiliary database 中。輔助數(shù)據(jù)庫的數(shù)據(jù)文件位置可以在命令中指定。

4. 創(chuàng)建包含恢復(fù)表或表分區(qū)的數(shù)據(jù)泵文件(expdp dump file)。數(shù)據(jù)泵的名稱和位置也可以在命令中指定。

5.(可選操作)將上一步生產(chǎn)的數(shù)據(jù)泵文件導(dǎo)入到目標(biāo)實(shí)例中。當(dāng)然也可以選擇不導(dǎo)入,如果選擇不導(dǎo)入就必須使用 impdp 手工導(dǎo)入。

6.(可選操作)在目標(biāo)數(shù)據(jù)庫中 rename 恢復(fù)表或表分區(qū)。

使用場(chǎng)景

RMAN 的表級(jí)和表分區(qū)級(jí)恢復(fù)在以下場(chǎng)景中非常適用:

(1)  需要將非常少量的表恢復(fù)至特定的時(shí)間點(diǎn)。在這種情況下,TSPITR 不是最有效的解決方案,因?yàn)樗鼤?huì)將表空間中的所有對(duì)象恢復(fù)到指定的時(shí)間點(diǎn)。

(2)  需要恢復(fù)已被邏輯損壞或已被
drop 和 purge
的表。

(3) flashback
不可用,比如需要的 undo 數(shù)據(jù)被覆蓋。

(4) DDL
操作修改表結(jié)構(gòu)后丟失的數(shù)據(jù)。flashback table 不能跨越 DDL(例如 truncate)來回滾表。

在這 Recover table 過程演示

創(chuàng)建測(cè)試表

SQL create table t_recover_test as select * from dba_objects;  

 

Table created.

 

SQL select count(*) from t_recover_test;

 

COUNT(*)

———-

 72652

備份

[oracle@localhost ~]$ rman target /

Recovery Manager: Release 12.2.0.1.0 – Production on Thu Jun 28 21:06:17 2018

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PCC (DBID=3164878903)

RMAN
backup database format /home/oracle/bak/db_%U

 

Starting backup at 28-JUN-18

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=61 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=/home/oracle/oradata/pcc/system01.dbf

input datafile file number=00003 name=/home/oracle/oradata/pcc/sysaux01.dbf

input datafile file number=00004 name=/home/oracle/oradata/pcc/undotbs01.dbf

input datafile file number=00005 name=/home/oracle/oradata/pcc/tbs_zyq01.dbf

input datafile file number=00007 name=/home/oracle/oradata/pcc/users01.dbf

channel ORA_DISK_1: starting piece 1 at 28-JUN-18

channel ORA_DISK_1: finished piece 1 at 28-JUN-18

piece handle=/home/oracle/bak/db_01t6k254_1_1 tag=TAG20180628T215236 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15

Finished backup at 28-JUN-18

 

Starting Control File and SPFILE Autobackup at 28-JUN-18

piece handle=/u01/app/oracle/product/12.2.0.1/dbs/c-3164878903-20180628-00 comment=NONE

Finished Control File and SPFILE Autobackup at 28-JUN-18

恢復(fù)表

[oracle@localhost ~]$ rman target /

Recovery Manager: Release 12.2.0.1.0 – Production on Fri Jun 29 00:52:29 2018

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PCC (DBID=3164878903)

RMAN
RECOVER TABLE zyq.t_recover_test

until time   to_date(2018-06-28 23:56:06 , yyyy-mm-dd hh34:mi:ss)

AUXILIARY DESTINATION /data01

REMAP TABLE zyq.t_recover_test:t_recover_test_map;

 

Starting recover at 29-JUN-18

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=66 device type=DISK

RMAN-05026: warning: presuming following set of tablespaces applies to specified point-in-time

 

List of tablespaces expected to have UNDO segments

Tablespace SYSTEM

Tablespace UNDOTBS1

 

Creating automatic instance, with SID= hCed

initialization parameters used for automatic instance:

db_name=PCC

db_unique_name=hCed_pitr_PCC

compatible=12.2.0

db_block_size=8192

db_files=200

diagnostic_dest=/u01/app/oracle

_system_trig_enabled=FALSE

sga_target=732M

processes=200

db_create_file_dest=/data01

log_archive_dest_1= location=/data01

#No auxiliary parameter file used

starting up automatic instance PCC

 

Oracle instance started

 

Total System Global Area  767557632 bytes

 

Fixed Size  8625416 bytes

Variable Size  213910264 bytes

Database Buffers  541065216 bytes

Redo Buffers  3956736 bytes

Automatic instance created

 

contents of Memory Script:

{

# set requested point in time

set until  time to_date(2018-06-28 23:56:06 , yyyy-mm-dd hh34:mi:ss)

# restore the controlfile

restore clone controlfile;

 

# mount the controlfile

sql clone alter database mount clone database

 

# archive current online log

sql alter system archive log current

}

executing Memory Script

 

executing command: SET until clause

 

Starting restore at 29-JUN-18

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=35 device type=DISK

 

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: restoring control file

channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/product/12.2.0.1/dbs/c-3164878903-20180628-01

channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/product/12.2.0.1/dbs/c-3164878903-20180628-01 tag=TAG20180628T234914

channel ORA_AUX_DISK_1: restored backup piece 1

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02

output file name=/data01/PCC/controlfile/o1_mf_fmcsc00p_.ctl

Finished restore at 29-JUN-18

 

sql statement: alter database mount clone database

 

sql statement: alter system archive log current

 

contents of Memory Script:

{

# set requested point in time

set until  time to_date(2018-06-28 23:56:06 , yyyy-mm-dd hh34:mi:ss)

# set destinations for recovery set and auxiliary set datafiles

set newname for clone datafile  1 to new;

set newname for clone datafile  4 to new;

set newname for clone datafile  3 to new;

set newname for clone tempfile  1 to new;

# switch all tempfiles

switch clone tempfile all;

# restore the tablespaces in the recovery set and the auxiliary set

restore clone datafile  1, 4, 3;

 

switch clone datafile all;

}

executing Memory Script

 

executing command: SET until clause

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

renamed tempfile 1 to /data01/PCC/datafile/o1_mf_temp_%u_.tmp in control file

 

Starting restore at 29-JUN-18

using channel ORA_AUX_DISK_1

 

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00001 to /data01/PCC/datafile/o1_mf_system_%u_.dbf

channel ORA_AUX_DISK_1: restoring datafile 00004 to /data01/PCC/datafile/o1_mf_undotbs1_%u_.dbf

channel ORA_AUX_DISK_1: restoring datafile 00003 to /data01/PCC/datafile/o1_mf_sysaux_%u_.dbf

channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/bak/db_01t6k254_1_1

channel ORA_AUX_DISK_1: piece handle=/home/oracle/bak/db_01t6k254_1_1 tag=TAG20180628T215236

channel ORA_AUX_DISK_1: restored backup piece 1

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15

Finished restore at 29-JUN-18

 

datafile 1 switched to datafile copy

input datafile copy RECID=4 STAMP=980038406 file name=/data01/PCC/datafile/o1_mf_system_fmcsc755_.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=5 STAMP=980038406 file name=/data01/PCC/datafile/o1_mf_undotbs1_fmcsc75h_.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=6 STAMP=980038406 file name=/data01/PCC/datafile/o1_mf_sysaux_fmcsc75c_.dbf

 

contents of Memory Script:

{

# set requested point in time

set until  time to_date(2018-06-28 23:56:06 , yyyy-mm-dd hh34:mi:ss)

# online the datafiles restored or switched

sql clone alter database datafile  1 online

sql clone alter database datafile  4 online

sql clone alter database datafile  3 online

# recover and open database read only

recover clone database tablespace   SYSTEM , UNDOTBS1 , SYSAUX

sql clone alter database open read only

}

executing Memory Script

 

executing command: SET until clause

 

sql statement: alter database datafile  1 online

 

sql statement: alter database datafile  4 online

 

sql statement: alter database datafile  3 online

 

Starting recover at 29-JUN-18

using channel ORA_AUX_DISK_1

 

starting media recovery

 

archived log for thread 1 with sequence 3 is already on disk as file /u01/app/oracle/product/12.2.0.1/dbs/arch2_3_979872889.dbf

archived log for thread 1 with sequence 4 is already on disk as file /u01/app/oracle/product/12.2.0.1/dbs/arch2_4_979872889.dbf

archived log file name=/u01/app/oracle/product/12.2.0.1/dbs/arch2_3_979872889.dbf thread=1 sequence=3

archived log file name=/u01/app/oracle/product/12.2.0.1/dbs/arch2_4_979872889.dbf thread=1 sequence=4

media recovery complete, elapsed time: 00:00:11

Finished recover at 29-JUN-18

 

sql statement: alter database open read only

 

contents of Memory Script:

{

sql clone create spfile from memory

shutdown clone immediate;

startup clone nomount;

sql clone alter system set  control_files =

/data01/PCC/controlfile/o1_mf_fmcsc00p_.ctl comment=

RMAN set scope=spfile

shutdown clone immediate;

startup clone nomount;

# mount database

sql clone alter database mount clone database

}

executing Memory Script

 

sql statement: create spfile from memory

 

database closed

database dismounted

Oracle instance shut down

 

connected to auxiliary database (not started)

Oracle instance started

 

Total System Global Area  767557632 bytes

 

Fixed Size  8625416 bytes

Variable Size  213910264 bytes

Database Buffers  541065216 bytes

Redo Buffers  3956736 bytes

 

sql statement: alter system set  control_files =   /data01/PCC/controlfile/o1_mf_fmcsc00p_.ctl comment= RMAN set scope=spfile

 

Oracle instance shut down

 

connected to auxiliary database (not started)

Oracle instance started

 

Total System Global Area  767557632 bytes

 

Fixed Size  8625416 bytes

Variable Size  213910264 bytes

Database Buffers  541065216 bytes

Redo Buffers  3956736 bytes

 

sql statement: alter database mount clone database

 

contents of Memory Script:

{

# set requested point in time

set until  time to_date(2018-06-28 23:56:06 , yyyy-mm-dd hh34:mi:ss)

# set destinations for recovery set and auxiliary set datafiles

set newname for datafile  5 to new;

# restore the tablespaces in the recovery set and the auxiliary set

restore clone datafile  5;

 

switch clone datafile all;

}

executing Memory Script

 

executing command: SET until clause

 

executing command: SET NEWNAME

 

Starting restore at 29-JUN-18

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=34 device type=DISK

 

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00005 to /data01/HCED_PITR_PCC/datafile/o1_mf_tbs_zyq_%u_.dbf

channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/bak/db_01t6k254_1_1

channel ORA_AUX_DISK_1: piece handle=/home/oracle/bak/db_01t6k254_1_1 tag=TAG20180628T215236

channel ORA_AUX_DISK_1: restored backup piece 1

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03

Finished restore at 29-JUN-18

 

datafile 5 switched to datafile copy

input datafile copy RECID=8 STAMP=980038478 file name=/data01/HCED_PITR_PCC/datafile/o1_mf_tbs_zyq_fmcsfttn_.dbf

 

contents of Memory Script:

{

# set requested point in time

set until  time to_date(2018-06-28 23:56:06 , yyyy-mm-dd hh34:mi:ss)

# online the datafiles restored or switched

sql clone alter database datafile  5 online

# recover and open resetlogs

recover clone database tablespace   TBS_ZYQ , SYSTEM , UNDOTBS1 , SYSAUX delete archivelog;

alter clone database open resetlogs;

}

executing Memory Script

 

executing command: SET until clause

 

sql statement: alter database datafile  5 online

 

Starting recover at 29-JUN-18

using channel ORA_AUX_DISK_1

 

starting media recovery

 

archived log for thread 1 with sequence 3 is already on disk as file /u01/app/oracle/product/12.2.0.1/dbs/arch2_3_979872889.dbf

archived log for thread 1 with sequence 4 is already on disk as file /u01/app/oracle/product/12.2.0.1/dbs/arch2_4_979872889.dbf

archived log file name=/u01/app/oracle/product/12.2.0.1/dbs/arch2_3_979872889.dbf thread=1 sequence=3

archived log file name=/u01/app/oracle/product/12.2.0.1/dbs/arch2_4_979872889.dbf thread=1 sequence=4

media recovery complete, elapsed time: 00:00:01

Finished recover at 29-JUN-18

 

database opened

 

contents of Memory Script:

{

# create directory for datapump import

sql create or replace directory TSPITR_DIROBJ_DPDIR as

/data01

# create directory for datapump export

sql clone create or replace directory TSPITR_DIROBJ_DPDIR as

/data01

}

executing Memory Script

 

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as /data01

 

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as /data01

 

Performing export of tables…

 EXPDP Starting SYS . TSPITR_EXP_hCed_Dhxe :  

 EXPDP Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

 EXPDP Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

 EXPDP Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER

 EXPDP Processing object type TABLE_EXPORT/TABLE/TABLE

 EXPDP . . exported ZYQ . T_RECOVER_TEST  9.324 MB  72652 rows

 EXPDP Master table SYS . TSPITR_EXP_hCed_Dhxe successfully loaded/unloaded

 EXPDP ******************************************************************************

 EXPDP Dump file set for SYS.TSPITR_EXP_hCed_Dhxe is:

 EXPDP  /data01/tspitr_hCed_71393.dmp

 EXPDP Job SYS . TSPITR_EXP_hCed_Dhxe successfully completed at Fri Jun 29 00:55:41 2018 elapsed 0 00:00:35

Export completed

 

contents of Memory Script:

{

# shutdown clone before import

shutdown clone abort

}

executing Memory Script

 

Oracle instance shut down

 

Performing import of tables…

 IMPDP Master table SYS . TSPITR_IMP_hCed_Arhm successfully loaded/unloaded

 IMPDP Starting SYS . TSPITR_IMP_hCed_Arhm :  

 IMPDP Processing object type TABLE_EXPORT/TABLE/TABLE

 IMPDP Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

 IMPDP . . imported ZYQ . T_RECOVER_TEST_MAP  9.324 MB  72652 rows

 IMPDP Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

 IMPDP Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER

 IMPDP Job SYS . TSPITR_IMP_hCed_Arhm successfully completed at Fri Jun 29 00:56:43 2018 elapsed 0 00:00:45

Import completed

 

Removing automatic instance

Automatic instance removed

auxiliary instance file /data01/PCC/datafile/o1_mf_temp_fmcsd5ny_.tmp deleted

auxiliary instance file /data01/HCED_PITR_PCC/onlinelog/o1_mf_3_fmcsg3y6_.log deleted

auxiliary instance file /data01/HCED_PITR_PCC/onlinelog/o1_mf_2_fmcsg07o_.log deleted

auxiliary instance file /data01/HCED_PITR_PCC/onlinelog/o1_mf_1_fmcsfzr1_.log deleted

auxiliary instance file /data01/HCED_PITR_PCC/datafile/o1_mf_tbs_zyq_fmcsfttn_.dbf deleted

auxiliary instance file /data01/PCC/datafile/o1_mf_sysaux_fmcsc75c_.dbf deleted

auxiliary instance file /data01/PCC/datafile/o1_mf_undotbs1_fmcsc75h_.dbf deleted

auxiliary instance file /data01/PCC/datafile/o1_mf_system_fmcsc755_.dbf deleted

auxiliary instance file /data01/PCC/controlfile/o1_mf_fmcsc00p_.ctl deleted

auxiliary instance file tspitr_hCed_71393.dmp deleted

Finished recover at 29-JUN-18

 

RMAN

驗(yàn)證

SQL select count(*) from T_RECOVER_TEST_MAP;

 

 COUNT(*)

———-

 72652

感謝各位的閱讀,以上就是“Oracle12 RMAN 新特性 Recover Table 有什么作用”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì) Oracle12 RMAN 新特性 Recover Table 有什么作用這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是丸趣 TV,丸趣 TV 小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-07-24發(fā)表,共計(jì)14104字。
轉(zhuǎn)載說明:除特殊說明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請(qǐng)注明出處。
評(píng)論(沒有評(píng)論)
主站蜘蛛池模板: 杂多县| 嘉义市| 昌乐县| 庆阳市| 百色市| 山丹县| 东兰县| 商城县| 东丰县| 黄陵县| 镇巴县| 广饶县| 洛南县| 湘乡市| 门源| 南漳县| 沁水县| 沂水县| 疏勒县| 海林市| 白水县| 微山县| 汉源县| 拜城县| 阿荣旗| 阿巴嘎旗| 县级市| 玛纳斯县| 富锦市| 东港市| 本溪市| 隆林| 武乡县| 肃南| 南澳县| 嘉定区| 庄浪县| 余干县| 彩票| 阿瓦提县| 赤城县|