国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

Oracle12c RMAN基于表的時(shí)間點(diǎn)恢復(fù)

IT那活兒 / 2813人閱讀
Oracle12c RMAN基于表的時(shí)間點(diǎn)恢復(fù)
點(diǎn)擊上方“IT那活兒”公眾號(hào),關(guān)注后了解更多內(nèi)容,不管IT什么活兒,干就完了!!!
1

概念

在Oracle數(shù)據(jù)庫中,對于用戶DDL(DROP TRUNCATE)等誤操作,引起的數(shù)據(jù)丟失,恢復(fù)的手段有:

  • 基于數(shù)據(jù)庫時(shí)間點(diǎn)不完全恢復(fù);
  • 基于表空間時(shí)間點(diǎn)恢復(fù)TSPIRT進(jìn)行數(shù)據(jù)恢復(fù)。
但是在12c中,RMAN新的特性:基于表的時(shí)間點(diǎn)恢復(fù),更加方便。
如下圖官方文檔所示:

2

恢復(fù)的目的

12c的RMAN基于表級別恢復(fù)是可以恢復(fù)單個(gè)或者更多的表或者分區(qū)表的時(shí)候,而不影響其他的數(shù)據(jù)庫對象,就是說在11g你無法基于表級別恢復(fù),而當(dāng)你做基于時(shí)間點(diǎn)恢復(fù),那么數(shù)據(jù)庫上的其他對象也會(huì)恢復(fù)到你要恢復(fù)的那個(gè)時(shí)間點(diǎn),或者你做基于表空間的恢復(fù)(TSPITR)都是會(huì)影響其他的數(shù)據(jù)庫對象。
在 Oracle 12c 中,在發(fā)生 drop truncate 的情況下,可以從 RMAN 備份中將一個(gè)特定的表或分區(qū)恢復(fù)到某個(gè)時(shí)間點(diǎn)、SCN 或歸檔序列號(hào)。

如果是 delete 的誤操作,如果在閃回范圍時(shí)間內(nèi),可以用閃回來恢復(fù)。

3

恢復(fù)的要求

如官方文檔所示:
--主要用到的技術(shù):
Oracle 12c的Recover Table新特性是利用創(chuàng)建輔助臨時(shí)實(shí)例加數(shù)據(jù)泵工具來實(shí)現(xiàn)的。
通常在進(jìn)行Recover Table之前應(yīng)該準(zhǔn)備好兩個(gè)目錄(AUXILIARY DESTINATION和DATAPUMP DESTINATION),AUXILIARY DESTINATION用來臨時(shí)存放輔助實(shí)例的數(shù)據(jù)文件,DATAPUMP DESTINATION用來臨時(shí)存放數(shù)據(jù)泵導(dǎo)出的文件。

--步驟

  • 建立一個(gè)輔助的實(shí)例;
  • 在輔助實(shí)例上做全庫的恢復(fù);
  • 通過datapump工具導(dǎo)出,導(dǎo)入。

4

恢復(fù)實(shí)驗(yàn)過程

4.1 創(chuàng)建測試用戶,授權(quán),分配測試表空間,給測試數(shù)據(jù)
--創(chuàng)建測試用戶:
SQL> alter session set container=PRODPDB;

Session altered.

SQL>

SQL> show con_name;

CON_NAME
------------------------------
PRODPDB

SQL>
 create user pdbwjh identified by pdbwjh;

User created.
--授權(quán):
grant connect,resource to pdbwjh;
grant CREATE TABLE to pdbwjh;
grant SELECT ANY TABLE to pdbwjh;
grant UNLIMITED TABLESPACE to pdbwjh;
--創(chuàng)建測試表空間,并更改用戶表空間。
--創(chuàng)建數(shù)據(jù)tbs:
create tablespace pdbwjh_data logging datafile /u01/app/oracle/oradata/prod/prodpdb/pdbwjh_data01.dbf size 100M autoextend off;
--創(chuàng)建臨時(shí)tbs:
create temporary tablespace pdbwjh_temp tempfile /u01/app/oracle/oradata/prod/prodpdb/pdbwjh_tmp.dbf size 30M autoextend off;
--更改用戶默認(rèn)表空間:
alter user pdbwjh default tablespace pdbwjh_data temporary tablespace pdbwjh_temp;
--查詢用戶所在表空間:
set line 300;
col username for a20
select USERNAME,ACCOUNT_STATUS,DEFAULT_TABLESPACE,TEMPORARY_TABLESPACE from dba_users where username=&username;



USERNAME ACCOUNT_STATUS DEFAULT_TABLESPACE TEMPORARY_TABLESPACE
-------------------- -------------------------------- ------------------------------ ------------------------------
PDBWJH OPEN PDBWJH_DATA PDBWJH_TEMP
--創(chuàng)表給數(shù)據(jù):
SQL> create table PDBWJH.testjk tablespace PDBWJH_DATA as select * from dba_objects;
Table created.
SQL>
SQL> select count(1) from pdbwjh.testjk;
COUNT(1)
----------
72635
SQL> commit;
Commit complete.
4.2 對數(shù)據(jù)庫進(jìn)行backup,因?yàn)榛謴?fù)需要提前有備份集才可以
[oracle@12c ~]$ rman target /

Recovery Manager: Release 12.2.0.1.0 - Production on Wed Jun 29 23:19:33 2022

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

connected to target database: PROD (DBID=515416371)

RMAN> run{
crosscheck archivelog all;
crosscheck backup;
backup database ;
backup archivelog all delete all input ;
backup current controlfile;
}2> 3> 4> 5> 6> 7>

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=278 device type=DISK
specification does not match any archived log in the repository

using channel ORA_DISK_1
specification does not match any backup in the repository

Starting backup at 29-JUN-22
using channel ORA_DISK_1
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=/u01/app/oracle/oradata/prod/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/prod/sysaux01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/prod/undotbs01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/prod/users01.dbf
channel ORA_DISK_1: starting piece 1 at 29-JUN-22
channel ORA_DISK_1: finished piece 1 at 29-JUN-22
piece handle=/u01/app/oracle/fast_recovery_area/prod/PROD/backupset/2022_06_29/o1_mf_nnndf_TAG20220629T232230_kcrvkpbl_.bkp tag=TAG20220629T232230 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00010 name=/u01/app/oracle/oradata/prod/prodpdb/sysaux01.dbf
input datafile file number=00009 name=/u01/app/oracle/oradata/prod/prodpdb/system01.dbf
input datafile file number=00011 name=/u01/app/oracle/oradata/prod/prodpdb/undotbs01.dbf
input datafile file number=00020 name=/u01/app/oracle/oradata/prod/prodpdb/pdbwjh_data01.dbf
input datafile file number=00012 name=/u01/app/oracle/oradata/prod/prodpdb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 29-JUN-22
channel ORA_DISK_1: finished piece 1 at 29-JUN-22
piece handle=/u01/app/oracle/fast_recovery_area/prod/PROD/DDF44DDF02C79B34E053C82BA8C0429E/backupset/2022_06_29/o1_mf_nnndf_TAG20220629T232230_kcrvkxgh_.bkp tag=TAG20220629T232230 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00017 name=/u01/app/oracle/oradata/prod/prodpdb1/sysaux01.dbf
input datafile file number=00016 name=/u01/app/oracle/oradata/prod/prodpdb1/system01.dbf
input datafile file number=00018 name=/u01/app/oracle/oradata/prod/prodpdb1/undotbs01.dbf
input datafile file number=00021 name=/u01/app/oracle/oradata/prod/prodpdb1/tbs1.dbf
input datafile file number=00019 name=/u01/app/oracle/oradata/prod/prodpdb1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 29-JUN-22
channel ORA_DISK_1: finished piece 1 at 29-JUN-22
piece handle=/u01/app/oracle/fast_recovery_area/prod/PROD/DE31ABD04811453BE053C800A8C01835/backupset/2022_06_29/o1_mf_nnndf_TAG20220629T232230_kcrvl0l7_.bkp tag=TAG20220629T232230 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/u01/app/oracle/oradata/prod/pdbseed/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/prod/pdbseed/system01.dbf
input datafile file number=00008 name=/u01/app/oracle/oradata/prod/pdbseed/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 29-JUN-22
channel ORA_DISK_1: finished piece 1 at 29-JUN-22
piece handle=/u01/app/oracle/fast_recovery_area/prod/PROD/DDF43DBAEC79939EE053C82BA8C00C8C/backupset/2022_06_29/o1_mf_nnndf_TAG20220629T232230_kcrvl3o0_.bkp tag=TAG20220629T232230 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 29-JUN-22

Starting backup at 29-JUN-22
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=17 RECID=13 STAMP=1108682566
channel ORA_DISK_1: starting piece 1 at 29-JUN-22
channel ORA_DISK_1: finished piece 1 at 29-JUN-22
piece handle=/u01/app/oracle/fast_recovery_area/prod/PROD/backupset/2022_06_29/o1_mf_annnn_TAG20220629T232247_kcrvl73l_.bkp tag=TAG20220629T232247 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u01/app/oracle/fast_recovery_area/prod/PROD/archivelog/2022_06_29/o1_mf_1_17_kcrvl6z4_.arc RECID=13 STAMP=1108682566
Finished backup at 29-JUN-22

Starting backup at 29-JUN-22
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 29-JUN-22
channel ORA_DISK_1: finished piece 1 at 29-JUN-22
piece handle=/u01/app/oracle/fast_recovery_area/prod/PROD/backupset/2022_06_29/o1_mf_ncnnf_TAG20220629T232248_kcrvl9hy_.bkp tag=TAG20220629T232248 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-JUN-22

Starting Control File and SPFILE Autobackup at 29-JUN-22
piece handle=/u01/app/oracle/fast_recovery_area/prod/PROD/autobackup/2022_06_29/o1_mf_s_1108682570_kcrvlbmq_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 29-JUN-22
4.3 模擬用戶誤刪除表(truncate,無法使用閃回)
[oracle@12c ~]$ sqlplus pdbwjh/pdbwjh@prodpdb

SQL*Plus: Release 12.2.0.1.0 Production on Wed Jun 29 23:26:35 2022

Copyright (c) 1982, 2016, Oracle. All rights reserved.

Last Successful login time: Tue Jun 28 2022 21:55:38 +08:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>

SQL>
SQL> show con_name

CON_NAME
------------------------------
PRODPDB
SQL> select table_name from user_tables;

TABLE_NAME
--------------------------------------------------------------------------------
SQLLOADER_TEST01
TESTJK

SQL>
 select count(1) from testjk;

COUNT(1)
----------
72635
SQL>
SQL> truncate table testjk;

Table truncated.

SQL>
 alter session set nls_date_format=yyyy-mm-dd hh24:mi:ss;

Session altered.
--發(fā)現(xiàn)誤刪除后,趕快確認(rèn)當(dāng)前的系統(tǒng)時(shí)間:
SQL>
SQL> select sysdate from dual;

SYSDATE
-------------------
2022-06-29 23:29:17
這里需要drop掉,不然恢復(fù)的時(shí)候,是會(huì)報(bào)錯(cuò)說表存在:
SQL> drop table testjk;

Table dropped.
4.4 創(chuàng)建輔助實(shí)例的位置AUXILIARY destination /u01/tsbakdatapump destination /u01/dump的路徑
[oracle@12c u01]$ mkdir tsbak
[oracle@12c u01]$ mkdir dump
[oracle@12c u01]$ ls -l
總用量 0
drwxrwxr-x. 4 oracle oinstall 40 427 23:00 app
drwxr-xr-x 2 oracle oinstall 6 525 21:00 arch
drwxr-xr-x 7 oracle oinstall 117 127 2017 database
drwxr-xr-x 2 oracle oinstall 6 628 21:55 dump
drwxr-xr-x 2 oracle oinstall 6 629 23:34 tsbak
4.5 登錄RMAN工具,使用RMAN進(jìn)行恢復(fù)
注:紅色文字部分為批注。
RMAN> RECOVER TABLE pdbwjh.testjk of pluggable database prodpdb 恢復(fù)的語句,指定表所在的pdb
until time "to_date(2022-06-29 23:28:00,yyyy-mm-dd hh24:mi:ss)"
AUXILIARY destination /u01/tsbak
datapump destination /u01/dump;2> 3> 4>

Starting recover at 29-JUN-22
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=280 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 PRODPDB:SYSTEM
Tablespace UNDOTBS1
Tablespace PRODPDB:UNDOTBS1

Creating automatic instance, with SID=qsbb 創(chuàng)建了輔助實(shí)例,實(shí)例的SID為 qsbb

initialization parameters used for automatic instance:
db_name=PROD
db_unique_name=qsbb_pitr_prodpdb_PROD
compatible=12.2.0
db_block_size=8192
db_files=200
diagnostic_dest=/u01/app/oracle
_system_trig_enabled=FALSE
sga_target=1520M
processes=200
db_create_file_dest=/u01/tsbak 我指定的輔助實(shí)例存儲(chǔ)的位置
log_archive_dest_1=location=/u01/tsbak
enable_pluggable_database=true 是否是PDB,因?yàn)槲一謴?fù)的是PDB里面的表的數(shù)據(jù),所以這里是true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used


starting up automatic instance PROD

Oracle instance started

Total System Global Area 1593835520 bytes

Fixed Size 8793256 bytes
Variable Size 402654040 bytes
Database Buffers 1174405120 bytes
Redo Buffers 7983104 bytes
Automatic instance created

contents of Memory Script:
{
# set requested point in time
set until time "to_date(2022-06-29 23:28:00,yyyy-mm-dd hh24:mi:ss)"; 指定恢復(fù)的時(shí)間點(diǎn),也可以指定SCN
# 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-22
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=180 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/fast_recovery_area/prod/PROD/autobackup/2022_06_29/o1_mf_s_1108682570_kcrvlbmq_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/prod/PROD/autobackup/2022_06_29/o1_mf_s_1108682570_kcrvlbmq_.bkp tag=TAG20220629T232250
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/tsbak/PROD/controlfile/o1_mf_kcrwtxq4_.ctl
Finished restore at 29-JUN-22

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(2022-06-29 23:28:00,yyyy-mm-dd hh24:mi:ss)";
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile 1 to new;
set newname for clone datafile 9 to new;
set newname for clone datafile 4 to new;
set newname for clone datafile 11 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 10 to new;
set newname for clone tempfile 1 to new;
set newname for clone tempfile 3 to new;
set newname for clone tempfile 5 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 9, 4, 11, 3, 10;

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

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME
renamed tempfile 1 to /u01/tsbak/PROD/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 3 to /u01/tsbak/PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 5 to /u01/tsbak/PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_pdbwjh_t_%u_.tmp in control file

Starting restore at 29-JUN-22
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore 備份需要恢復(fù)的數(shù)據(jù)文件,可以理解為將備份集copy到輔助實(shí)例目錄下
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/tsbak/PROD/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/tsbak/PROD/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/tsbak/PROD/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/prod/PROD/backupset/2022_06_29/o1_mf_nnndf_TAG20220629T232230_kcrvkpbl_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/prod/PROD/backupset/2022_06_29/o1_mf_nnndf_TAG20220629T232230_kcrvkpbl_.bkp tag=TAG20220629T232230
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
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 00009 to /u01/tsbak/PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00011 to /u01/tsbak/PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00010 to /u01/tsbak/PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/prod/PROD/DDF44DDF02C79B34E053C82BA8C0429E/backupset/2022_06_29/o1_mf_nnndf_TAG20220629T232230_kcrvkxgh_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/prod/PROD/DDF44DDF02C79B34E053C82BA8C0429E/backupset/2022_06_29/o1_mf_nnndf_TAG20220629T232230_kcrvkxgh_.bkp tag=TAG20220629T232230
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-22

datafile 1 switched to datafile copy
input datafile copy RECID=10 STAMP=1108683881 file name=/u01/tsbak/PROD/datafile/o1_mf_system_kcrwv3g8_.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=11 STAMP=1108683881 file name=/u01/tsbak/PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_system_kcrwv6kh_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=12 STAMP=1108683881 file name=/u01/tsbak/PROD/datafile/o1_mf_undotbs1_kcrwv3gb_.dbf
datafile 11 switched to datafile copy
input datafile copy RECID=13 STAMP=1108683881 file name=/u01/tsbak/PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_undotbs1_kcrwv6kh_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=14 STAMP=1108683881 file name=/u01/tsbak/PROD/datafile/o1_mf_sysaux_kcrwv3gb_.dbf
datafile 10 switched to datafile copy
input datafile copy RECID=15 STAMP=1108683881 file name=/u01/tsbak/PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_sysaux_kcrwv6kg_.dbf

contents of Memory Script:
{
# set requested point in time
set until time "to_date(2022-06-29 23:28:00,yyyy-mm-dd hh24:mi:ss)";
# online the datafiles restored or switched
sql clone "alter database datafile 1 online";
sql clone PRODPDB "alter database datafile
9 online"
;
sql clone "alter database datafile 4 online";
sql clone PRODPDB "alter database datafile
11 online"
;
sql clone "alter database datafile 3 online";
sql clone PRODPDB "alter database datafile
10 online"
;
# recover and open database read only
recover clone database tablespace "SYSTEM", "PRODPDB":"SYSTEM", "UNDOTBS1", "PRODPDB":"UNDOTBS1", "SYSAUX", "PRODPDB":"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 9 online

sql statement: alter database datafile 4 online

sql statement: alter database datafile 11 online

sql statement: alter database datafile 3 online

sql statement: alter database datafile 10 online

Starting recover at 29-JUN-22
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 18 is already on disk as file /u01/app/oracle/fast_recovery_area/prod/PROD/archivelog/2022_06_29/o1_mf_1_18_kcrwcofv_.arc
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=17
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/prod/PROD/backupset/2022_06_29/o1_mf_annnn_TAG20220629T232247_kcrvl73l_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/prod/PROD/backupset/2022_06_29/o1_mf_annnn_TAG20220629T232247_kcrvl73l_.bkp tag=TAG20220629T232247
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/tsbak/1_17_1103578037.dbf thread=1 sequence=17
archived log file name=/u01/app/oracle/fast_recovery_area/prod/PROD/archivelog/2022_06_29/o1_mf_1_18_kcrwcofv_.arc thread=1 sequence=18
media recovery complete, elapsed time: 00:00:00
Finished recover at 29-JUN-22

sql statement: alter database open read only

contents of Memory Script:
{
sql clone alter pluggable database PRODPDB open read only;
}
executing Memory Script

sql statement: alter pluggable database PRODPDB 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 =
/u01/tsbak/PROD/controlfile/o1_mf_kcrwtxq4_.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 1593835520 bytes

Fixed Size 8793256 bytes
Variable Size 402654040 bytes
Database Buffers 1174405120 bytes
Redo Buffers 7983104 bytes

sql statement: alter system set  control_files = /u01/tsbak/PROD/controlfile/o1_mf_kcrwtxq4_.ctl comment= RMAN set scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 1593835520 bytes

Fixed Size 8793256 bytes
Variable Size 402654040 bytes
Database Buffers 1174405120 bytes
Redo Buffers 7983104 bytes

sql statement: alter database mount clone database

contents of Memory Script:
{
# set requested point in time
set until time "to_date(2022-06-29 23:28:00,yyyy-mm-dd hh24:mi:ss)";
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile 20 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 20;

switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

Starting restore at 29-JUN-22
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=162 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore 從備份集中進(jìn)行restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00020 to /u01/tsbak/QSBB_PITR_PRODPDB_PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_pdbwjh_d_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/prod/PROD/DDF44DDF02C79B34E053C82BA8C0429E/backupset/2022_06_29/o1_mf_nnndf_TAG20220629T232230_kcrvkxgh_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/prod/PROD/DDF44DDF02C79B34E053C82BA8C0429E/backupset/2022_06_29/o1_mf_nnndf_TAG20220629T232230_kcrvkxgh_.bkp tag=TAG20220629T232230
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 29-JUN-22

datafile 20 switched to datafile copy
input datafile copy RECID=17 STAMP=1108683941 file name=/u01/tsbak/QSBB_PITR_PRODPDB_PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_pdbwjh_d_kcrwx4ck_.dbf

contents of Memory Script:
{
# set requested point in time
set until time "to_date(2022-06-29 23:28:00,yyyy-mm-dd hh24:mi:ss)";
# online the datafiles restored or switched
sql clone PRODPDB "alter database datafile
20 online"
;
# recover and open resetlogs reostore后,進(jìn)行recover
recover clone database tablespace "PRODPDB":"PDBWJH_DATA", "SYSTEM", "PRODPDB":"SYSTEM", "UNDOTBS1", "PRODPDB":"UNDOTBS1", "SYSAUX", "PRODPDB":"SYSAUX" delete archivelog;
alter clone database open resetlogs; recover后,resetlogs打開數(shù)據(jù)庫實(shí)例
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile 20 online

Starting recover at 29-JUN-22
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 18 is already on disk as file /u01/app/oracle/fast_recovery_area/prod/PROD/archivelog/2022_06_29/o1_mf_1_18_kcrwcofv_.arc
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=17
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/prod/PROD/backupset/2022_06_29/o1_mf_annnn_TAG20220629T232247_kcrvl73l_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/prod/PROD/backupset/2022_06_29/o1_mf_annnn_TAG20220629T232247_kcrvl73l_.bkp tag=TAG20220629T232247
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/tsbak/1_17_1103578037.dbf thread=1 sequence=17
channel clone_default: deleting archived log(s)
archived log file name=/u01/tsbak/1_17_1103578037.dbf RECID=15 STAMP=1108683942
archived log file name=/u01/app/oracle/fast_recovery_area/prod/PROD/archivelog/2022_06_29/o1_mf_1_18_kcrwcofv_.arc thread=1 sequence=18
media recovery complete, elapsed time: 00:00:01
Finished recover at 29-JUN-22

database opened

contents of Memory Script:
{
sql clone alter pluggable database PRODPDB open;
}
executing Memory Script

sql statement: alter pluggable database PRODPDB open

contents of Memory Script:
{
# create directory for datapump import
sql PRODPDB "create or replace directory
TSPITR_DIROBJ_DPDIR as
/u01/dump"
;
# create directory for datapump export
sql clone PRODPDB "create or replace directory
TSPITR_DIROBJ_DPDIR as
/u01/dump"
;
}
executing Memory Script

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as /u01/dump    輔助實(shí)例恢復(fù)完后,將輔助實(shí)例中的數(shù)據(jù)文件以dump形式導(dǎo)出來,然后在導(dǎo)入到我們的pdb

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as /u01/dump     創(chuàng)建directory

Performing export of tables...
EXPDP> Starting "SYS"."TSPITR_EXP_qsbb_lgbr":
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 "PDBWJH"."TESTJK"                           9.614 MB 72635 rows 導(dǎo)出數(shù)據(jù)
EXPDP> Master table "SYS"."TSPITR_EXP_qsbb_lgbr" successfully loaded/unloaded
EXPDP> ******************************************************************************
EXPDP> Dump file set for SYS.TSPITR_EXP_qsbb_lgbr is:
EXPDP> /u01/dump/tspitr_qsbb_93806.dmp dump存放的路徑
EXPDP> Job "SYS"."TSPITR_EXP_qsbb_lgbr" successfully completed at Wed Jun 29 23:46:20 2022 elapsed 0 00:00:16
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_qsbb_feFA" successfully loaded/unloaded 導(dǎo)入到我們所需恢復(fù)的實(shí)例Pdb中
IMPDP> Starting "SYS"."TSPITR_IMP_qsbb_feFA":
IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
IMPDP> . . imported "PDBWJH"."TESTJK"                           9.614 MB 72635 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_qsbb_feFA" successfully completed at Wed Jun 29 23:46:38 2022 elapsed 0 00:00:12
Import completed


Removing automatic instance 導(dǎo)入成功后,輔助實(shí)例上的數(shù)據(jù)文件等都會(huì)被刪除
Automatic instance removed
auxiliary instance file /u01/tsbak/PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_pdbwjh_t_kcrwvh18_.tmp deleted
auxiliary instance file /u01/tsbak/PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_temp_kcrwvh0v_.tmp deleted
auxiliary instance file /u01/tsbak/PROD/datafile/o1_mf_temp_kcrwvf5y_.tmp deleted
auxiliary instance file /u01/tsbak/QSBB_PITR_PRODPDB_PROD/onlinelog/o1_mf_3_kcrwx85l_.log deleted
auxiliary instance file /u01/tsbak/QSBB_PITR_PRODPDB_PROD/onlinelog/o1_mf_2_kcrwx84h_.log deleted
auxiliary instance file /u01/tsbak/QSBB_PITR_PRODPDB_PROD/onlinelog/o1_mf_1_kcrwx83w_.log deleted
auxiliary instance file /u01/tsbak/QSBB_PITR_PRODPDB_PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_pdbwjh_d_kcrwx4ck_.dbf deleted
auxiliary instance file /u01/tsbak/PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_sysaux_kcrwv6kg_.dbf deleted
auxiliary instance file /u01/tsbak/PROD/datafile/o1_mf_sysaux_kcrwv3gb_.dbf deleted
auxiliary instance file /u01/tsbak/PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_undotbs1_kcrwv6kh_.dbf deleted
auxiliary instance file /u01/tsbak/PROD/datafile/o1_mf_undotbs1_kcrwv3gb_.dbf deleted
auxiliary instance file /u01/tsbak/PROD/DDF44DDF02C79B34E053C82BA8C0429E/datafile/o1_mf_system_kcrwv6kh_.dbf deleted
auxiliary instance file /u01/tsbak/PROD/datafile/o1_mf_system_kcrwv3g8_.dbf deleted
auxiliary instance file /u01/tsbak/PROD/controlfile/o1_mf_kcrwtxq4_.ctl deleted
auxiliary instance file tspitr_qsbb_93806.dmp deleted
Finished recover at 29-JUN-22

RMAN>
--恢復(fù)完畢后,查看數(shù)據(jù)庫數(shù)據(jù):
[oracle@12c ~]$ sqlplus pdbwjh/pdbwjh@prodpdb

SQL*Plus: Release 12.2.0.1.0 Production on Wed Jun 29 23:46:54 2022

Copyright (c) 1982, 2016, Oracle. All rights reserved.

Last Successful login time: Wed Jun 29 2022 23:26:35 +08:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>

SQL>
SQL>
SQL> select table_name from user_tables;

TABLE_NAME
--------------------------------------------------------------------------------
SQLLOADER_TEST01
TESTJK

SQL>
 select count(1) from testjk;

COUNT(1)
----------
72635

--數(shù)據(jù)表已恢復(fù)。

5

總結(jié)

需要注意的是:
  • 需要恢復(fù)的數(shù)據(jù)庫必須是歸檔模式;
  • 數(shù)據(jù)庫屬于讀寫模式;
  • 確保需要恢復(fù)的輔助實(shí)例所創(chuàng)建的目錄位置要有足夠的大小,否則恢復(fù)會(huì)報(bào)錯(cuò);
  • 如果是恢復(fù)PDB中的單個(gè)表,需要指定。

本文作者:王俊暉(上海新炬王翦團(tuán)隊(duì))

本文來源:“IT那活兒”公眾號(hào)

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://m.specialneedsforspecialkids.com/yun/129352.html

相關(guān)文章

  • Windows平臺(tái)下Oracle數(shù)據(jù)庫備份腳本

    摘要:以下腳本是我在項(xiàng)目工作中使用的備份腳本,腳本都是自己寫的。簡介此套腳本可以實(shí)現(xiàn)對數(shù)據(jù)庫實(shí)現(xiàn)全備份和增量備份。綜合以上兩種利弊,比較好的方式是在出現(xiàn)丟失備份或的情況下,通知管理員處置,手工處理之后備份腳本運(yùn)行恢復(fù)正常。 以下腳本是我在項(xiàng)目工作中使用的備份腳本,腳本都是自己寫的。但在使用過程中,感覺還有提供空間,我這個(gè)人有點(diǎn)懶,所以想用將腳本開源出來的方式督促自己完善這一套腳本。大家如果對...

    tomorrowwu 評論0 收藏0

發(fā)表評論

0條評論

最新活動(dòng)
閱讀需要支付1元查看
<