Thursday, June 29, 2017

switch-over database roles..



On primary

select name,open_mode,database_role,db_unique_name,protection_mode from v$database;
alter database commit to switchover to standby;
startup mount;
alter database recover managed standby database disconnect from session;
select name,open_mode,database_role,db_unique_name,protection_mode from v$database;


Now go to the originally standby database

alter database commit to switchover to primary;
alter database open;
select name,open_mode,database_role,db_unique_name,protection_mode from v$database;


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

Errors Handled 


SQL> alter database commit to switchover to primary;
SQL> alter database commit to switchover to primary;
alter database commit to switchover to primary
*
ERROR at line 1:
ORA-16139: media recovery required


SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

SWITCHOVER_STATUS
--------------------
RECOVERY NEEDED

SQL> RECOVER MANAGED STANDBY DATABASE FINISH;
Media recovery complete.
SQL> alter database commit to switchover to primary;

Database altered.
----------------------------------------
If you get an error in the above command like

ORA-01093: ALTER DATABASE CLOSE only permitted with no sessions connected
Did followng and worked fine for me
select switchover_status from v$database;
select sid, process, program from v$session where type = 'USER';

alter database commit to switchover to primary with session shutdown;
---------------------------------------------



No comments:

Post a Comment