官方文档学习:data guard broker

原创文章,转载请标明出处
http://space.itpub.net/26239116/viewspace-749136
使用之前:
1 安装oracle软件或客户端,装客户端选择administrator模式
2 设置参数DG_BROKER_START=TRUE
3 如果某个数据库在RAC中,还需要设置参数DG_BROKER_CONFIG_FILEn
4 在 主库listener.ora中将GLOBAL_DBNAME配置为db_unique_name_DGMGRL.db_domain形式,如
LISTENER = (DESCRIPTION =
     (ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=host_name)
     (PORT=port_num))))
SID_LIST_LISTENER=(SID_LIST=(SID_DESC=(SID_NAME=sid_name)
     (GLOBAL_DBNAME=db_unique_name_DGMGRL.db_domain)
     (ORACLE_HOME=oracle_home))
5 如果有RAC环境,则START_OPTIONS必须设置为MOUNT
srvctl add database -d -o -s mount
srvctl modify database -d -o -s mount
6 主库必须是归档模式
7 参数COMPATIBLE必须高于9.2.0.1.0,并且主备库一致
8 设置参数local_listener
alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg2)(PORT=1521)))'
然后启动监听,查看监听状态,有dg2_XPT服务
Service "dg2_XPT" has 1 instance(s).

dgmgrl命令

Table 1-2 DGMGRL Commands

Command Description

ADD

Adds a standby database to the broker configuration

CONNECT

Connects to an Oracle instance

CREATE

Creates a broker configuration

DISABLE

Disables a configuration, a database, or fast-start failover

EDIT

Edits a configuration, database, or instance

ENABLE

Enables a configuration, a database, or fast-start failover

EXIT

Exits the program

FAILOVER

Changes a standby database to be the primary database

HELP

Displays description and syntax for individual commands

QUIT

Exits the program

REINSTATE

Changes a disabled database into a viable standby database

REM

Comments to be ignored by DGMGRL

REMOVE

Removes a configuration, database, or instance

SHOW

Displays information of a configuration, database, or instance

SHUTDOWN

Shuts down a currently running Oracle instance

START

Starts the fast-start failover observer

STARTUP

Starts an Oracle database instance

STOP

Stops the fast-start failover observer

SWITCHOVER

Switches roles between the primary database and a standby database




dg broker的配置文件存放
参数DG_BROKER_CONFIG_FILE1,DG_BROKER_CONFIG_FILE2中
1 RAC中每个实例的这两个参数必须一致
2 这两个参数只有在broker没启用的时候才能修改,也就是参数DG_BROKER_START=FALSE的时候
3 RAC中,两个参数必须指向裸设备,ASM,集群文件系统

启用DATA GUARD BROKER
ALTER SYSTEM SET DG_BROKER_START=TRUE;

SHOW PARAMETER DG_BROKER_START

NAME               TYPE      VALUE
------------------------------------ 
dg_broker_start    boolean   TRUE

连接dgmgrl
$ dgmgrl
Username: sys
Password:
Connected.

创建配置文件
主库:
DGMGRL> create configuration 'dgconfig' as primary database is 'dg1' connect identifier is dg1;
DGMGRL> add database 'dg2' as connect identifier is dg2 maintained as physical; 
DGMGRL> show configuration

Configuration
  Name:                dgconfig
  Enabled:             NO
  Protection Mode:     MaxPerformance
  Fast-Start Failover: DISABLED
  Databases:
    dg1 - Primary database
    dg2 - Physical standby database

Current status for "dgconfig":
DISABLED

DGMGRL>  enable configuration
Enabled.
DGMGRL> show configuration

Configuration
  Name:                dgconfig
  Enabled:             YES
  Protection Mode:     MaxPerformance
  Fast-Start Failover: DISABLED
  Databases:
    dg1 - Primary database
    dg2 - Physical standby database

Current status for "dgconfig":
SUCCESS

管理数据库
改变数据库状态:
EDIT DATABASE 'North_Sales' SET STATE='LOG-TRANSPORT-OFF';
一共有下面这些状态

Table 4-1 Database States and Descriptions

Database Role State Name Description

Primary

ONLINE

The primary database is open for read/write access and redo transport services are archiving online redo log files to the standby databases.

If this is a RAC database, all started instances are open in read/write mode and have redo transport services running.

This is the default state for a primary database when it is enabled for the first time.

Primary

LOG-TRANSPORT-OFF

The primary database is open for read/write access, but redo transport services are not transmitting redo data to the standby databases.

If this is a RAC database, all started instances are open in read/write mode and redo transport services are not running on any instances.

Physical standby

ONLINE

The physical standby database is mounted and Redo Apply is started. The standby database is not open for read-only queries.

If the standby database is a RAC database, the broker starts log apply services on exactly one standby instance, called the apply instance. If this instance fails, the broker automatically chooses another started instance. This new instance then becomes the apply instance.

This is the default state for a physical standby database when it is enabled for the first time.

Physical standby

LOG-APPLY-OFF

The physical standby database is mounted, but Redo Apply is stopped. The standby database is not open for read-only queries.

If this is a RAC database, there is no instance running log apply services until you change the database state to ONLINE.

Physical standby

READ-ONLY

The physical standby database is open for read-only queries, and Redo Apply is stopped.

If this is a RAC database, one or more instances will be open in read-only mode. Redo Apply is not running on any instance.

Logical standby

ONLINE

The logical standby database is open for read-only queries and SQL Apply is started. The logical standby database guard is on.

If this is a RAC database, SQL Apply is running on one instance, the apply instance. If this instance fails, the broker automatically chooses another started instance. This new instance becomes the apply instance.

This is the default state for a logical standby database when it is enabled for the first time.

Logical standby

LOG-APPLY-OFF

The logical standby database is open for read-only queries, and SQL Apply is not running. The logical standby database guard is on.

If this is a RAC database, there is no instance running SQL Apply until you change the database state to ONLINE.

All

OFFLINE

When you set the state of a standby database to OFFLINE, the broker automatically shuts down the database, turns off redo transport services to this database, and leaves the database as disabled in the broker configuration. The broker will not manage this database until you restart the database.

When you set the state of a primary database to OFFLINE, the broker automatically shuts down the database. The primary database is not available, and the broker is no longer managing the entire Data Guard configuration. You need to restart the database to resume broker control.

If this is a RAC database, all started instances are shutdown.



数据库属性
查看属性
SHOW DATABASE VERBOSE 'dg2'
修改属性
DGMGRL> SHOW DATABASE 'North_Sales' 'ArchiveLagTarget';
  ArchiveLagTarget = '0'

DGMGRL>  EDIT DATABASE 'North_Sales' SET PROPERTY 'ArchiveLagTarget'=1200;
  Property "ArchiveLagTarget" updated

DGMGRL> SHOW DATABASE 'North_Sales' 'ArchiveLagTarget';
  ArchiveLagTarget = '1200'


管理 Redo Transport Service
需要设置每个数据库的下列属性

AlternateLocation

Binding

Dependency

LogShipping

LogXptMode

MaxFailure

NetTimeout

ReopenSecs

StandbyArchiveLocation

关闭日志传输
DGMGRL> EDIT DATABASE 'North_Sales' SET STATE="LOG-TRANSPORT-OFF";
关闭对指定备库的日志传输
DGMGRL> EDIT DATABASE 'DR_Sales' SET PROPERTY 'LogShipping'='OFF';

改变保护模式
DGMGRL> EDIT DATABASE 'dg1' SET PROPERTY 'LogXptMode'='SYNC';
DGMGRL> EDIT DATABASE 'dg2' SET PROPERTY 'LogXptMode'='SYNC';
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;

















来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26239116/viewspace-749142/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26239116/viewspace-749142/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值