环境:192.168.48.10 orcl
192.168.48.20 orcl_adg(db_unqiue_name)
1. 配置dgbroker
DGMGRL> help create;
Creates a broker configuration
Syntax:
CREATE CONFIGURATION <configuration name> AS
PRIMARY DATABASE IS <database name>
CONNECT IDENTIFIER IS <connect identifier>;
DGMGRL> create configuration c1 as
> primary database is orcl
> connect identifier is orcl;
Configuration "c1" created with primary database "orcl"
DGMGRL> add database orcl_adg as connect identifier is orcl_adg;
Database "orcl_adg" added
DGMGRL> enable configuration;
Enabled.
DGMGRL> show configuration;
Configuration - c1
Protection Mode: MaxPerformance
Databases:
orcl - Primary database
orcl_adg - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
2. 开启fast_start failover
注:前提条件很多,报错了请看oerr
[oracle@orcl ~]$ oerr ora 16651
16651, 0000, "requirements not met for enabling fast-start failover"
// *Cause: The attempt to enable fast-start failover could not be completed
// because one or more requirements were not met:
// - The Data Guard configuration must be in either MaxAvailability
// or MaxPerformance protection mode.
// - The LogXptMode property for both the primary database and
// the fast-start failover target standby database must be
// set to SYNC if the configuration protection mode is set to
// MaxAvailability mode.
// - The LogXptMode property for both the primary database and
// the fast-start failover target standby database must be
// set to ASYNC if the configuration protection mode is set to
// MaxPerformance mode.
// - The primary database and the fast-start failover target standby
// database must both have flashback enabled.
// - No valid target standby database was specified in the primary
// database FastStartFailoverTarget property prior to the attempt
// to enable fast-start failover, and more than one standby
// database exists in the Data Guard configuration.
// *Action: Retry the command after correcting the issue:
// - Set the Data Guard configuration to either MaxAvailability
// or MaxPerformance protection mode.
// - Ensure that the LogXptMode property for both the primary
// database and the fast-start failover target standby database
// are set to SYNC if the configuration protection mode is set to
// MaxAvailability.
// - Ensure that the LogXptMode property for both the primary
// database and the fast-start failover target standby database
// are set to ASYNC if the configuration protection mode is set to
// MaxPerformance.
// - Ensure that both the primary database and the fast-start failover
// target standby database have flashback enabled.
// - Set the primary database FastStartFailoverTarget property to
// the DB_UNIQUE_NAME value of the desired target standby database
// and the desired target standby database FastStartFailoverTarget
// property to the DB_UNIQUE_NAME value of the primary database.
DGMGRL> help enable
Enables a configuration, a database, or fast-start failover
Syntax:
ENABLE CONFIGURATION;
ENABLE DATABASE <database name>;
ENABLE FAST_START FAILOVER [CONDITION <condition>];
DGMGRL> ENABLE FAST_START FAILOVER;
Enabled.
DGMGRL> help start
Starts the fast-start failover observer
Syntax:
START OBSERVER [FILE=<observer configuration file>];
DGMGRL> START OBSERVER;
Observer started
可以查看下自动切换的参数值:
DGMGRL> show configuration verbose;
Configuration - c1
Protection Mode: MaxPerformance
Databases:
orcl_adg - Primary database
orcl - (*) Physical standby database
(*) Fast-Start Failover target
Properties:
FastStartFailoverThreshold = '30'
OperationTimeout = '30'
FastStartFailoverLagLimit = '30'
CommunicationTimeout = '180'
ObserverReconnect = '0'
FastStartFailoverAutoReinstate = 'TRUE'
FastStartFailoverPmyShutdown = 'TRUE'
BystandersFollowRoleChange = 'ALL'
ObserverOverride = 'FALSE'
ExternalDestination1 = ''
ExternalDestination2 = ''
PrimaryLostWriteAction = 'CONTINUE'
Fast-Start Failover: ENABLED
Threshold: 30 seconds
Target: orcl
Observer: orcl
Lag Limit: 30 seconds
Shutdown Primary: TRUE
Auto-reinstate: TRUE
Observer Reconnect: (none)
Observer Override: FALSE
Configuration Status:
SUCCESS
3. 模拟主库宕机
kill pmon即可
DGMGRL> START OBSERVER;
Observer started
16:17:23.69 Tuesday, November 21, 2017
Initiating Fast-Start Failover to database "orcl_adg"...
Performing failover NOW, please wait...
Failover succeeded, new primary is "orcl_adg"
16:17:29.47 Tuesday, November 21, 2017
16:20:32.87 Tuesday, November 21, 2017
Initiating reinstatement for database "orcl"...
Reinstating database "orcl", please wait...
Operation requires shutdown of instance "orcl" on database "orcl"
Shutting down instance "orcl"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "orcl" on database "orcl"
Starting instance "orcl"...
ORACLE instance started.
Database mounted.
Continuing to reinstate database "orcl" ...
Reinstatement of database "orcl" succeeded
16:21:27.98 Tuesday, November 21, 2017
简直不要太自动化,主库又变为physical standby了.这个依赖于oracle的闪回特性,中间有一个reinstate原来主库的过程