Oracle 11g Data Guard Broker操作笔记

转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/41548669

一、设置

1、设置broker
 在主备库上各设置为true
SQL> alter system set dg_broker_start=true;

2、在主库上操作
[[email protected] admin]$ dgmgrl sys/[email protected]

DGMGRL> help

DGMGRL> help create

DGMGRL> CREATE CONFIGURATION c1 AS PRIMARY DATABASE IS PROD1 CONNECT IDENTIFIER IS PROD1;

DGMGRL> help add

DGMGRL> ADD DATABASE DG AS CONNECT IDENTIFIER IS DG;

DGMGRL> help enable

DGMGRL> ENABLE CONFIGURATION;

DGMGRL> help show

DGMGRL> SHOW CONFIGURATION;

3、备库操作
SQL> SQL> shutdown immediate;

SQL> startup  open read only;

最好加一下read only,因为有时broker有时会把它拉回到mount状态!!!

SQL> select open_mode  from v$database;

OPEN_MODE
----------
READ ONLY

SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
NO

SQL> show parameter recovery

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      /flash
db_recovery_file_dest_size           big integer 1G

SQL> shutdown immediate;

SQL> startup mount;

SQL> alter database flashback on;

二、snapshot


1、主库
DGMGRL> SHOW CONFIGURATION

DGMGRL> help convert

DGMGRL> CONVERT DATABASE DG TO SNAPSHOT STANDBY;  ---如果这里有失败可能是监听DG_DGMGRL没设

DGMGRL> SHOW CONFIGURATION;

2、备库
变成TEST库后,确实可以写入数据
SQL> create table t1(id int,name varchar2(10));

Table created.

SQL> insert into t1 values(1,‘AAAA‘);

1 row created.

SQL> commit;

Commit complete.

三、还原到物理备库


1、主库
DGMGRL> help convert

DGMGRL> CONVERT DATABASE DG TO  PHYSICAL STANDBY; ---如果这里有失败可能是监听DG_DGMGRL没设

四、来回切换库


1、在主库PROD1上操作
DGMGRL> SHOW CONFIGURATION

Configuration
  Name:                c1
  Enabled:             YES
  Protection Mode:     MaxPerformance
  Databases:
    prod1 - Primary database
    dg    - Physical standby database

Fast-Start Failover: DISABLED

Current status for "c1":
SUCCESS

DGMGRL> help switch
Unrecognized command "switch", try "help"
DGMGRL> help switchover

Switch roles between the primary database and a standby database

Syntax:

SWITCHOVER TO <standby database name>;

DGMGRL> SWITCHOVER TO DG;
Performing switchover NOW, please wait...
New primary database "dg" is opening...
Operation requires shutdown of instance "PROD1" on database "prod1"
Shutting down instance "PROD1"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "PROD1" on database "prod1"
Starting instance "PROD1"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "dg"

DGMGRL> SHOW CONFIGURATION

Configuration
  Name:                c1
  Enabled:             YES
  Protection Mode:     MaxPerformance
  Databases:
    dg    - Primary database
    prod1 - Physical standby database

Fast-Start Failover: DISABLED

Current status for "c1":
SUCCESS

DGMGRL> SWITCHOVER TO PROD1
Performing switchover NOW, please wait...
New primary database "prod1" is opening...
Operation requires shutdown of instance "DG" on database "dg"
Shutting down instance "DG"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "DG" on database "dg"
Starting instance "DG"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "prod1"

五、修改传输模式

DGMGRL> SHOW DATABASE VERBOSE PROD1

DGMGRL> help edit

DGMGRL> EDIT DATABASE PROD1 SET PROPERTY LogXptMode=SYNC;  ---主库
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxAvailability;  ---主库
Error: ORA-16627: operation disallowed since no standby databases would remain to support protection mode

Failed.
这个错误的主要原因是(主库和备库都要改EDIT DATABASE XXXX SET PROPERTY)

DGMGRL> EDIT DATABASE PROD1 SET PROPERTY LogXptMode=SYNC;     ---主库
DGMGRL> EDIT DATABASE DG    SET PROPERTY LogXptMode=SYNC;     ---备库

DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxAvailability;    ---主库
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxAvailability;    ---备库

以上Error: ORA-16627: 错误马上消失。。。。

++++备库的一些基本命令可以记下:
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database recover managed standby database disconnect from session;

Database altered.

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> alter database open;

Database altered.

六、故障切换


1、主库
DGMGRL> help enable;

DGMGRL> ENABLE FAST_START FAILOVER;

2、备库
[[email protected] ~]$ dgmgrl sys/[email protected]

DGMGRL> help start

DGMGRL> START OBSERVER

3、主库
[[email protected] ~]$ ps -ef |grep pmon
oracle    3444     1  0 16:41 ?        00:00:00 ora_pmon_PROD1
oracle    4534 29892  0 17:04 pts/2    00:00:00 grep pmon
oracle   10888     1  0 09:03 ?        00:00:00 ora_pmon_PROD2
[[email protected] ~]$ kill -9 3444

4、备库
 (1)发现信息
DGMGRL> START OBSERVER
Observer started

17:05:29.04  Friday, November 21, 2014
Initiating Fast-Start Failover to database "dg"...
Performing failover NOW, please wait...
Failover succeeded, new primary is "dg"
17:05:37.62  Friday, November 21, 2014

(2)stop observer(观察到上面的信息就停止掉,以防来回切换)
  
 用ctr+c即可

5、主库
[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.7.0 - Production on Fri Nov 21 17:10:14 2014

Copyright (c) 1982, 2008, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area  418484224 bytes
Fixed Size                  1313792 bytes
Variable Size             176161792 bytes
Database Buffers          234881024 bytes
Redo Buffers                6127616 bytes
Database mounted.

6、切回去
DGMGRL> SHOW CONFIGURATION;

Configuration
  Name:                c1
  Enabled:             YES
  Protection Mode:     MaxAvailability
  Databases:
    dg    - Primary database
    prod1 - Physical standby database (disabled)
          - Fast-Start Failover target

Fast-Start Failover: ENABLED

Current status for "c1":
Warning: ORA-16607: one or more databases have failed

DGMGRL> SWITCHOVER TO PROD1
Performing switchover NOW, please wait...
Error: ORA-16541: database is not enabled

Failed.

DGMGRL> DISABLE FAST_START FAILOVER;
Error: ORA-16652: fast-start failover target standby database is disabled

Failed.
DGMGRL> DISABLE FAST_START FAILOVER force;
Disabled.

DGMGRL> SHOW CONFIGURATION;

Configuration
  Name:                c1
  Enabled:             YES
  Protection Mode:     MaxAvailability
  Databases:
    dg    - Primary database
    prod1 - Physical standby database (disabled)

Fast-Start Failover: DISABLED

Current status for "c1":
Warning: ORA-16608: one or more databases have warnings

DGMGRL> switchover to prod1;             ----------------------------------->这个错误的一般出现在VM中。。。
Performing switchover NOW, please wait...
Error: ORA-16541: database is not enabled

Failed.
Unable to switchover, primary database is still "dg"

DGMGRL> show database verbose prod1

Current status for "prod1":
Error: ORA-16661: the standby database needs to be reinstated

实在搞不定,重置了
DGMGRL> reinstate database PROD1
Reinstating database "prod1", please wait...
Operation requires shutdown of instance "PROD1" on database "prod1"
Shutting down instance "PROD1"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "PROD1" on database "prod1"
Starting instance "PROD1"...
ORACLE instance started.
Database mounted.
Continuing to reinstate database "prod1" ...
Reinstatement of database "prod1" succeeded
DGMGRL> show configuration;

Configuration
  Name:                c1
  Enabled:             YES
  Protection Mode:     MaxAvailability
  Databases:
    dg    - Primary database
    prod1 - Physical standby database

Fast-Start Failover: DISABLED

Current status for "c1":
Warning: ORA-16610: command "EDIT DATABASE prod1 SET PROPERTY" in progress

DGMGRL> SWITCHOVER TO PROD1
Performing switchover NOW, please wait...
New primary database "prod1" is opening...
Operation requires shutdown of instance "DG" on database "dg"
Shutting down instance "DG"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "DG" on database "dg"
Starting instance "DG"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "prod1"

DGMGRL> show configuration;

Configuration
  Name:                c1
  Enabled:             YES
  Protection Mode:     MaxAvailability
  Databases:
    prod1 - Primary database
    dg    - Physical standby database

Fast-Start Failover: DISABLED

Current status for "c1":
SUCCESS

时间: 2024-10-08 04:54:09

Oracle 11g Data Guard Broker操作笔记的相关文章

Oracle 11g Data Guard 之角色转换

1.1 简介 Data Guard配置包括1个primary角色的数据库和1个或者多个standby角色的数据库,数据库的角色我们可以通过V$DATABASE中DATABASE_ROLE字段来获得. 另外,Data Guard配置中standby库的数量.位置.备库类型以及redo data从主库传到备库的方式,决定了主库发生停机故障时能采用的角色管理方案. 当数据库运行于Data Guard中primary或者standby这样互斥的角色时,可以通过SQL语句或者Data Guard brok

Oracle 11g Data Guard 物理备库快速配置指南(上)

缘起 最近做了10g和11g的物理备库配置实验,发现 Data Guard 其实很容易,但是缺少好文档.我是参考官方文档做的实验,觉得它写的不是很清楚的. Google 出来两个pdf文档,读了觉得比官方文档强很多.翻译下,也许会对某些朋友有用.翻译的同时我也好更熟悉下这两个文档.好久没翻译过英文了,可以顺便练练手. 原文档下载地址(墙外): Configure Dataguard 11gR2 Physical Standby Part 1 Configure Dataguard 11gR2 P

Oracle 11g Data Guard 使用duplicate from active database 创建 standby database

用这种方式来搭建DG ,主库的停机时间很少,只需要重启一下,使参数生效.也可以用这种方法进行DB迁移.DG搭建好,然后把备库激活就可以了. 这样整个迁移中宕机时间也比较短. Oracle 11g的pyhsical standby 支持open read only 下的apply和Real-time query. 因此就有了physical standby 稳定和logical standby 的报表查询功能. Oracle: 11.2.0.1 OS: redhat 5.5 Primary IP:

Oracle 11g Data Guard 之物理备库角色转换

一.物理备库的Switchover操作 本节主要内容是物理备库的switchover操作,该操作起始于主库,结束于目标备库. 1.确认主库可以切换为standby角色 SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE; 如果结果显示TO STANDBY或者SESSIONS ACTIVE,则表明主库可以切换为standby角色,否则,切换操作将不可行,因为redo传输不是配置错误就是不能正常进行. 2.主库启动switchover 执行如下SQL语句将主库

ORACLE 11G Data Guard 角色转换

1,ORACLE Dataguard角色切换DataGuard已经是现今标准的主流容灾方案,由于日志传递对于网络适应程度强,且可以采用同步实时的传递方式和异步延迟的传递方式,甚至可以成为远程的异地容灾方案.不管用于何种用途,DG都免不了要进行角色转换,即将standby 数据库切换为primary数据库,角色转换分为:switchover和failover两种 2,两种方式的异同1),switchover是primary库转换成standby库.standby库转换成primary库2),fai

Oracle 11g Data Guard 之逻辑备库角色转换

逻辑备库不复制数据库服务,在进行switchover或者failover时,连接主库服务的中间层将不能连接(因为服务的创建没有被复制),或者连接不正确的版本(因为服务属性的修改没有被复制). Oracle集群不复制管理逻辑备库的服务,必须手动对主库与备库进行同步,具体的详参Oracle集群管理和部署的相关内容. 一.逻辑备库的switchover操作 当进行switchover操作来改变主库和逻辑备库的角色时,总是在主库启动switchover,然后在逻辑备库完成操作,其中的步骤必须按顺序,否则

[Oracle维护工程师手记系列]Data Guard Broker中改属性是否需要两侧分别执行?

Data Guard Broker中改属性是否需要两侧分别执行? Data Guard Broker有一些属性,可以通过 show configuration 看到.我有时会想,这些个属性,是否是分别属于primary 和 standby,如果想要修改,是否需要分别登陆到primary 和 standby ,来分别修改呢? 这也是很多客户经常有的疑问.故此我进行了如下的实验. 先看看primary 端的 属性值: -bash-4.1$ dgmgrl /DGMGRL for Linux: Vers

Oracle Data Guard broker 现场遇到bug ,闪之~

最近在客户现场搭建一套容灾环境,发现遇到了BUG,在无法解决的情况下,放弃了broker,依旧可以实现ADG,Oracle无法实现双主,但是MySQL可以哈.官网说法记录一下. OERR: ORA-16597 "Oracle Data Guard broker detects two or more primary databases" (varies by version) Reference Note (文档 ID 172973.1) PURPOSE This is a brief

【DATAGUARD】物理dg配置客户端无缝切换 (八.1)--Data Guard Broker 的配置

[DATAGUARD]物理dg配置客户端无缝切换 (八.1)--Data Guard Broker 的配置 一.1  BLOG文档结构图       一.2  前言部分   一.2.1  导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识,~O(∩_∩)O~: ① Data Guard Broker 的配置 ② Fast-Start Failover 的配置 ③ Oracle DataGuard 之客户端TAF 配置 ④ 使用DGMGRL 来管理数据库 ⑤