Backup and recovery of databases in the Dataguard Environment

Source: Internet
Author: User

After the active data guard is deployed, the read-only query can be handed over to the standby database for execution, and the routine database backup work can be performed on the standby database to relieve the pressure on the primary database, make full use of server resources. The following shows how to use backup of the slave database to restore the data of the master database!

I. Create a tablespace on the primary database, create a table on the tablespace, insert test data, and check the synchronization of the standby database.

  1. SQL> create tablespace test01 datafile '/u01/app/Oracle/oradata/db1/test01.dbf' size 10 M;
    Tablespace created.
  2. SQL> create table rman tablespace test01 as select object_id, object_name from dba_objects;
  3. Table created.
  4.  
  5. SQL> select count (*) from rman;
  6.  
  7. COUNT (*)
  8. ----------
  9. 76379
  10.  
  11. [Oracle @ db2 db1] $ sqlplus/nolog
  12. SQL * Plus: Release 11.2.0.3.0 Production on Mon Oct 29 11:37:38 2012
  13. Copyright (c) 1982,201 1, Oracle. All rights reserved.
  14.  
  15. SQL> conn/as sysdba
  16. Connected.
  17. SQL> select count (*) from rman;
  18.  
  19. COUNT (*)
  20. ----------
  21. 76379

Ii. Use rman on the slave database to back up the new tablespace test01

  1. [Oracle @ db2 db1] $ rman target/
  2. Recovery Manager: Release 11.2.0.3.0-Production on Mon Oct 29 11:38:01 2012
  3. Copyright (c) 1982,201 1, Oracle and/or its affiliates. All rights reserved.
  4. Connected to target database: DB1 (DBID = 1387827106)
  5.  
  6. RMAN> report schema;
  7.  
  8. RMAN> backup tablespace test01 format '/home/oracle/test01 _ % U ';
  9.  
  10. Starting backup at 2012-10-29-11:38:50
  11. Allocated channel: ORA_DISK_1
  12. Channel ORA_DISK_1: SID = 1 device type = DISK
  13. Channel ORA_DISK_1: starting full datafile backup set
  14. Channel ORA_DISK_1: specifying datafile (s) in backup set
  15. Input datafile file number = 00034 name =/u01/app/oracle/oradata/db1/test01.dbf
  16. Channel ORA_DISK_1: starting piece 1 at 2012-10-29-11:38:51
  17. Channel ORA_DISK_1: finished piece 1 at 2012-10-29-11:38:52
  18. Piece handle =/home/oracle/test01_03novc2b_1_1 tag = TAG20121029T113851 comment = NONE
  19. Channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
  20. Finished backup at 2012-10-29-11:38:52

3. Disable the primary database and delete the tablespace data files to simulate data loss.

  1. [Oracle @ db1 ~] $ Sqlplus/nolog
  2. SQL * Plus: Release 11.2.0.3.0 Production on Mon Oct 29 11:39:49 2012
  3. Copyright (c) 1982,201 1, Oracle. All rights reserved.
  4.  
  5. SQL> conn/as sysdba
  6. Connected.
  7. SQL> shutdown immediate
  8. Database closed.
  9. Database dismounted.
  10. ORACLE instance shut down.
  11. SQL> exit
  12.  
  13. [Oracle @ db1 ~] $ Rm-rf/u01/app/oracle/oradata/db1/test01.dbf

4. Restart the master database. It can only be started to the mount status.

  1. [Oracle @ db1 ~] $ Sqlplus/nolog
  2. SQL * Plus: Release 11.2.0.3.0 Production on Mon Oct 29 11:41:42 2012
  3. Copyright (c) 1982,201 1, Oracle. All rights reserved.
  4. SQL> conn/as sysdba
  5. Connected to an idle instance.
  6. SQL> startup
  7. ORACLE instance started.
  8.  
  9. Total System Global Area 1536602112 bytes
  10. Fixed Size 2228624 bytes
  11. Variable Size 1174408816 bytes
  12. Database Buffers 352321536 bytes
  13. Redo Buffers 7643136 bytes
  14. Database mounted.
  15. ORA-01157: cannot identify/lock data file 34-see DBWR trace file
  16. ORA-01110: data file 34: '/u01/app/oracle/oradata/db1/test01.dbf'
  17.  
  18. SQL> select open_mode, database_role from v $ database;
  19.  
  20. OPEN_MODE DATABASE_ROLE
  21. ------------------------------------
  22. MOUNTED PRIMARY
  • 1
  • 2
  • Next Page

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.