Please read the preliminary notes, that are the same here than for settings up Data Guard.
Unless explicitly specified, all commands below are executed as oracle.
On primaryServer :
Connected.
LogXptMode = 'ASYNC'
LogXptMode = 'ASYNC'
Property "logxptmode" updated
Property "logxptmode" updated
LogXptMode = 'sync'
LogXptMode = 'sync'
Succeeded.
Configuration - ORACLE_SIDDR Protection Mode: MaxAvailability Databases: ORACLE_SID_PRIMARYDATACENTER - Primary database ORACLE_SID_STANDBYDATACENTER - Physical standby database Fast-Start Failover: DISABLED Configuration Status: SUCCESS
dgmgrl / << EOC show database '${ORACLE_SID}_PRIMARYDATACENTER' 'LogXptMode'; show database '${ORACLE_SID}_STANDBYDATACENTER' 'LogXptMode'; edit database '${ORACLE_SID}_PRIMARYDATACENTER' set property logxptmode=SYNC; edit database '${ORACLE_SID}_STANDBYDATACENTER' set property logxptmode=SYNC; show database '${ORACLE_SID}_PRIMARYDATACENTER' 'LogXptMode'; show database '${ORACLE_SID}_STANDBYDATACENTER' 'LogXptMode'; edit configuration set protection mode as MAXAVAILABILITY; show configuration; EOC
Welcome to DGMGRL, type "help" for information. Connected. DGMGRL> LogXptMode = 'async' DGMGRL> LogXptMode = 'async' DGMGRL> Property "logxptmode" updated DGMGRL> Property "logxptmode" updated DGMGRL> LogXptMode = 'sync' DGMGRL> LogXptMode = 'sync' DGMGRL> Succeeded. DGMGRL> Configuration - ORACLE_SIDDR Protection Mode: MaxAvailability Databases: ORACLE_SID_PRIMARYDATACENTER - Primary database ORACLE_SID_STANDBYDATACENTER - Physical standby database Fast-Start Failover: DISABLED Configuration Status: SUCCESS
We'll now test the switchover with these new parameters :
The only difference you may notice from the screenshots of the procedures linked above is when running show configuration verbose. The Protection Mode is now :
Protection Mode: MaxAvailability
At this step, as root, we're supposed to : lvcreate -n lv_orafra_oracle_sid -L 100g data_vg mkfs -t ext4 /dev/data_vg/lv_orafra_oracle_sid lvdisplay /dev/mapper/data_vg-lv_orafra_oracle_sid mkdir /appli/oracle/ORACLE_SID/orafra mount /dev/mapper/data_vg-lv_orafra_oracle_sid /appli/oracle/ORACLE_SID/orafra chown -R oracle:oinstall /appli/oracle/ORACLE_SID/orafra chmod 750 /appli/oracle/ORACLE_SID/orafra/ Then append to /etc/fstab : /dev/data_vg/lv_orafra_oracle_sid /appli/oracle/ORACLE_SID/orafra ext4 defaults 1 2 NB : 100GB is an estimated size... ==> But this can be done more easily with the "createFs" tools.
don't forget to create the FlashBack filesystem on both servers !
sqlplus '/ as sysdba' << EOSQL alter system set db_recovery_file_dest_size = 100G; alter system set db_recovery_file_dest='/appli/oracle/$ORACLE_SID/orafra' scope=both; alter system set db_flashback_retention_target=480 scope=both; column type format a11; show parameter db_recovery show parameter db_flashback EOSQL
System altered. System altered. System altered. NAME TYPE VALUE ----------------------------- --------------- ------------------------------ db_recovery_file_dest string /appli/oracle/ORACLE_SID/orafra db_recovery_file_dest_size big integer 100G NAME TYPE VALUE -------------------------------- ---------- -------- db_flashback_retention_target integer 480
don't forget to declare the FlashBack filesystem on both servers !
Database altered.
sqlplus -s '/ as sysdba' << EOSQL alter database recover managed standby database cancel; alter database flashback on; alter database recover managed standby database using current logfile disconnect from session; EOSQL
Database altered. Database altered. Database altered.
sqlplus -s '/ as sysdba' << EOSQL column name format a15; column flashback_on format a20; select name, flashback_on from v\$database; EOSQL
NAME FLASHBACK_ON
------------- ---------------
ORACLE_SID YES
sqlplus -s '/ as sysdba' << EOSQL CREATE OR REPLACE TRIGGER start_DGservice after startup on database DECLARE mirole VARCHAR(30); miservicenames varchar2(2000); miservice varchar2(100) := '$ORACLE_SID'; milen number := 0; BEGIN SELECT DATABASE_ROLE INTO mirole FROM V\$DATABASE; IF mirole = 'PRIMARY' THEN DBMS_SERVICE.START_SERVICE(miservice); select trim(replace(value,miservice)) into miservicenames from v\$parameter where name = 'service_names'; milen := length(miservicenames); if (milen > 0) then if (substr(miservicenames,milen,1) = ',') then miservicenames:= substr(miservicenames,1,milen-1); end if; end if; execute immediate 'alter system set service_names='''||miservicenames||''' scope=spfile'; end if; END; / EOSQL
System altered.
PL/SQL procedure successfully completed.If this returns :
ERROR at line 1:
ORA-44305: service ORACLE_SID is running
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.DBMS_SERVICE", line 454
ORA-06512: at "SYS.DBMS_SERVICE", line 375
ORA-06512: at line 1
Try :
PL/SQL procedure successfully completed.Then retry the "start" command above. This weird behavior is the reason why this whole step doesn't work from the command line with a giant heredoc
set linesize 200 COL "TRIGGER_NAME" FORMAT A20 COL "TRIGGERING_EVENT" FORMAT A20 select TRIGGER_NAME, TRIGGER_TYPE, TRIGGERING_EVENT, STATUS, ACTION_TYPE from dba_triggers where TRIGGER_NAME like '%DG%';
TRIGGER_NAME TRIGGER_TYPE TRIGGERING_EVENT STATUS ACTION_TYPE ------------------ --------------- ------------------- ---------- -------------- START_DGSERVICE AFTER EVENT STARTUP ENABLED PL/SQL
WALLET_LOCATION = ...
block for each instance should do the trick.Oracle Secret Store Tool : Version 11.2.0.4.0 - Production Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. Enter password: walletPassword Enter password again: walletPassword
TNS_ADMIN
's value is /home/oracle/network/admin.
Oracle Secret Store Tool : Version 11.2.0.4.0 - Production
Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
Enter wallet password: walletPassword
Create credential oracle.security.client.connect_string1
Oracle Secret Store Tool : Version 11.2.0.4.0 - Production
Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
Enter wallet password: walletPassword
Create credential oracle.security.client.connect_string2
Oracle Secret Store Tool : Version 11.2.0.4.0 - Production Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. Enter wallet password: walletPassword List credential (index: connect_string username) 2: ORACLE_SID_STANDBYDATACENTER sys 1: ORACLE_SID_PRIMARYDATACENTER sys
Still as oracle on primaryServer :
cat << EOF >> /home/oracle/network/admin/sqlnet.ora WALLET_LOCATION = (SOURCE = (METHOD = FILE) (METHOD_DATA = (DIRECTORY = $walletDirectory) ) ) DIAG_ADR_ENABLED = OFF SQLNET.WALLET_OVERRIDE = TRUE EOF
Let's check we can make a passwordless connection to the broker using the wallet, as oracle on primaryServer
Connected.
Connected.
Technically speaking, you should disconnect from the 1st connection, leave DGMGRL, then try the 2nd connection. Because after the 1st connection succeeded, you're connected to ORACLE_SID_PRIMARYDATACENTER. No big deal anyway, since this is where we're testing from.
On primaryServer :
As oracle on primaryServer :
Don't forget to : export ORACLE_SID=ORACLE_SID
connect /
Connected.If this outputs, instead :
ORA-12578: TNS:wallet open failedIt's because you forgot to undo the edits made to /home/oracle/network/admin/sqlnet.ora at a previous step.
show configuration
Configuration - ORACLE_SIDDR Protection Mode: MaxAvailability Databases: ORACLE_SID_PRIMARYDATACENTER - Primary database ORACLE_SID_STANDBYDATACENTER - Physical standby database Fast-Start Failover: DISABLED Configuration Status: SUCCESS
Enabled.
Property "faststartfailoverthreshold" updated
Fast-Start Failover: ENABLED Threshold: 120 seconds Target: ORACLE_SID_STANDBYDATACENTER Observer: observer.mycompany.tld Lag Limit: 30 seconds (not in use) Shutdown Primary: TRUE Auto-reinstate: TRUE Observer Reconnect: (none) Observer Override: FALSE Configurable Failover Conditions Health Conditions: Corrupted Controlfile YES Corrupted Dictionary YES Inaccessible Logfile NO Stuck Archiver NO Datafile Offline YES Oracle Error Conditions: (none)
dgmgrl / << EOC show configuration; enable fast_start failover; edit configuration set property FastStartFailoverThreshold = '120'; show fast_start failover; EOC
Welcome to DGMGRL, type "help" for information. Connected. DGMGRL> Configuration - ORACLE_SIDDR Protection Mode: MaxAvailability Databases: ORACLE_SID_PRIMARYDATACENTER - Primary database ORACLE_SID_STANDBYDATACENTER - Physical standby database Fast-Start Failover: DISABLED Configuration Status: SUCCESS DGMGRL> Enabled. DGMGRL> Property "faststartfailoverthreshold" updated DGMGRL> Fast-Start Failover: ENABLED Threshold: 120 seconds Target: ORACLE_SID_STANDBYDATACENTER Observer: observer.mycompany.tld Lag Limit: 30 seconds (not in use) Shutdown Primary: TRUE Auto-reinstate: TRUE Observer Reconnect: (none) Observer Override: FALSE Configurable Failover Conditions Health Conditions: Corrupted Controlfile YES Corrupted Dictionary YES Inaccessible Logfile NO Stuck Archiver NO Datafile Offline YES Oracle Error Conditions: (none)
Everything is configured : if primaryServer goes down, FSFO should automatically failover to standbyServer. Let's turn primaryServer down without notice/clean shutdown and see what happens.
ORACLE instance shut down.
connect /
Connected.
Configuration - ORACLE_SIDDR Protection Mode: MaxAvailability Databases: ORACLE_SID_STANDBYDATACENTER - Primary database Warning: ORA-16817: unsynchronized fast-start failover configuration ORACLE_SID_PRIMARYDATACENTER - (*) Physical standby database (disabled) ORA-16661: the standby database needs to be reinstated Fast-Start Failover: ENABLED Configuration Status: WARNING
We can see that standbyServer has become the primary database and that the whole system has an unstable status.
Connected to an idle instance. Database mounted.
Password: sys password
Connected.
Reinstating database "ORACLE_SID_PRIMARYDATACENTER", please wait... Error: ORA-16653: failed to reinstate database Failed. Reinstatement of database "ORACLE_SID_PRIMARYDATACENTER" failedOr :
Reinstating database "ORACLE_SID_PRIMARYDATACENTER", please wait... Error: ORA-16657: reinstatement of database in progress Failed. Database reinstatement for "ORACLE_SID_PRIMARYDATACENTER" in progress.
This means the Oracle Observer is currently already reinstating the database (which is its expected behavior, FSFO RuLeZ !!! ). To make sure :
show configurationConfiguration - ORACLE_SIDDR Protection Mode: MaxAvailability Databases: ORACLE_SID_STANDBYDATACENTER - Primary database ORACLE_SID_PRIMARYDATACENTER - (*) Physical standby database Fast-Start Failover: ENABLED Configuration Status: SUCCESS
Reinstating database "ORACLE_SID_PRIMARYDATACENTER", please wait... Operation requires shutdown of instance "ORACLE_SID" on database "ORACLE_SID_PRIMARYDATACENTER" Reinstatement of database "ORACLE_SID_PRIMARYDATACENTER" succeeded