failover以及利用flashback将故障主库拉回DG中

如果不开启flashback的话,DG就要重新搭建

由于主库已经不可访问,我们所有的操作都在备库完成:

主库

SQL> shutdown abort

ORACLE instance shut down.

 

备库切换成主库

SQL> alter database recover managed standby database cancel;

 

Database altered.

 

SQL>  alter database recover managed standby database finish;

 

Database altered.

 

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

 

OPEN_MODE             DATABASE_ROLE    SWITCHOVER_STATUS

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

READ ONLY             PHYSICAL STANDBY TO PRIMARY

 

SQL>  alter database commit to switchover to primary;

 

Database altered.

SQL> alter database open;

 

Database altered.

 

或者 shutdown immediate+startup

新主库查看状态

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

 

OPEN_MODE             DATABASE_ROLE    SWITCHOVER_STATUS

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

READ WRITE             PRIMARY              FAILED DESTINATION

 

 

现在利用flashback重建DG

在新的主库上执行下面操作:

SQL> select to_char(standby_became_primary_scn) from v$database;

 

TO_CHAR(STANDBY_BECAME_PRIMARY_SCN)

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

1066862

 

在之前的主库上,也就是现在的备库上执行下面的操作:

[oracle@primary prod]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Fri Oct 19 10:46:40 2018

 

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

 

Connected to an idle instance.

 

SQL> startup mount;

ORACLE instance started.

 

Total System Global Area  830930944 bytes

Fixed Size                    2257800 bytes

Variable Size                  545262712 bytes

Database Buffers          276824064 bytes

Redo Buffers                    6586368 bytes

Database mounted.

SQL> flashback database to scn 1066862;

 

Flashback complete.

 

SQL> alter database convert to physical standby;

 

Database altered.

 

SQL> shutdown immediate;

ORA-01507: database not mounted

 

 

ORACLE instance shut down.

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@primary prod]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Fri Oct 19 10:48:06 2018

 

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

 

Connected to an idle instance.

 

SQL> startup;

ORACLE instance started.

 

Total System Global Area  830930944 bytes

Fixed Size                    2257800 bytes

Variable Size                  545262712 bytes

Database Buffers          276824064 bytes

Redo Buffers                    6586368 bytes

Database mounted.

Database opened.

SQL> alter database recover managed standby database using current logfile disconnect from session;

 

Database altered.

 

原来的主库现在已经加入到dg中,现在是新备库

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

OPEN_MODE             DATABASE_ROLE    SWITCHOVER_STATUS

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

READ ONLY WITH APPLY PHYSICAL STANDBY NOT ALLOWED

 

现在主库的状态

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

 

OPEN_MODE             DATABASE_ROLE    SWITCHOVER_STATUS

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

READ WRITE             PRIMARY              SESSIONS ACTIVE

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值