影者东升 发表于 2021-7-10 13:30:04

ADG单实例系列搭建之(Data Guard Broker)

  环境准备   主机名ipDB Versiondb_namedb_unique_name主库orcl192.168.56.12011.2.0.4orclorcl备库orcl_stby192.168.56.12111.2.0.4orclorcl_stby  Notes:
  1、db_unique_name主备库不能相同。
  2、db_name主备库需保持一致。
  3、主备库DB版本需保持一致。
  提前搭建好ADG,请参考:
  ADG单实例系列搭建之(RMAN备份恢复)
  ADG单实例搭建系列之(Active Database Duplicate Using Image Copies)
  ADG单实例搭建系列之 (DBCA)
一、Enable Broker --both databases (primary and standby)

ALTER SYSTEM SET dg_broker_start=true;
二、Register server with the broker dgmgrl sys/oracle@orcl

##pri是configuration名称,随意
##第一个orcl是db_unique_name
##第二个orcl是TNSNAME
CREATE CONFIGURATION pri AS PRIMARY DATABASE IS orcl CONNECT IDENTIFIER IS orcl;

##第一个orcl_stby是db_unique_name
##第二个orcl_stby是TNSNAME
ADD DATABASE orcl_stby AS CONNECT IDENTIFIER IS orcl_stby MAINTAINED AS PHYSICAL;

ENABLE CONFIGURATION;

三、Check the configuration and database
SHOW CONFIGURATION;

SHOW DATABASE orcl;

SHOW DATABASE orcl_stby;

四、Database Switchover
  Configure Listener Both Primary and Standby
vi $TNS_AMDIN/listener.ora

##GLOBAL_DBNAME是db_unique_name+DGMGRL
##primary add

    (SID_DESC =
      (GLOBAL_DBNAME = orcl_DGMGRL)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db)
      (SID_NAME = orcl)
    )

##standby add

    (SID_DESC =
      (GLOBAL_DBNAME = orcl_stby_DGMGRL)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db)
      (SID_NAME = orcl)
    )
  Notes:如果listener.ora不配置DGMGRL静态监听,SWITCHOVER将报错:ORA-12514。

SWITCHOVER TO orcl_stby;  主切备:

  备切主:

五、Database Failover  主库提前开启FLASHBACK,Failover后还可以切回备库,防止主库废掉。
ALTER DATABASE FLASHBACK ON;

ALTER SYSTEM SET db_recovery_file_dest_size=5G;
##备库DGMGRL操作
FAILOVER TO orcl_stby IMMEDIATE;
  原主库切换为备库:
##备库DGMGRL操作
REINSTATE DATABASE orcl;
六、Snapshot Standby  Snapshot standby database是ORACLE 11g的新特性。允许Physical standby短时间的使用read write模式。必须是ADG才支持。
  注意:一旦snapshot standby被激活的时间超出了primary 的最大负载时间,再次的本地更新操作将会产生额外的异常。
##主库DGMGRL操作

CONVERT DATABASE orcl_stby TO SNAPSHOT STANDBY;
  切回物理备库:
##主库DGMGRL执行

CONVERT DATABASE orcl_stby TO PHYSICAL STANDBY;

  
文档来源:51CTO技术博客https://blog.51cto.com/luciferliu/3029787
页: [1]
查看完整版本: ADG单实例系列搭建之(Data Guard Broker)