在配置DG broker之前需要确保Dataguard配置正常且主库和备库均使用spfile.
1. 主库配置
SQL
> show parameter dg_broker_start;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dg_broker_start boolean FALSE
- 启用dg_broker_start,启用后oracle会自动启动一个dmon进程
SQL> alter system
set dg_broker_start
= true;
System altered.
- 修改listener.ora文件,加入DGMGRL静态监听:
SID_LIST_LISTENER
=
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ora11db)
(ORACLE_HOME = /app
/oracle
/product
/11.2.
0/dbhome_1)
(SID_NAME = ora11db)
)
(SID_DESC =
(GLOBAL_DBNAME = ora11db_DGMGRL)
(ORACLE_HOME = /app
/oracle
/product
/11.2.
0/dbhome_1)
(SID_NAME = ora11db)
)
)
$> lsnrctl reload
2. 备库配置
SQL
> show parameter dg_broker_start;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dg_broker_start boolean FALSE
- 启用dg_broker_start,启用后oracle会自动启动一个dmon进程
SQL> alter system
set dg_broker_start
= true;
System altered.
- 修改listener.ora文件,加入DGMGRL静态监听:
SID_LIST_LISTENER
=
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ora11sty)
(ORACLE_HOME = /app
/oracle
/product
/11.2.
0/dbhome_1)
(SID_NAME = ora11sty)
)
(SID_DESC =
(GLOBAL_DBNAME = ora11sty_DGMGRL)
(ORACLE_HOME = /app
/oracle
/product
/11.2.
0/dbhome_1)
(SID_NAME = ora11sty)
)
)
$> lsnrctl reload
3.配置broker
oracle
@solora11g:
~ $
> dgmgrl sys
/manager
DGMGRL for Solaris: Version
11.2.
0.1.
0 - 64
bit Production
Copyright (c) 2000,
2009, Oracle.
All rights reserved.
Welcome to DGMGRL, type "help"
for information.
Connected.
DGMGRL> create configuration
'DGORA11G' as primary database is 'ora11db' connect identifier
is ora11db;
Configuration "DGORA11G" created with primary database "ora11db"
DGMGRL> show configuration
Configuration - DGORA11G
Protection Mode: MaxPerformance
Databases:
ora11db - Primary database
Fast-Start Failover: DISABLED
Configuration Status:
DISABLED
DGMGRL
> add database 'ora11sty' as connect identifier
is 'ora11sty' maintained
as physical;
Database "ora11sty" added
DGMGRL> show configuration
Configuration - DGORA11G
Protection Mode: MaxPerformance
Databases:
ora11db - Primary database
ora11sty - Physical standby
database
Fast-Start Failover: DISABLED
Configuration Status:
DISABLED
DGMGRL
> enable configuration
Enabled.
DGMGRL> show configuration
Configuration - DGORA11G
Protection Mode: MaxPerformance
Databases:
ora11db - Primary database
ora11sty - Physical standby
database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
4. 测试switchover
DGMGRL> switchover to ora11sty
Performing switchover NOW, please wait...
New primary database "ora11sty" is opening...
Operation requires shutdown of instance "ora11db" on database "ora11db"
Shutting down instance "ora11db"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "ora11db" on database "ora11db"
Starting instance "ora11db"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "ora11sty"