Rman backup recovery Guide

Source: Internet
Author: User

Environment Introduction:
Operating system version: RHEL5.4 32-bit
Oracle version: 10.2.0.1 32-bit
Oracle_SID: orcl
The operating system of the source server and target server is consistent with that of oracle.

Source server: 192.168.227.20
Target Server: 192.168.227.30. You only need to install the oracle software.

I. Use rman on the source server to back up the database, including data files, archived log files, control files, and parameter files.

 
 
  1. [oracle@orcl ~]$ mkdir /u01/backup  
  2. [oracle@orcl ~]$ rman target /  
  3. Recovery Manager: Release 10.2.0.1.0 - Production on Tue Sep 6 16:04:53 2011  
  4. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  5. connected to target database: ORCL (DBID=1287906064)  
  6.  
  7. RMAN> run {   
  8. 2> allocate channel c1 device type disk;  
  9. 3> backup incremental level 0    
  10. 4> format '/u01/backup/db_full_%U.bkp'    
  11. 5> tag '2011-09-06-FULL'  
  12. 6> database plus archivelog;  
  13. 7> release channel c1;  
  14. 8> }  
  15. RMAN> backup current controlfile format '/u01/backup/control20110906.bak';  
  16. RMAN> backup spfile format '/u01/backup/spfile20110906.bak'; 

2. Copy the backup data on the target server and prepare the relevant directories.

 
 
  1. [oracle@orcl ~]$ mkdir /u01/backup  
  2. [oracle@orcl ~]$ scp -rp 192.168.227.20:/u01/backup/* /u01/backup/  
  3. oracle@192.168.227.20's password:   
  4. control20110906.bak                           100% 6944KB   1.7MB/s   00:04      
  5. db_full_0fmlsmdt_1_1.bkp                      100%   97MB   4.4MB/s   00:22      
  6. db_full_0gmlsme5_1_1.bkp                      100%  593MB   9.1MB/s   01:05      
  7. db_full_0hmlsmg7_1_1.bkp                      100% 6656     6.5KB/s   00:00    
  8. spfile20110906.bak                            100%   96KB  96.0KB/s   00:00   
  9.  
  10. [oracle@orcl ~]$ mkdir -p /u01/app/oracle/admin/orcl/{adump,bdump,cdump,dpdump,udump,pfile}  
  11. [oracle@orcl ~]$ mkdir -p /u01/app/oracle/oradata/orcl  
  12. [oracle@orcl ~]$ mkdir -p /u01/app/oracle/flash_recover_area/ORCL 

Iii. recovery on the target server

 
 
  1. [Oracle @ orcl ~] $ Echo'Db_name=Orcl'>$ ORACLE_HOME/dbs/initorcl. ora
  2. [Oracle @ orcl ~] $ ExportORACLE_SID=Orcl 
  3. [Oracle @ orcl ~] $ Rman target/
  4. Recovery Manager: Release 10.2.0.1.0-Production on Tue Sep 6 16:18:19 2011
  5. Copyright (c) 1982,200 5, Oracle. All rights reserved.
  6. Connected to target database (not started)
  7.  
  8. RMAN>Set dbid 1287906064; // specify the DBID, which must be consistent with the DBID of the source server.
  9. RMAN>Startup nomount; // start the database to the nomount state. here you need to create the initorcl. ora file before, or an error will be reported.
  10. RMAN>Restore spfile from '/u01/backup/spfile20110906.bak'; // restore the parameter file
  11. RMAN>Startup nomount force; // restart the instance to the nomout status.
  12. RMAN>Restore controlfile from '/u01/backup/control20110906.bak'; // restore control file
  13. RMAN>Recover database; // Restore database files
  14. RMAN>Recover database; // restore the database file. An error is reported here.
  15. RMAN-03002: failure of recover command at 17:03:51
  16. RMAN-06054: media recovery requesting unknown log: thread 1 seq 15 lowscn 547974
  17. RMAN>Exit
  18.  
  19. [Oracle @ orcl ~] $ Sqlplus/nolog // perform the until cancel Operation on the database in sqlplus and enable it in resetlogs mode.
  20. SQL * Plus: Release 10.2.0.1.0-Production on Tue Sep 6 17:04:22 2011
  21. Copyright (c) 1982,200 5, Oracle. All rights reserved.
  22.  
  23. SQL>Conn/as sysdba
  24. Connected.
  25. SQL>Recover database using backup controlfile until cancel;
  26. ORA-00279: change 547974 generated at 16:49:11 needed for thread 1
  27. ORA-00289: suggestion:
  28. /U01/app/oracle/flash_recovery_area/ORCL/archivelog/20151109_06/o2017mf_000015 _ % u _. ar
  29. C
  30. ORA-00280: change 547974 for thread 1 is in sequence #15
  31.  
  32.  
  33. Specify log :{<RET>= Suggested | filename | AUTO | CANCEL}
  34. Cancel
  35. Media recovery canceled.
  36. SQL>Alter database open resetlogs;

Iv. Test

 
 
  1. SQL> select member from v$logfile;  
  2.  
  3. MEMBER  
  4. --------------------------------------------------------------------------------  
  5. /u01/app/oracle/oradata/orcl/redo03.log  
  6. /u01/app/oracle/oradata/orcl/redo02.log  
  7. /u01/app/oracle/oradata/orcl/redo01.log  
  8.  
  9. SQL> select file_name from dba_data_files;  
  10.  
  11. FILE_NAME  
  12. --------------------------------------------------------------------------------  
  13. /u01/app/oracle/oradata/orcl/users01.dbf  
  14. /u01/app/oracle/oradata/orcl/sysaux01.dbf  
  15. /u01/app/oracle/oradata/orcl/undotbs01.dbf  
  16. /u01/app/oracle/oradata/orcl/system01.dbf  
  17. /u01/app/oracle/oradata/orcl/example01.dbf  
  18. /u01/app/oracle/oradata/orcl/tbs_apple01.dbf  
  19. 6 rows selected.  
  20.  
  21.  
  22. SQL> select count(*) from dba_temp_files;  
  23.   COUNT(*)  
  24. ----------  
  25.          1  
  26.  
  27. SQL> select count(*) from hr.employees;  
  28.  
  29.   COUNT(*)  
  30. ----------  
  31.        107 

5. Notes

 
 
  1. RMAN>List incarnation; // generate a new incarnation
  2. Using target database control file instead of recovery catalog
  3.  
  4. List of Database Incarnations
  5. DB Key Inc Key DB Name db id status Reset SCN Reset Time
  6. -------------------------------------------------------------
  7. 1 1 ORCL 1287906064 PARENT 1 2005-06-30: 19: 09: 40
  8. 2 2 ORCL 1287906064 PARENT 446075: 17: 55: 31
  9. 3 3 ORCL 1287906064 CURRENT 547975 2011-09-06: 17: 07: 09
  10.  
  11. [Oracle @ orcl ~] $ Emctl start dbconsole // dbconsole needs to be reconfigured, And the orapwd file also needs to be created
  12. TZ set to PRC
  13. Productname Configuration issue./u01/app/oracle/product/10.2.0/db_1/Solaris/j2ee/OC4J_DBConsole_orcl.herostart.com_orcl not found

Vi. Incremental Backup Recovery from different machines
1: source server

 
 
  1. SQL> create user rman_inr identified by "123456" default tablespace users;  
  2. User created.  
  3. SQL> grant connect,resource to rman_inr;  
  4. Grant succeeded.  
  5. SQL> create table rman_inr.test as select * from dba_source;  
  6. Table created.  
  7.  
  8. RMAN> backup incremental level 1   
  9. 2> format '/u01/backup/inr1_db_%U' tag 'inr_1'  
  10. 3> database plus archivelog;  
  11.  
  12. [oracle@orcl ~]$ rman target /  
  13. RMAN> backup incremental level 1   
  14. 2> format '/u01/backup/inr1_db_%U' tag 'inr_1'  
  15. 3> database plus archivelog;  
  16.  
  17. RMAN> backup current controlfile format '/u01/backup/control02.bak';  
  18.  
  19. [oracle@orcl ~]$ ls -lh /u01/backup/inr1_db_1*  
  20. -rw-r----- 1 oracle oinstall  53M Sep  8 16:34 /u01/backup/inr1_db_1omm1ud0_1_1  
  21. -rw-r----- 1 oracle oinstall  51M Sep  8 16:35 /u01/backup/inr1_db_1pmm1udk_1_1  
  22. -rw-r----- 1 oracle oinstall 6.9M Sep  8 16:35 /u01/backup/inr1_db_1qmm1uf2_1_1  
  23. -rw-r----- 1 oracle oinstall  11K Sep  8 16:35 /u01/backup/inr1_db_1rmm1uf5_1_1  
  24.  
  25. [oracle@orcl ~]$ scp /u01/backup/inr1_db_1* 192.168.227.30:/u01/backup/  
  26. [oracle@orcl ~]$ scp /u01/backup/control02.bak 192.168.227.30:/u01/backup/    

2: Target Server

 
 
  1. [oracle@orcl ~]$ sqlplus /nolog  
  2. SQL> conn /as sysdba  
  3. Connected.  
  4. SQL> shutdown immediate;    
  5.  
  6. RMAN> set dbid=1287906064;  
  7. RMAN> startup nomount;  
  8. RMAN> restore controlfile from '/u01/backup/control02.bak';  
  9. RMAN> startup mount force;  
  10.  
  11. RMAN> restore database;  
  12. RMAN> recover database;  
  13. RMAN-03002: failure of recover command at 09/08/2011 16:46:44  
  14. RMAN-06054: media recovery requesting unknown log: thread 1 seq 45 lowscn 598452  
  15. RMAN> exit  
  16.  
  17. [oracle@orcl ~]$ sqlplus /nolog  
  18. SQL> conn /as sysdba  
  19.  
  20. SQL> recover database using backup controlfile until cancel;  
  21. ORA-00279: change 598452 generated at 09/08/2011 16:35:49 needed for thread 1  
  22. ORA-00289: suggestion : /u01/arch/orcl/1_45_760125331.arc  
  23. ORA-00280: change 598452 for thread 1 is in sequence #45  
  24.  
  25. Specify log: {<RET>=suggested | filename | AUTO | CANCEL}  
  26. cancel  
  27. Media recovery cancelled.  
  28.  
  29. SQL> alter database open resetlogs;  
  30. Database altered. 

3: Test

 
 
  1. SQL> conn rman_inr/123456  
  2. Connected  
  3.  
  4. SQL> select count(*) from test;  
  5.  
  6.   COUNT(*)  
  7. ----------  
  8.     292428 

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.