Jun 22, 2015

ORA-01666: control file is for a standby database - failover over standby as primary

Few and quick steps to open the standby database as primary with failover option. Note that primary is not avialbe to switch over. Dataguad broker not configured.

Quick round-up:

SQL> select name,open_mode ,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
PROD     READ ONLY            PHYSICAL STANDBY

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 3.4206E+10 bytes
Fixed Size                  2238616 bytes
Variable Size            3422553960 bytes
Database Buffers         3.0736E+10 bytes
Redo Buffers               45682688 bytes
Database mounted.
SQL>


SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01666: control file is for a standby database


SQL> select name,open_mode,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
PROD     MOUNTED              PHYSICAL STANDBY

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Database altered.

SQL>
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

Database altered.

SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY
*
ERROR at line 1:
ORA-16139: media recovery required

-- Fail-over

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;

Database altered.
SQL> ALTER DATABASE ACTIVATE STANDBY DATABASE;

Database altered.

SQL>

-- Now verify the database status

SQL> select name,open_mode ,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
PROD      MOUNTED              PRIMARY

-- Now open the database

SQL> alter database open;

Database altered.

SQL> select name,open_mode ,database_role from v$database;

NAME      OPEN_MODE            DATABASE_ROLE
--------- -------------------- ----------------
PROD      READ WRITE           PRIMARY


-- If you have flashback on, make it off if you want.

SQL> alter database flashback off;

Database altered.


Thanks.

11 comments:

  1. Thank you for the information!

    I continued to get error even after following the steps here. Had to use manually recreated controlfile to bring up the database.

    ReplyDelete
  2. Thanks for sharing your knowledge, it was very useful.

    ReplyDelete
  3. Really help full thankyou

    ReplyDelete
  4. worked for me as well

    ReplyDelete
  5. Thank you for the information.

    ReplyDelete

Translate >>