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 ];

猜你喜欢

转载自wwtang9527.iteye.com/blog/1606980