91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Oracle 12C 新特性用rman備份恢復表

發布時間:2020-08-04 23:43:02 來源:ITPUB博客 閱讀:117 作者:pingdanorcale 欄目:關系型數據庫

在12c之前對于用戶因DDL(DROPTRUNCATE )等操作引起的數據丟失,一般通過數據庫時間點不完全恢復、基于表空間的時間點恢復(TSPITR)、閃回技術。

12c 推出了rman基于時間點對表的恢復。原理如下:

Recover Table 新特性是利用創建輔助臨時實例加數據泵工具來實現的。通常在進行Recover Table之前應該準備好兩個目錄(AUXILIARY DESTINATION和DATAPUMP DESTINATION),AUXILIARY DESTINATION用來臨時存放輔助實例的數據文件,DATAPUMP DESTINATION用來臨時存放數據泵導出的文件。

一:測試過程如下:

1.

SQL> set lines 60

SQL> desc tb ;

 Name                          Null?    Type

 ----------------------------- ----------------------------

 OWNER                                  VARCHAR2(128)

 OBJECT_NAME                            VARCHAR2(128)

 SUBOBJECT_NAME                         VARCHAR2(128)

 OBJECT_ID                              NUMBER

 DATA_OBJECT_ID                         NUMBER

 OBJECT_TYPE                            VARCHAR2(23)

 CREATED                                DATE

 LAST_DDL_TIME                          DATE

SQL> insert into  tb select * from tb ;

72633 rows created.

SQL> commit  ;

Commit complete.

SQL>

SQL> conn / as sysdba

Connected.

2. 切換日志使數據寫到磁盤上。

SQL> alter system switch logfile ;

3.rman 備份數據庫

Recovery Manager: Release 12.2.0.1.0 -Production on Fri Jun 29 11:41:03 2018

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

connected to target database: MISDB(DBID=4279250949)

RMAN> run

2> {

3> crosscheck archivelog all;

4> crosscheck  backup;

5> delete noprompt obsolete;

6> delete noprompt expired backup;

7> allocate channel d1  type disk ;

8> allocate channel d2 type disk ;

9> backup format '/u01/bk/%T_%d_%s_%p.dat'tag 'full_data' database ;         

10> backup format'/u01/bk/%T_%d_%s_%p.arc' tag 'full_arc' archivelog all delete all input ;    

11> backup format'/u01/bk/%T_%d_%s_%p.ctl' tag 'full_ctl' current controlfile;

12> release channel d1;

13> release channel d2;

14> };

released channel: d1

released channel: d2

RMAN>

SQL> select count(*) from rita.tb ;

 COUNT(*)

----------

   145266

SQL> select current_scn from v$database;

CURRENT_SCN

-----------

2074690

4. 刪除表

SQL> drop table rita.tb  purge;

SQL> select count(*) from rita.tb ;

 selectcount(*) from rita.tb

                           *

ERROR at line 1:

ORA-00942: table or view does not exist

5. 建輔助目錄

[oracle@host01 u01]$ mkdir  recover/

[oracle@host01 u01]$ mkdir  dumpfiles

[oracle@host01 u01]$ ls

app bk  dumpfiles  lost+found recover

[oracle@host01 u01]$ cd dumpfiles/

[oracle@host01 dumpfiles]$ ls

[oracle@host01 dumpfiles]$ cd  ..

[oracle@host01 u01]$

6. 查看數據庫備份:

list backup of database;

connected to target database: MISDB(DBID=4279250949)

RMAN>

using target database control file instead ofrecovery catalog

7. 恢復刪除的表:

rman target /

Recovery Manager: Release 12.2.0.1.0 -Production on Fri Jun 29 15:22:20 2018

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

connected to target database: MISDB(DBID=4279250949)

RMAN> run{

2> RECOVER TABLE rita.tb

3> UNTIL SCN 2074690

4> AUXILIARY DESTINATION '/u01/recover'

5> datapump destination '/u01/dumpfiles';

6> };

Starting recover at 29-JUN-18

using target database control file instead ofrecovery catalog

current log archived

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=52 instance=misdb1device type=DISK

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

List of tablespaces expected to have UNDOsegments

Tablespace SYSTEM

Tablespace UNDOTBS1

Creating automatic instance, with SID='ygBi' 自動創建一個數據庫實例

oracle@host01 datafile]$ ps -ef |grep smon

grid      5050      1  0 14:57 ?        00:00:00 asm_smon_+ASM1

root      5144      1  1 14:58 ?        00:00:30/u01/app/12.2.0/grid/bin/osysmond.bin

oracle    7730      1  0 15:00 ?        00:00:00 ora_smon_misdb1

oracle   36939      1  015:28 ?        00:00:00 ora_smon_ygBi

reating automatic instance, with SID='ygBi'

initialization parameters used for automatic instance:

db_name=MISDB

db_unique_name=ygBi_pitr_MISDB

compatible=12.2.0

db_block_size=8192

db_files=200

diagnostic_dest=/u01/app/oracle

_system_trig_enabled=FALSE

sga_target=1728M

processes=200

db_create_file_dest=/u01/recover

log_archive_dest_1='location=/u01/recover' --- 這個空間要足夠大

#No auxiliary parameter file used

datafile 1 switched to datafile copy

input datafile copy RECID=4 STAMP=980090756 filename=/u01/recover/MISDB/datafile/o1_mf_system_fmcqnsc8_.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=5 STAMP=980090756 filename=/u01/recover/MISDB/datafile/o1_mf_undotbs1_fmcqpx2n_.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=6 STAMP=980090756 filename=/u01/recover/MISDB/datafile/o1_mf_sysaux_fmcqpx17_.dbf

contents of Memory Script:

{

# set requested point in time

set until  scn2074690;

# 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';

。。。

contents of Memory Script:

{

# create directory for datapump import

sql "create or replace directory TSPITR_DIROBJ_DPDIRas ''

/u01/dumpfiles''";

# create directory for datapump export

sql clone "create or replace directoryTSPITR_DIROBJ_DPDIR as ''

/u01/dumpfiles''";

}

executing Memory Script

sql statement: create or replace directoryTSPITR_DIROBJ_DPDIR as ''/u01/dumpfiles''

sql statement: create or replace directoryTSPITR_DIROBJ_DPDIR as ''/u01/dumpfiles''

Performing export of tables...

  EXPDP> Starting"SYS"."TSPITR_EXP_ygBi_gcph": 

  EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

  EXPDP> Processing object typeTABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

  EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER

  EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE

   EXPDP> . .exported "RITA"."TB"                                 19.21 MB  145266 rows

   EXPDP> Mastertable "SYS"."TSPITR_EXP_ygBi_gcph" successfullyloaded/unloaded

   EXPDP>******************************************************************************

   EXPDP> Dumpfile set for SYS.TSPITR_EXP_ygBi_gcph is:

   EXPDP>   /u01/dumpfiles/tspitr_ygBi_13106.dmp

   EXPDP> Job"SYS"."TSPITR_EXP_ygBi_gcph" successfully completed at FriJun 29 15:31:30 2018 elapsed 0 00:01:09

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_ygBi_yzeq"successfully loaded/unloaded

  IMPDP> Starting"SYS"."TSPITR_IMP_ygBi_yzeq": 

    IMPDP> Processing object typeTABLE_EXPORT/TABLE/TABLE

   IMPDP>Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

   IMPDP> . .imported "RITA"."TB"                                 19.21 MB  145266 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_ygBi_yzeq" successfully completed at FriJun 29 15:32:44 2018 elapsed 0 00:00:41

Import completed

二:從上邊的例子可以看出,恢復大體流程是

1.rman  根據指定的表確定備份。

2.rman  根據指定的recover 路徑恢復一個輔助實例,恢復到指定的時間點。

Creating automatic instance, with SID='ygBi'

initialization parameters used for automatic instance:

db_name=MISDB

db_unique_name=ygBi_pitr_MISDB

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  scn2074690;

# set destinations for recovery set and auxiliary setdatafiles

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;

3. 用恢復好的輔助實例,數據庫導出在導入生產環境

EXPDP> Starting"SYS"."TSPITR_EXP_ygBi_gcph": 

   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

Performing import of tables...

   IMPDP> Mastertable "SYS"."TSPITR_IMP_ygBi_yzeq" successfullyloaded/unloaded

   IMPDP>Starting "SYS"."TSPITR_IMP_ygBi_yzeq": 

   IMPDP>Processing object type TABLE_EXPORT/TABLE/TABLE

   IMPDP>Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

   IMPDP> . .imported "RITA"."TB"                                 19.21 MB  145266 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_ygBi_yzeq" successfully completed at FriJun 29 15:32:44 2018 elapsed 0 00:00:41

Import completed

4. 刪除輔助實例

恢復完成。

三:RECOVER TABLE需要注意的幾個問題:

1. 目標數據庫必須被置于讀寫模式。

2. 目標數據庫必須被置于歸檔模式。

3.SYS 用戶下的表或分區無法恢復。

4. 存儲于SYSAUX和SYSTEM表空間下的表和分區無法恢復。

5.Standby 數據庫上的表或表分區不能進行恢復。

6. 在執行“RECOVER TABLE”命令時,可以根據需要在以下三種級別指定時間:

(1)SCN號

(2)Sequence number(日志序列號)

(3)Time:根據NLS_LANG和NLS_DATE_FORMAT環境變量中的格式來指定時間,也可以用SYSDATE,比如"SYSDATE-30"、"to_date('2018-06-29:17:51:48','yyyy-mm-ddhh34:mi:ss')"

參考文檔

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/bradv/rman-recovering-tables-partitions.html#GUID-87B7F772-335F-4179-81C9-91678D026D01

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

兰坪| 肃宁县| 延吉市| 安仁县| 简阳市| 堆龙德庆县| 慈利县| 曲阜市| 光泽县| 汾西县| 永昌县| 汤阴县| 三原县| 天全县| 从江县| 五河县| 晋宁县| 绩溪县| 醴陵市| 噶尔县| 南皮县| 淮南市| 广灵县| 霞浦县| 佛冈县| 天门市| 云浮市| 永康市| 富裕县| 新民市| 柘荣县| 教育| 渭源县| 布拖县| 广宁县| 晋江市| 苏尼特左旗| 临城县| 重庆市| 繁峙县| 公安县|