Fast Start Failover

Включаем FlashBack на каждом сервере

SELECT flashback_on FROM v$database;
shutdown immediate;
startup mount;
ALTER DATABASE FLASHBACK ON;
alter database open;
(На PRIMARY startup mount;)
Включение broker на PRIMARY и STANDBY:

show parameter DG_BROKER_START
alter system set DG_BROKER_START=true scope=both;
show parameter DG_BROKER_START
Настройка DataGuard Broker

dgmgrl
connect sys/sys@MURGBPROD

CREATE CONFIGURATION fsfodg AS
PRIMARY DATABASE IS MURGBPROD
CONNECT IDENTIFIER IS MURGBPROD;

ADD DATABASE MURGBSTAN AS
CONNECT IDENTIFIER IS MURGBSTAN
MAINTAINED AS PHYSICAL;

show database verbose MURGBPROD;
show database verbose MURGBSTAN;

show configuration;
enable configuration;
enable database MURGBSTAN;

show database MURGBPROD;
show database MURGBSTAN;

EDIT DATABASE MURGBPROD SET PROPERTY ‘LogXptMode’=’SYNC’;
EDIT DATABASE MURGBSTAN SET PROPERTY ‘LogXptMode’=’SYNC’;

EDIT DATABASE MURGBPROD SET PROPERTY FastStartFailoverTarget=’MURGBSTAN’;
EDIT DATABASE MURGBSTAN SET PROPERTY FastStartFailoverTarget=’MURGBPROD’;

EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;

start observer;

ENABLE FAST_START FAILOVER;

show configuration;
listener.ora должен быть таким:

Чтобы switchover работал нужно дописать _DGMMGRL <global_db_name>_DGMGRL

На PRIMARY
(SID_DESC =
(GLOBAL_DBNAME = MURGBPROD_DGMGRL)
(ORACLE_HOME = C:\app\product\11.2.0\dbhome_1)
(SID_NAME = MURGB)
)

На STANDBY:
(SID_DESC =
(GLOBAL_DBNAME = MURGBSTAN_DGMGRL)
(ORACLE_HOME = C:\app\product\11.2.0\dbhome_1)
(SID_NAME = MURGB)
)
tnsnames.ora должен быть таким:

MURGBPROD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.192)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MURGBPROD_DGMGRL)
)
)

MURGBSTAN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.179)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = MURGBSTAN_DGMGRL)
)
)

Проверка Switchover

Проверка статусов на Primary и Standby:
select DB_UNIQUE_NAME,DATABASE_ROLE,OPEN_MODE,FS_FAILOVER_STATUS,FS_FAILOVER_CURRENT_TARGET from v$database;

show database MURGBPROD;
show database MURGBSTAN;

switchover to MURGBSTAN;

select DB_UNIQUE_NAME,DATABASE_ROLE,OPEN_MODE,FS_FAILOVER_STATUS,FS_FAILOVER_CURRENT_TARGET from v$database;

Настройка Observer

Для того чтобы работал FAST_START FAILOVER должен быть запущен Observer.
Скрипт запуска можно добавить в планировщик Windows. (например триггер при включении компьютера)

observer.cmd:
set ORACLE_HOME=C:\app\product\11.2.0\dbhome_1
call dgmgrl -silent sys/sys@MURGBPROD «stop observer»
call dgmgrl -silent sys/sys@MURGBPROD «start observer»

Под Linux
#!/bin/ksh
# startobserver
PATH=$PATH:$HOME/bin
export PATH
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/u01/app/oracle
PATH=$ORACLE_HOME/bin:$PATH
ORACLE_SID=nvlpu1
export ORACLE_SID
export ORACLE_HOME
export ORACLE_BASE
export PATH
dgmgrl << eof
connect sys/sysexi@MURGBPROD
STOP OBSERVER;
START OBSERVER;
eof

Проверка Fast Start Failover

select DB_UNIQUE_NAME,DATABASE_ROLE,OPEN_MODE,FS_FAILOVER_STATUS,FS_FAILOVER_CURRENT_TARGET from v$database;

На PRIMARY выключаем базу:
shutdown abort;

Через минуту STANDBY база должна перести в PRIMARY и статус будет «Reinstate Required»
select DB_UNIQUE_NAME,DATABASE_ROLE,OPEN_MODE,FS_FAILOVER_STATUS,FS_FAILOVER_CURRENT_TARGET from v$database;

На выключенной базе:
startup mount;

DGMGRL>
show configuration;

murgbstan — (*) Physical standby database (disabled)
ORA-16661: the standby database needs to be reinstated

DGMGRL>
reinstate database ‘murgbstan’;