Data Guard Broker error: Physical standby database (disabled)

Having had an outage on the disk for my test Dataguard managed by the broker I had to recreate the standby (a few archived logs went lost). The first operation is creating a standby controlfile:

alter database create standby controlfile as 'C:\Downloads\standby.ctl';

I will manually replace the files in the standby SBSWISS with those of the primary DGSWISS

SQL> select name from v$datafile;



NAME

--------------------------------------------------------------------------------

E:\ORADATA\SBGRID\SYSTEM01.DBF

E:\ORADATA\SBGRID\SYSAUX01.DBF

E:\ORADATA\SBGRID\UNDOTBS01.DBF

E:\ORADATA\SBGRID\USERS01.DBF



SQL> select * from v$controlfile;

STATUS NAME

-------



E:\ORADATA\SBGRID\CONTROL01.CTL

C:\ORACLE\FLASH_RECOVERY_AREA\SBGRID\CONTROL02.CTL



The two databases are shutdown

Primary data files are copied over the standby data files

C:\Windows\system32>e:

E:\>cd oradata

E:\oradata>copy DGSWISS\* SBSWISS

DGSWISS\CONTROL01.CTL

Overwrite SBSWISS\CONTROL01.CTL? (Yes/No/All): All

DGSWISS\REDO01.LOG

DGSWISS\REDO02.LOG

DGSWISS\REDO03.LOG

DGSWISS\SBREDO01.LOG

DGSWISS\SBREDO02.LOG

DGSWISS\SBREDO03.LOG

DGSWISS\SYSAUX01copy.DBF

DGSWISS\SYSTEM01.DBF

DGSWISS\TEMP01.DBF

DGSWISS\UNDOTBS01.DBF

DGSWISS\USERS01.DBF

       12 file(s) copied.



The standby controlfile replaces the current controlfiles on the standby

copy C:\Downloads\standby.ctl E:\ORADATA\SBSWISS\CONTROL01.CTL

copy C:\Downloads\standby.ctl C:\ORACLE\FLASH_RECOVERY_AREA\SBSWISS\CONTROL02.CTL

Restart the two databases and check the dataguard broker

DGMGRL> show configuration

Configuration - swiss



  Protection Mode: MaxAvailability

  Databases:

    DGSWISS - Primary database

    SBSWISS - Physical standby database (disabled)



Fast-Start Failover: DISABLED



Configuration Status:

SUCCESS




DGMGRL> enable database 'SBSWISS';

Error: ORA-16631: operation requires shutdown of database or instance ""



Failed.

Note that the DGMGRL reports an empty database name ''''

I tried to remove the standby and then add it again to the configuration:

DGMGRL> remove database 'SBSWISS';

Error: ORA-16627: operation disallowed since no standby databases would remain to support protection mode



Failed.

DGMGRL> enable database 'SBSWISS';

Error: ORA-16631: operation requires shutdown of database or instance ""



Failed.

DGMGRL> enable configuration;

Enabled.

DGMGRL> show configuration;



Configuration - swiss



  Protection Mode: MaxAvailability

  Databases:

    DGSWISS - Primary database

    SBSWISS - Physical standby database (disabled)



Fast-Start Failover: DISABLED



Configuration Status:

SUCCESS



DGMGRL>

Not getting any further, I resorted to the metalink and found the article ID 1161094.1

Failover/Reinstate within Dataguard configuration fails with ORA-16653 /ORA-16795 [ID 1161094.1]

Possible reason was that the flashback had not been enabled on the standby side.

SQL> alter database flashback enabled;
alter database flashback enabled

                         *

ERROR at line 1:

ORA-38722: ON or OFF expected.



SQL> alter database flashback on;
alter database flashback on

*

ERROR at line 1:

ORA-01153: an incompatible media recovery is active



SQL> recover managed standby database cancel; Media recovery complete.

SQL> alter database flashback on;

Database altered.

SQL> recover managed standby database disconnect from session;

Media recovery complete. SQL> recover managed standby database cancel;

Media recovery complete.

DGMGRL> show configuration

Configuration - swiss



  Protection Mode: MaxAvailability

  Databases:

    DGGRID - Primary database

    SBGRID - Physical standby database

      Warning: ORA-16826: apply service state is inconsistent with the DelayMins property



Fast-Start Failover: DISABLED



Configuration Status:

WARNING



the clause "using current logfile" must be issued to eliminate the warning.

SQL> recover managed standby database cancel;

SQL> recover managed standby database using current logfile disconnect from session; Media recovery complete.

Now the configuration is without warnings

DGMGRL> show configuration

Configuration - grid



  Protection Mode: MaxAvailability

  Databases:

    DGGRID - Primary database

    SBGRID - Physical standby database



Fast-Start Failover: DISABLED



Configuration Status:

SUCCESS



DGMGRL> exit



The data guard broker is now working fine.