4.模拟故障
SQL> conn hr/hr@192.168.133.120:1521/pdborcl
Connected.
SQL> drop table emp1 purge;
Table dropped.
SQL> select * from emp1;
select * from emp1
*
ERROR at line 1:
ORA-00942: table or view does not exist
5.执行基于时间点的表恢复
oracle@dbserver ~]$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Sun May 19 12:03:36 2024
Version 19.22.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCLCDB (DBID=2931055914)
RMAN> recover table hr.emp1 of pluggable database pdborcl
2> until time "to_date('2024-05-19 12:01:25','yyyy-mm-dd hh24:mi:ss')"
3> auxiliary destination '/tmp/aux';
Starting recover at 2024-05-19 12:04:31
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
RMAN-05026: warning: presuming following set of tablespaces applies to specified point-in-time
List of tablespaDO segments
Tablespace SYSTEMces expected to have UN
Tablespace PDBORCL:SYSTEM
Tablespace UNDOTBS1
Tablespace PDBORCL:UNDOTBS1
Creating automatic instance, with SID='dDme'
initialization parameters used for automatic instance:
db_name=ORCLCDB
db_unique_name=dDme_pitr_pdborcl_ORCLCDB
compatible=19.0.0
db_block_size=8192
db_files=200
diagnostic_dest=/u01/app/oracle
_pdb_name_case_sensitive=false
_system_trig_enabled=FALSE
sga_target=2240M
processes=200
db_create_file_dest=/tmp/aux
log_archive_dest_1='location=/tmp/aux'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used
contents of Memory Script:
{
# set requested point in time
set until time "to_date('2024-05-19 12:01:25','yyyy-mm-dd hh24: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
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('2024-05-19 12:01:25','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;
# 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;
renamed tempfile 1 to /tmp/aux/ORCLCDB/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 3 to /tmp/aux/ORCLCDB/107B00529A4E9350E0637885A8C036A8/datafile/o1_mf_temp_%u_.tmp in control file
Starting restore at 2024-05-19 12:04:54
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 /tmp/aux/ORCLCDB/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /tmp/aux/ORCLCDB/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /tmp/aux/ORCLCDB/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece +FRA/ORCLCDB/BACKUPSET/2024_05_19/nnndf0_tag20240519t114756_0.287.1169380077
channel ORA_AUX_DISK_1: piece handle=+FRA/ORCLCDB/BACKUPSET/2024_05_19/nnndf0_tag20240519t114756_0.287.1169380077 tag=TAG20240519T114756
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
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 /tmp/aux/ORCLCDB/107B00529A4E9350E0637885A8C036A8/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00011 to /tmp/aux/ORCLCDB/107B00529A4E9350E0637885A8C036A8/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00010 to /tmp/aux/ORCLCDB/107B00529A4E9350E0637885A8C036A8/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece +FRA/ORCLCDB/107B00529A4E9350E0637885A8C036A8/BACKUPSET/2024_05_19/nnndf0_tag20240519t114756_0.283.1169380107
channel ORA_AUX_DISK_1: piece handle=+FRA/ORCLCDB/107B00529A4E9350E0637885A8C036A8/BACKUPSET/2024_05_19/nnndf0_tag20240519t114756_0.283.1169380107 tag=TAG20240519T114756
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 2024-05-19 12:05:17
contents of Memory Script:
{
# set requested point in time
set until time "to_date('2024-05-19 12:01:25','yyyy-mm-dd hh24:mi:ss')";
# online the datafiles restored or switched
sql clone "alter database datafile 1 online";
sql clone 'PDBORCL' "alter database datafile
9 online";
sql clone "alter database datafile 4 online";
sql clone 'PDBORCL' "alter database datafile
11 online";
sql clone "alter database datafile 3 online";
sql clone 'PDBORCL' "alter database datafile
10 online";
# recover and open database read only
recover clone database tablespace "SYSTEM", "PDBORCL":"SYSTEM", "UNDOTBS1", "PDBORCL":"UNDOTBS1", "SYSAUX", "PDBORCL":"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 2024-05-19 12:05:18
using channel ORA_AUX_DISK_1
Executing: alter database datafile 7 offline
Executing: alter database datafile 5, 6, 8 offline
Executing: alter database datafile 12, 19, 20, 23, 24 offline
Executing: alter database datafile 13, 14, 15, 16, 17, 18 offline
starting media recovery
archived log for thread 1 with sequence 8 is already on disk as file /u01/app/oracle/arch_log/1_8_1169372078.dbf
archived log for thread 1 with sequence 9 is already on disk as file /u01/app/oracle/arch_log/1_9_1169372078.dbf
archived log for thread 1 with sequence 10 is already on disk as file /u01/app/oracle/arch_log/1_10_1169372078.dbf
archived log for thread 1 with sequence 11 is already on disk as file /u01/app/oracle/arch_log/1_11_1169372078.dbf
archived log file name=/u01/app/oracle/arch_log/1_8_1169372078.dbf thread=1 sequence=8
archived log file name=/u01/app/oracle/arch_log/1_9_1169372078.dbf thread=1 sequence=9
archived log file name=/u01/app/oracle/arch_log/1_10_1169372078.dbf thread=1 sequence=10
archived log file name=/u01/app/oracle/arch_log/1_11_1169372078.dbf thread=1 sequence=11
media recovery complete, elapsed time: 00:00:02
Finished recover at 2024-05-19 12:05:23
sql statement: alter database open read only
contents of Memory Script:
{
sql clone 'alter pluggable database PDBORCL open read only';
}
executing Memory Script
sql statement: alter pluggable database PDBORCL 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 =
''/tmp/aux/ORCLCDB/controlfile/o1_mf_m4lym160_.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
sql statement: alter database mount clone database
contents of Memory Script:
{
# set requested point in time
set until time "to_date('2024-05-19 12:01:25','yyyy-mm-dd hh24:mi:ss')";
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile 23 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 23;
contents of Memory Script:
{
# set requested point in time
set until time "to_date('2024-05-19 12:01:25','yyyy-mm-dd hh24:mi:ss')";
# online the datafiles restored or switched
sql clone 'PDBORCL' "alter database datafile
23 online";
# recover and open resetlogs
recover clone database tablespace "PDBORCL":"TSP_TEST1", "SYSTEM", "PDBORCL":"SYSTEM", "UNDOTBS1", "PDBORCL":"UNDOTBS1", "SYSAUX", "PDBORCL":"SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script
executing command: SET until clause
sql statement: alter database datafile 23 online
Starting recover at 2024-05-19 12:06:32
using channel ORA_AUX_DISK_1
Executing: alter database datafile 7 offline
Executing: alter database datafile 5, 6, 8 offline
Executing: alter database datafile 12, 19, 20, 24 offline
Executing: alter database datafile 13, 14, 15, 16, 17, 18 offline
starting media recovery
archived log for thread 1 with sequence 8 is already on disk as file /u01/app/oracle/arch_log/1_8_1169372078.dbf
archived log for thread 1 with sequence 9 is already on disk as file /u01/app/oracle/arch_log/1_9_1169372078.dbf
archived log for thread 1 with sequence 10 is already on disk as file /u01/app/oracle/arch_log/1_10_1169372078.dbf
archived log for thread 1 with sequence 11 is already on disk as file /u01/app/oracle/arch_log/1_11_1169372078.dbf
archived log file name=/u01/app/oracle/arch_log/1_8_1169372078.dbf thread=1 sequence=8
archived log file name=/u01/app/oracle/arch_log/1_9_1169372078.dbf thread=1 sequence=9
archived log file name=/u01/app/oracle/arch_log/1_10_1169372078.dbf thread=1 sequence=10
archived log file name=/u01/app/oracle/arch_log/1_11_1169372078.dbf thread=1 sequence=11
media recovery complete, elapsed time: 00:00:01
Finished recover at 2024-05-19 12:06:35