All technological notes.
Complete Recovery: ARCHIVELOG Mode - CDBComplete Recovery: ARCHIVELOG Mode - CDB
Noncritical data file:
SYSTEM or UNDO tablespaceBecause the database is in ARCHIVELOG mode,
SYSTEM datafile in CDB# remove system df from CDB
rm '/u01/app/oracle/oradata/ORCL/system01.dbf'
-- connect
connect system
-- ERROR:
-- ORA-00604: error occurred at recursive SQL level 1
-- ORA-01116: error in opening database file 1
-- ORA-01110: data file 1: '/u01/app/oracle/oradata/ORCL/system01.dbf'
-- ORA-27041: unable to open file
-- Linux-x86_64 Error: 2: No such file or directory
-- Additional information: 3
A: A complete recovery is possible.
A: RMAN is the best utility to recover data.
RESTORE and RECOVER commandsLIST FAILURE command.Determine the state of the database to choose the course of action in the next step.
SQL*Plus login displays “ORA-01034: ORACLE not available”, then the database instance is down.
STARTUP MOUNT to mount database.SQL*Plus login displays an error that includes “ORA-01116: error in opening database file 1”, then database instance is still running, but impaired and must be terminated with shutdown abort.
Shutdown abort to shutdown instancerman target / command shows an error and immediately disconnects then the database instance is down.rman target /
SHUTNDOWN ABORT
STARTUP MOUNT
-- restore and recover system01.dbf
RESTORE DATAFILE 1;
RECOVER DATAFILE 1;
-- Open db
ALTER DATABASE OPEN;

sqlplus /nolog
connect system
show con_name
show user

recreate loss of critical datafile
Confirm failure in sqlplus
sqlplus / as sysdba
select username from dba_users;
-- select username from dba users
*
-- ERROR at line 1:
-- ORA-00604: error occurred at recursive SQL level 1
-- ORA-01116: error in opening database file 1
-- ORA-01110: data file 1: '/u01/app/oracle/oradata/ORCL/system01.dbf'
-- ORA-27041: unable to open file
-- Linux-x86_64 Error: 2: No such file or directory
-- Additional information: 3


rman target /
shutdown abort
startup mount
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

sqlplus /nolog
connect system
show con_name
show user

Critical data file
SYSTEM tablespace or containing UNDO dataA loss of one of critical data file requires the database to be restored from the MOUNT state. 需要 mount
Steps:
The instance may or may not shut down automatically.
SHUTDOWN ABORT to bring the instance down.# remove user df from CDB
rm '/u01/app/oracle/oradata/ORCL/users01.dbf'
-- query and create user can be executed.
SELECT username FROM cdb_users;
rman target /
ALTER TABLESPACE users OFFLINE IMMEDIATE;
-- rman
RESTORE DATAFILE 7;
RECOVER DATAFILE 7;
-- sqlplus
ALTER TABLESPACE users ONLINE;

ls -al '/u01/app/oracle/oradata/ORCL/users01.dbf'
recreate loss of critical datafile
Confirm failure in sqlplus
rman target /
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
