Dataguard環境下資料庫的備份與恢複

來源:互聯網
上載者:User

在部署完active data guard後,不但可以將唯讀查詢交給備庫執行,還可以把日常的Database Backup工作放在備庫上執行,從而減輕主庫的壓力,充分的發揮伺服器資源,下面示範下利用備庫備份來還原主庫資料的過程!

一:主庫上建立資料表空間,並在資料表空間上建表,插入測試資料,同時檢查備庫的同步情況

  1. SQL> create tablespace test01 datafile '/u01/app/Oracle/oradata/db1/test01.dbf' size 10M;
    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, 2011, Oracle.  All rights reserved.  
  14.  
  15. SQL> conn /as sysdba  
  16. Connected.  
  17. SQL> select count(*) from rman;  
  18.  
  19.   COUNT(*)  
  20. ----------  
  21.      76379 

二:在備庫上使用rman對建立的資料表空間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, 2011, 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 

三:關閉主庫後刪除資料表空間資料檔案,類比資料丟失情境

  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, 2011, 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 

四:重新啟動主庫,只能啟動到mount狀態

  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, 2011, 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
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.