概念
在Oracle数据库中,对于用户DDL(DROP TRUNCATE)等误操作,引起的数据丢失,恢复的手段有:
恢复的目的
如果是 delete 的误操作,如果在闪回范围时间内,可以用闪回来恢复。
恢复的要求
--步骤
通过datapump工具导出,导入。
恢复实验过程
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.
grant connect,resource to pdbwjh;
grant CREATE TABLE to pdbwjh;
grant SELECT ANY TABLE to pdbwjh;
grant UNLIMITED TABLESPACE to pdbwjh;
create tablespace pdbwjh_data logging datafile /u01/app/oracle/oradata/prod/prodpdb/pdbwjh_data01.dbf size 100M autoextend off;
create temporary tablespace pdbwjh_temp tempfile /u01/app/oracle/oradata/prod/prodpdb/pdbwjh_tmp.dbf size 30M autoextend off;
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
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.
[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
[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.
SQL>
SQL> select sysdate from dual;
SYSDATE
-------------------
2022-06-29 23:29:17
SQL> drop table testjk;
Table dropped.
[oracle@12c u01]$ mkdir tsbak
[oracle@12c u01]$ mkdir dump
[oracle@12c u01]$ ls -l
总用量 0
drwxrwxr-x. 4 oracle oinstall 40 4月 27 23:00 app
drwxr-xr-x 2 oracle oinstall 6 5月 25 21:00 arch
drwxr-xr-x 7 oracle oinstall 117 1月 27 2017 database
drwxr-xr-x 2 oracle oinstall 6 6月 28 21:55 dump
drwxr-xr-x 2 oracle oinstall 6 6月 29 23:34 tsbak
RMAN> RECOVER TABLE pdbwjh.testjk of pluggable database prodpdb 恢复的语句,指定表所在的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 创建了辅助实例,实例的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 我指定的辅助实例存储的位置
log_archive_dest_1=location=/u01/tsbak
enable_pluggable_database=true 是否是PDB,因为我恢复的是PDB里面的表的数据,所以这里是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)"; 指定恢复的时间点,也可以指定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 备份需要恢复的数据文件,可以理解为将备份集copy到辅助实例目录下
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 从备份集中进行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后,进行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打开数据库实例
}
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 辅助实例恢复完后,将辅助实例中的数据文件以dump形式导出来,然后在导入到我们的pdb
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as /u01/dump 创建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 导出数据
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 导入到我们所需恢复的实例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 导入成功后,辅助实例上的数据文件等都会被删除
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>
[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
--数据表已恢复。
总结
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/129352.html
摘要:以下脚本是我在项目工作中使用的备份脚本,脚本都是自己写的。简介此套脚本可以实现对数据库实现全备份和增量备份。综合以上两种利弊,比较好的方式是在出现丢失备份或的情况下,通知管理员处置,手工处理之后备份脚本运行恢复正常。 以下脚本是我在项目工作中使用的备份脚本,脚本都是自己写的。但在使用过程中,感觉还有提供空间,我这个人有点懒,所以想用将脚本开源出来的方式督促自己完善这一套脚本。大家如果对...
阅读 1347·2023-01-11 13:20
阅读 1685·2023-01-11 13:20
阅读 1133·2023-01-11 13:20
阅读 1860·2023-01-11 13:20
阅读 4101·2023-01-11 13:20
阅读 2705·2023-01-11 13:20
阅读 1386·2023-01-11 13:20
阅读 3598·2023-01-11 13:20