通過RMAN備份duplicate建立DataGuard

來源:互聯網
上載者:User

說明:
建立dataguard方式很多,本文分紹了其中一種方式, 10g/11g都適用。
本文通過RMAN target主庫與本地輔助庫,通過本地備份恢複資料檔案建立Oracle 11g Dataguard物理備庫。

使用RMAN的Duplicate功能建立物理DataGuard 

Oracle基礎教程之通過RMAN複製資料庫

RMAN備份策略制定參考內容

RMAN備份學習筆記

OracleDatabase Backup加密 RMAN加密

一、環境介紹
1. 主要資料庫環境
作業系統版本  : OEL5.8 x64
資料庫版本    : Oracle 11.2.0.3 x64
資料庫名      : orcl
資料庫SID    : orcl
db_unique_name: orcl
instance_name : orcl

2. 備庫環境
作業系統版本  : OEL5.8 x64
資料庫版本    : Oracle 11.2.0.3 x64 (只安裝oracle資料庫軟體,no netca dbca)
資料庫名      : slave
資料庫SID    : slave
db_unique_name: slave
instance_name : slave

3. DataGuard啟動順序
啟動順序:先啟備庫,後啟主庫
關閉順序:先關主庫,後關備庫
 
二、主要資料庫環境準備

1. 主庫環境對比
重新建立口令檔案
# su - oracle
$ orapwd file='/u01/app/oracle/product/11.2.0/db_1/dbs/orapworcl' password=oracle entries=10 force=y

2. 修改配置lisener監聽檔案
說明:添加dgmgrl靜態監聽配置,為後面的dg broker配置打基礎。
$ cat /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora 
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.233.200)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = orcl)
    )
  )
ADR_BASE_LISTENER = /u01/app/oracle

4. 修改配置tnsname.ora檔案
說明:ORCL是主庫的服務名,DG是備庫的服務名。
$ vi /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.233.200)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
SLAVE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.233.150)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = slave)
    )
  )

5. 修改配置成規檔模式
1)、檢查資料庫是否處于歸檔狀態
SQL> archive log list;
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog;
SQL> alter database open;

2)、將主庫設定為 FORCE LOGGING 模式
SQL> alter database force logging;
SQL> select force_logging from v$database;
FOR
---
YES

6. 修改主庫參數檔案
SQL>
alter system set instance_name='orcl' scope=spfile; 
alter system set db_unique_name='orcl' scope=spfile; 
alter system set local_listener='orcl' scope=spfile;
alter system set log_archive_config='DG_CONFIG=(orcl,slave)'; 
alter system set log_archive_dest_1='LOCATION=/u01/archivelog/ valid_for=(all_logfiles,all_roles) db_unique_name=orcl' scope=spfile;
alter system set log_archive_dest_2='SERVICE=slave lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=slave' scope=spfile; 
alter system set log_archive_format='arch_%r_%t_%s.arc' scope=spfile;
alter system set fal_client='orcl' scope=spfile;
alter system set fal_server='slave' scope=spfile; 
alter system set standby_file_management=AUTO; 
alter database add standby logfile group 4 '/u01/app/oracle/oradata/orcl/standby_redo04.log' size 50M; 
alter database add standby logfile group 5 '/u01/app/oracle/oradata/orcl/standby_redo05.log' size 50M; 
alter database add standby logfile group 6 '/u01/app/oracle/oradata/orcl/standby_redo06.log' size 50M; 
alter database add standby logfile group 7 '/u01/app/oracle/oradata/orcl/standby_redo07.log' size 50M; 
SQL> shutdown immediate;
SQL> startup;

#準備一些測試資料,只建立表結構
SQL> conn / as sysdba;
SQL> create user abc identified by abc ;
SQL> grant dba to abc;
SQL> conn abc/abc
SQL> create table abc ( id integer , name char(10));
在備份之前這個表還沒有資料。下面的備份組中沒有表記錄。

  • 1
  • 2
  • 3
  • 4
  • 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.