官方文件學習:data guard broker

liiinuuux發表於2012-11-13
原創文章,轉載請標明出處
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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章