Oracle-RMAN full recovery

Source: Internet
Author: User

Oracle-RMAN full recovery 1. concepts related to RMAN full recovery 1. mainly two commands are used in RMAN full recovery, one is restore and the other is recover. 2. Data can be restored at three levels: database, tablespace, and data file. 3. In RMAN, you can use the user management recovery command to help solve the problem in various situations. Ii. RMAN full recovery experiment (1) Use RMAN to perform three backups of the data file app1_01.dbf. One is full backup, the other is level 0 backup, and the other is Level 1 backup. 1. Complete backup of data files. The command is as follows,

RMAN> backup datafile  '/u01/oradata/wilson/app1_01.dbf' format '/u01/backup/app1_%U';

 

2. Perform level 0 backup. The command is as follows,
RMAN> backup incremental level 0  datafile '/u01/oradata/wilson/app1_01.dbf'  format '/u01/backup/all_0_%U';

 

3. Perform Level 1 backup. The command is as follows,
RMAN> backup incremental level 1  datafile '/u01/oradata/wilson/app1_01.dbf'  format '/u01/backup/all_1_%U';

 

4. Close the database and delete the data file append 01.dbf,
[oracle@oracle11g wilson]$ rm   -f    app1_01.dbf

 

5. Place the database in the mount state, connect RMAN, restore and restore data files, and open the database,
RMAN> restore   datafile  ‘/u01/oradata/wilson/app1_01.dbf’;Starting restore at 01-SEP-13using channel ORA_DISK_1channel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00012 to /u01/oradata/wilson/app1_01.dbfchannel ORA_DISK_1: reading from backup piece /u01/backup/all_0_04oiptg4_1_1channel ORA_DISK_1: piece handle=/u01/backup/all_0_04oiptg4_1_1 tag=TAG20130901T230228channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:08Finished restore at 01-SEP-13

 

Through the restore command, we can see that the database uses level 0 backup preferentially during restoration.
RMAN> recover   datafile   ‘/u01/oradata/wilson/app1_01.dbf’;RMAN> alter database open;database opened

 

(2) In the (1) experiment, the restored data file is still in the original directory. If the disk is damaged, it cannot be stored in the original directory. What should I do? 1. Close the database, delete a data file, and restore it to another directory,
[Oracle @ oracle11g wilson] $ rm-f append 01.dbf (delete the append 01.dbf data file)

 

2. Open the database and go to the mount status. You can check the views v $ recover_file and v $ datafile to determine which file is faulty,
SQL> select * from v$recover_file;     FILE# ONLINE  ONLINE_ ERROR                 CHANGE# TIME---------- ------- ------- ------------------ ---------- ---------         12 ONLINE  ONLINE  FILE NOT FOUND              0SQL> select file#,name from v$datafile;     FILE# NAME---------- -----------------------------------         1 /u01/oradata/wilson/system01.dbf         2 /u01/oradata/wilson/sysaux01.dbf         3 /u01/oradata/wilson/undotbs01.dbf         4 /u01/oradata/wilson/users01.dbf         5 /u01/oradata/wilson/example01.dbf         6 /u01/oradata/wilson/app2_01.dbf         7 /u01/oradata/wilson/app3_01.dbf         8 /u01/oradata/wilson/smallundo1.dbf        12 /u01/oradata/wilson/app1_01.dbf9 rows selected.

 

It can be seen that the file number is 12. 3. Restore and restore the data file on the RMAN connection,
RMAN> run {2> set newname for datafile 12 to '/u01/oradata/app1_01.dbf'; (restore file No. 12 to another directory) 3> restore datafile 12; 4> switch datafile 12; (Use this command to update the control file) 5> recover datafile 12; 6> alter database open ;}

 

So you can see this file in/u01/oradata,
[oracle@oracle11g oradata]$ lltotal 102540-rw-r----- 1 oracle oinstall 104865792 Sep  1 23:51 app1_01.dbf

 

Restore the data file to another directory. (3) Restore tablespace 1. Delete the app1_01.dbf file when the database is open,
[oracle@oracle11g wilson]$ rm   -f     app1_01.dbf 

 

To view the table Dave. t,
SQL> select * from Dave.t;select * from Dave.t                   *ERROR at line 1:ORA-01116: error in opening database file 12ORA-01110: data file 12: '/u01/oradata/wilson/app1_01.dbf'ORA-27041: unable to open fileLinux Error: 2: No such file or directoryAdditional information: 3

 

Because the data file does not exist, it cannot be found. At this time, the view v $ recover_file does not have any records. You must shutdown abort to close the database and then open the data to the mount status. Then you can view the view v $ recover_file to see it,
SQL> select * from  v$recover_file;     FILE# ONLINE  ONLINE_ ERROR                 CHANGE# TIME---------- ------- ------- ------------------ ---------- ---------               12 ONLINE  ONLINE  FILE NOT FOUND              0

 

It can be seen that the file number is 12. 2. Connect to RMAN to restore the data file,
RMAN> run{2> sql 'alter database datafile 12  offline';3> restore tablespace app1;4> recover tablespace app1;5> sql 'alter  database  datafile 12  online';}

 

After the recovery is successful, check the table Dave. t,
SQL> select *  from Dave.t;        ID NAME---------- -----------------------------------         3 wound         4 mm         0 Dave.Sun         1 sunshine         2 sunny

 

As you can see, the tablespace is successfully restored. In the preceding example, the restored tablespace is still in the original directory. If the disk is damaged, it cannot be stored in the original directory. What should I do? The method provided in (2) is the same. You only need to change the data file to a tablespace.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.