Oracle 10g DataGuard broker 配置与手动切换

在主从库都启用broker:

alter system set dg_broker_start=true scope=both;

SQL> alter system set dg_broker_start=true scope=both;
System altered.

在主库上启动broker:
dgmgrl sys/oracle

$ dgmgrl sys/oracle
DGMGRL for Linux: Version 10.2.0.1.0 - Production
Copyright (c) 2000, 2005, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected.

创建配置及主库:

create configuration 'broker_prod' as
primary database is pri
connect identifier is db_pri;

DGMGRL> create configuration 'broker_prod' as
> primary database is pri
> connect identifier is db_pri;
Configuration "broker_prod" created with primary database "pri"

添加从库:

add database stdby as
connect identifier is db_stdby
maintained as physical;

DGMGRL> add database stdby as
> connect identifier is db_stdby
> maintained as physical;
Database "stdby" added

开启配置:
enable configuration

DGMGRL> enable configuration
Enabled.

查看配置:
show configuration;

DGMGRL> show configuration;

Configuration
Name: broker_prod
Enabled: YES
Protection Mode: MaxPerformance
Fast-Start Failover: DISABLED
Databases:
pri - Primary database
stdby - Physical standby database

Current status for "broker_prod":
SUCCESS

切换前准备,主机、从机上都要开启一个名为"<db_unique_name>_DGMGRL"的监听服务:
主机

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = pri_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = prod)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = thczpri)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)


检查服务已监听:
lsnrctl service |grep DGMGRL

$ lsnrctl service |grep DGMGRL
Service "pri_DGMGRL" has 1 instance(s).

从机

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = stdby_DGMGRL)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = stdby)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = thczstdby)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)


检查服务已监听:
lsnrctl service |grep DGMGRL

$ lsnrctl service |grep DGMGRL
Service "stdby_DGMGRL" has 1 instance(s).

试着做切换:
switchover to stdby;

DGMGRL> switchover to stdby;
Performing switchover NOW, please wait...
Operation requires shutdown of instance "prod" on database "pri"
Shutting down instance "prod"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires shutdown of instance "stdby" on database "stdby"
Shutting down instance "stdby"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "prod" on database "pri"
Starting instance "prod"...
ORACLE instance started.
Database mounted.
Operation requires startup of instance "stdby" on database "stdby"
Starting instance "stdby"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "stdby"

可以看到上面切换成功了。

再切换回来:
switchover to pri;

DGMGRL> switchover to pri;
Performing switchover NOW, please wait...
Operation requires shutdown of instance "stdby" on database "stdby"
Shutting down instance "stdby"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires shutdown of instance "prod" on database "pri"
Shutting down instance "prod"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "stdby" on database "stdby"
Starting instance "stdby"...
ORACLE instance started.
Database mounted.
Operation requires startup of instance "prod" on database "pri"
Starting instance "prod"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "pri"

也是成功的。

创建配置语法:
CREATE CONFIGURATION configuration-name AS
PRIMARY DATABASE IS database-name
CONNECT IDENTIFIER IS connect-identifier;

添加备库配置语法:
ADD DATABASE database-name AS
CONNECT IDENTIFIER IS connect-identifier
MAINTAINED AS {PHYSICAL | LOGICAL};

删除database语法:
REMOVE DATABASE database-name [ PRESERVE DESTINATIONS ];
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值