Wednesday, 16 March 2016

RECOVER LOST DATAFILE USING RMAN


-
Assume: “rmantest01” datafile removed from disk by rm command:

SQL> select file_name from dba_data_Files;

FILE_NAME
-------------------------------------------
/u01/app/oracle/oradata/rman/users01.dbf
/u01/app/oracle/oradata/rman/undotbs01.dbf
/u01/app/oracle/oradata/rman/sysaux01.dbf
/u01/app/oracle/oradata/rman/system01.dbf
/u01/app/oracle/oradata/rmantest01

SQL> create user ad identified by ad default tablespace rmantest;
User created.

SQL> grant connect , resource to ad;
Grant succeeded.

SQL> conn ad/ad;
Connected.
SQL> create table ad (id number(5));
Table created.

SQL> insert into ad values(01);
1 row created.

SQL> commit;
Commit complete.

Now , I will simulate an Error…
I will Remove the datafile with ‘rm’ command to simulate a disk crash


SQL> !rm /u01/app/oracle/oradata/rmantest01                                                                                                                                                                                              //Datafile Removed

Now , when User input some data in his Table,
We will get Error as Below
 

SQL> insert into ad values (3);
insert into ad values (3)
            *
ERROR at line 1:
ORA-01116: error in opening database file 6
ORA-01110: data file 6: '/u01/app/oracle/oradata/rmantest01'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3


> Now , Following things a DBA will do…

SQL> conn / as sysdba
Connected.

SQL> alter database datafile 6 offline;
Database altered.

SQL> !rman target /
RMAN> restore datafile 6;
RMAN> recover datafile 6;
RMAN> exit

SQL> alter database datafile 6 online;
Database altered.


Now , we just Restored our Datafile using RMAN, and Recoverd it with Archives
when user connects, He can work Smoothly J 

SQL> conn ad/ad;
Connected.

SQL> insert into ad values (3);
1 row created





No comments:

Post a Comment