Check DATAFILES
[code]
SQL> select file_id,tablespace_name,file_name from dba_data_files;
FILE_ID TABLESPACE_NAME FILE_NAME
---------- ------------------------ ---------------------------------------------
1 SYSTEM /u01/app/oracle/oradata/ORCL1/system01.dbf
3 SYSAUX /u01/app/oracle/oradata/ORCL1/sysaux01.dbf
4 UNDOTBS1 /u01/app/oracle/oradata/ORCL1/undotbs01.dbf
7 USERS /u01/app/oracle/oradata/ORCL1/users01.dbf
13 GG_TBS /u01/app/oracle/oradata/OGG/datafile/gg_cdb.dbf
15 ENCRYPT_TEST /u01/app/oracle/oradata/ORCL1/encrypt_test.dbf
6 rows selected.
SQL>
[/code]
Create sample table and try to insert some records
[code]
SQL> create table sample(description varchar2(100)) tablespace users;
Table created.
SQL> insert into sample values ('#####INSERT - BEFORE BACKUP#####');
1 row created.
SQL> commit;
Commit complete.
[/code]
Backup datafile USERS
[code]
RMAN> backup datafile 7;
Starting backup at 18-APR-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=184 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/u01/app/oracle/oradata/ORCL1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 18-APR-20
channel ORA_DISK_1: finished piece 1 at 18-APR-20
piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/07uu03n8_1_1 tag=TAG20200418T232735 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 18-APR-20
Starting Control File and SPFILE Autobackup at 18-APR-20
piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/c-1414679838-20200418-02 comment=NONE
Finished Control File and SPFILE Autobackup at 18-APR-20
RMAN> quit
Recovery Manager complete.
[/code]
After backup try to insert one more record
[code]
SQL> insert into sample values ('#####INSERT - AFTER BACKUP#####');
1 row created.
SQL> commit;
Commit complete.
[/code]
Now shutdown database and remove datafile USERS
[code]
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> quit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
[oracle@orcl19c ~]$ rm -rf /u01/app/oracle/oradata/ORCL1/users01.dbf
[/code]
Try to start database
[code]
SQL> startup
ORACLE instance started.
Total System Global Area 893385440 bytes
Fixed Size 9140960 bytes
Variable Size 234881024 bytes
Database Buffers 641728512 bytes
Redo Buffers 7634944 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/u01/app/oracle/oradata/ORCL1/users01.dbf'
[/code]
We need to restore and recover the datafile USERS and OPEN the database
[code]
RMAN> RESTORE DATAFILE 7;
Starting restore at 18-APR-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=16 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/ORCL1/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/19.0.0/dbhome_1/dbs/07uu03n8_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/07uu03n8_1_1 tag=TAG20200418T232735
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 18-APR-20
RMAN> RECOVER DATAFILE 7;
Starting recover at 18-APR-20
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 18-APR-20
RMAN> ALTER DATABASE OPEN;
Statement processed
[/code]
Check the database status and records in sample table
[code]
RMAN> RESTORE DATAFILE 7;
Starting restore at 18-APR-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=16 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/ORCL1/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/19.0.0/dbhome_1/dbs/07uu03n8_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/product/19.0.0/dbhome_1/dbs/07uu03n8_1_1 tag=TAG20200418T232735
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 18-APR-20
RMAN> RECOVER DATAFILE 7;
Starting recover at 18-APR-20
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 18-APR-20
RMAN> ALTER DATABASE OPEN;
Statement processed
RMAN> QUIT
Recovery Manager complete.
[oracle@orcl19c ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Apr 18 23:35:29 2020
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> select * from sample;
DESCRIPTION
---------------------------------------
#####INSERT - BEFORE BACKUP#####
#####INSERT - AFTER BACKUP#####
SQL>
[/code]




No comments:
Post a Comment