DataGaurd环境主库崩溃后将备库切为主库

下列方法已经经过验证

主库数据库服务器完全崩溃的情况下。物理备库的打开模式为READ ONLY的情况下,可以把物理备库切换成主库。但是要丢失一部分数据

切换过程
第一:查看物理备库的打开模式
SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ ONLY

第二:查看物理备库的切换状态
SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
NOT ALLOWED

第三:关闭物理备库的当前连接回话
SQL> Alter database commit to switchover to physical standby with session shutdown;

Database altered.


第四:关闭
SQL> alter database recover managed standby database cancel;

Database altered.

第五;关闭(或是先不要执行第四步,直接执行这步)
SQL> alter database recover managed standby database finish;
alter database recover managed standby database finish
*
ERROR at line 1:
ORA-00283: recovery session canceled due to errors
ORA-16157: media recovery not allowed following successful FINISH recovery

第六:查看物理备库的切换状态
SQL> select switchover_status from v$database;

第七:切换到主库
SQL> alter database commit to switchover to primary;

Database altered.


第八:关闭物理备库
SQL> shutdown immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.

第九:启动物理备库
SQL> startup
ORACLE instance started.

Total System Global Area  409194496 bytes
Fixed Size                  2213856 bytes
Variable Size             318769184 bytes
Database Buffers           83886080 bytes
Redo Buffers                4325376 bytes
Database mounted.
Database opened.



第十:查看物理备库的打开模式
SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

第十一:查看物理备库的数据库角色
SQL> select database_role from v$database;


DATABASE_ROLE
----------------
PRIMARY

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26194851/viewspace-2120136/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26194851/viewspace-2120136/

你可能感兴趣的:(DataGaurd环境主库崩溃后将备库切为主库)