All technological notes.
Complete Recovery: ARCHIVELOG Mode - PDBComplete Recovery: ARCHIVELOG Mode - PDB
SYSTEM or UNDO TablespacePrerequisites:
PLUGGABLE DATABASEARCHIVELOG mode.Characteristics:
Step to recover SYSTEM or UNDO TBSP
Shut down the PDB with the ABORT option if it is not automatically done.
tablespace or the damaged datafile.Features:
ABORT mode forcefully closes it without bringing down the entire CDB instance.关闭 pdb,而不是整个 CDB.If the datafile that is missing or corrupted belongs to a PDB and more specifically to the SYSTEM or UNDO tablespace, 缺失关键文件时, 必须 ABORT 关闭.
ABORT mode.A PDB, tablespace, or datafile media recovery is required.
PDB is the application root of an application container, other datafiles in the application PDBs may have to be restored and recovered as well. 如果 PDB 是根, 其他 df 需要恢复.Example:
-- close pdb
rman target "'sys@pdb_name'"
SHUTDOWN ABORT
-- restore and recover
RESTORE DATABASE;
RECOVER DATABASE;
-- open pdb
STARTUP
SYSTEM datafile in PDB-- Create tbsp in pdb
alter session set container=orclpdb;
-- CLEANUP from previous run
DROP USER bar91 CASCADE;
DROP TABLESPACE bar91tbs INCLUDING CONTENTS AND DATAFILES;
-- Create tablespace
CREATE TABLESPACE bar91tbs
DATAFILE '/u01/app/oracle/oradata/ORCL/orclpdb/bar91tbs01.dbf' SIZE 10M
SEGMENT SPACE MANAGEMENT MANUAL;
-- Create user
CREATE USER bar91 IDENTIFIED BY pass4B91
DEFAULT TABLESPACE bar91tbs
QUOTA UNLIMITED ON bar91tbs;
GRANT CREATE SESSION TO bar91;
-- create table and populate
-- be sure table is at least 2 blocks long
CREATE TABLE bar91.barcopy
TABLESPACE bar91tbs
AS SELECT * FROM HR.EMPLOYEES;
INSERT INTO bar91.BARCOPY
SELECT * FROM bar91.BARCOPY;
INSERT INTO bar91.BARCOPY
SELECT * FROM bar91.BARCOPY;
rman target "'sys@orclpdb as sysdba'"
BACKUP PLUGGABLE DATABASE ORCLPDB;
sqlplus / as sysdba
alter session set container=orclpdb;
UPDATE bar91.BARCOPY SET salary = salary+1;
COMMIT;
rm /u01/app/oracle/oradata/ORCL/orclpdb/system01.dbf
rman target sys@orclpdb
-- close pdb
SQL "ALTER PLUGGABLE DATABASE orclpdb CLOSE ABORT";
-- restore and recover df
RESTORE DATAFILE 9;
RECOVER DATAFILE 9;
-- open pdb
SQL "ALTER PLUGGABLE DATABASE orclpdb OPEN";


ls -al /u01/app/oracle/oradata/ORCL/orclpdb/system01.dbf
recreate loss of critical datafile
Confirm failure in sqlplus
rman target "'/ as sysdba'"
ALTER PLUGGABLE DATABASE orclpdb CLOSE ABORT;
LIST FAILURE;
ADVISE FAILURE;
-- generate a script with all repair actions and comments.
REPAIR FAILURE PREVIEW;
-- repair database failures
REPAIR FAILURE;
-- will ask whether open the db
ALTER PLUGGABLE DATABASE orclpdb OPEN;


complete recovery is possible as long as you have all available backups required.
archive log files required to recover the restored data file up to the current SCN of the PDB including all redo log files (one member in each group will be sufficient).RMAN is the best utility to recover data.
RESTORE and RECOVER commands.LIST FAILURE commands.REPAIR command.SYSTEM Tablespace RecoveryStep to recover Non-SYSTEM TBSP
OFFLINE IMMEDIATE.Media recovery for that datafile is requiredFeatures:
PDB and more specifically to any tablespace other than SYSTEM tablespace,
rm /u01/app/oracle/oradata/ORCL/orclpdb/bar91tbs01.dbf
-- rman
rman target "'sys@orclpdb as sysdba'"
REPORT SCHEMA;
-- close pdb immediate
SHUTDOWN IMMEDIATE;
-- restore and recover
RESTORE DATABASE;
RECOVER DATABASE;
-- open pdb
STARTUP



rman target "'/ as sysdba'"
LIST FAILURE;
ADVISE FAILURE;
-- generate a script with all repair actions and comments.
REPAIR FAILURE PREVIEW;
-- repair database failures
REPAIR FAILURE;
-- will ask whether open the db
ALTER PLUGGABLE DATABASE orclpdb OPEN;



REPAIR command:REPAIR command:
Example:
-- rman
CONNECT TARGET /
REPAIR REPAIR pdb_name:tbsp_name;
-- sqlplus
CONNECT system@sales_pdb
ALTER TABLESPACE tbs2 OFFLINE IMMEDIATE;
-- rman
CONNECT TARGET /
RESTORE TABLESPACE sales_pdb:tbs2;
RECOVER TABLESPACE sales_pdb:tbs2;
-- sqlplus
ALTER TABLESPACE tbs2 ONLINE;
rman target "'/ as sysdba'"
REPORT SCHEMA;
-- close pdb immediate
ALTER PLUGGABLE DATABASE orclpdb CLOSE IMMEDIATE;
-- restores and recovers the data file.
REPAIR PLUGGABLE DATABASE ORCLPDB;
ALTER PLUGGABLE DATABASE orclpdb OPEN;



TempfileMissing of a tempfile belonging to a PDB temporary tablespace
Solution:
Can add or drop tempfile:
-- When connecting with PDB
-- add new tempfile
ALTER TABLESPACE temp ADD TEMPFILE
'/u0l/app/oracle/oradata/CDB1/HR_PDB/temp2_02.dbf"'
SIZE 20M;
-- drop missing tempfile
ALTER TABLESPACE temp DROP TEMPFILE
'/u0l/app/oracle/oradata/CDB1/HR_PDB/temp2_01.dbf';