对于已经建立的rac dataguard 环境,standby rac和主库对应拥有两个节点并且可以应在一个节点用日志!在此情况下 启用 ADG 特性
主库:rac1 rac2
备库: rac3 rac4
一 非dataguard·broker 情况下:
1. 日志已经在rac3上应用,所以只需在节点rac3上取消日志应用,注意:对于节点rac4 不用做任何操作!
rac3> alter database recover managed standby database cancel;
Database altered.
2. Since database added to cluster to startup default on mount mode with
打开数据库至 read only 模式,需要注意的是向集群添加节点的时候一般是以mount状态启动的,对于备库要以read only 方式打开!
在节点rac3上
rac3> alter database open read only;
Database altered.
rac3> select open_mode from v$database;
OPEN_MODE
---------
READ ONLY
对节点rac3操作完之后,节点rac4依然是mounted状态
rac4> select open_mode from v$database;
OPEN_MODE
---------
MOUNTED
以read only方式打开节点rac4的实例
rac4> alter database open read only;
Database altered.
rac4> select open_mode from v$database;
OPEN_MODE
---------
READ ONLY
3. 在一个节点上进行应用日志,执行如下命令:
rac3> alter database recover managed standby database using current logfile disconnect;
Database altered.
4. 在两个备库实例上查看数据库的打开方式:
rac3> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY
rac4> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY
二 如果配置的dataguard broker,并且已经应用日志了,按照如下方法进行:
1.用dgmgrl 停止应用日志!
DGMGRL> edit database rac set state='APPLY-OFF';
Succeeded.
DGMGRL> show database rac
Database - rac
Role: PHYSICAL STANDBY
Intended State: APPLY-OFF
Transport Lag: 0 seconds
Apply Lag: 0 seconds
Real Time Query: OFF
Instance(s):
rac1 (apply instance)
rac2
Database Status:
SUCCESS
2. 进行非dataguard broker的第二步!
alter database open read only;
3. 使用 dgmgrl 重新开始应用日志!
DGMGRL> edit database rac set state='APPLY-ON';
Succeeded.
三 停止ADG
1. 取消日志应用!
rac3> alter database recover managed standby database cancel;
Database altered.
open_mode 将由 READ ONLY WITH APPLY 变为 READ ONLY
rac3> select open_mode from v$database;
OPEN_MODE
---------
READ ONLY
2. 关闭并重启standby 至mount状态!
srvctl stop database -d rac
srvctl start database -d rac
rac3> select open_mode from v$database;
OPEN_MODE
---------
MOUNTED
3. 重新开启日志应用!
rac3> alter database recover managed standby database using current logfile disconnect;
Database altered.