oracle 12.2.0.1 使用 active dataguard broker 之三 fast_start failover

os: centos 7.4
database:12.2.0.1 + dbf

switchover
一般指的时正常情况下,人为执行的切换命令或者在符合某些条件执行的。不会丢失数据

failover
一般指的是实例失效的情况下,进行的故障转移。丢失的数据多少依赖配置的dg级别。

生产环境肯定时希望能够 fast failover的,这是就需要额外设置下。

dataguard broker 自动 failover

DGMGRL> SHOW FAST_START FAILOVER;

Fast-Start Failover: DISABLED

  Threshold:          30 seconds
  Target:             (none)
  Observer:           (none)
  Lag Limit:          30 seconds
  Shutdown Primary:   TRUE
  Auto-reinstate:     TRUE
  Observer Reconnect: (none)
  Observer Override:  FALSE

Configurable Failover Conditions
  Health Conditions:
    Corrupted Controlfile          YES
    Corrupted Dictionary           YES
    Inaccessible Logfile            NO
    Stuck Archiver                  NO
    Datafile Write Errors          YES

  Oracle Error Conditions:
    (none)

DGMGRL> enable fast_start failover;
Warning: ORA-16827: Flashback Database is disabled

启用 fast_start failover 是要设置 flashback database

启用 flashback database

SQL> alter system set db_recovery_file_dest_size = 4G ;

System altered.

SQL> alter system set db_recovery_file_dest='/u01/app/oracle/fra/' ;

System altered.

SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
NO

SQL> alter database flashback on;

Database altered.

SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
YES

SQL> show parameter db_recovery;

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest		     string	 /u01/app/oracle/fra/
db_recovery_file_dest_size	     big integer 4G

primary 在 open 就可以修改 flashback on
physical standby 在 mount 可以修改 flashback on 或者取消 redo apply 也可以应用,如下:

SQL> alter database flashback on;

alterdatabase flashback on

*

ERRORat line 1:

ORA-01153:an incompatible media recovery is active

SQL> alter database recover managed standby database cancel;

Databasealtered.

SQL> alter database flashback on;

Database altered.

SQL> select flashback_on from v$database;

FLASHBACK_ON

------------------
YES

SQL> alter database recover managed standby database disconnect from session ;

Database altered.

所以,归档模式和 flashback database 在前期就一并设置了,这很重要。

再次设置

DGMGRL> enable fast_start failover;
Enabled.

DGMGRL> show configuration;

Configuration - dgconf

  Protection Mode: MaxPerformance
  Members:
  orclp  - Primary database
    Warning: ORA-16819: fast-start failover observer not started

    orcls1 - (*) Physical standby database 
      Warning: ORA-16819: fast-start failover observer not started

Fast-Start Failover: ENABLED

Configuration Status:
WARNING   (status updated 45 seconds ago)

DGMGRL> start observer;

[W000 07/09 22:41:16.40] FSFO target standby is orcls1
[W000 07/09 22:41:18.95] Observer trace level is set to USER
[W000 07/09 22:41:18.95] Try to connect to the primary.
[W000 07/09 22:41:18.95] Try to connect to the primary tns_orclp.
[W000 07/09 22:41:18.96] The standby orcls1 is ready to be a FSFO target
[W000 07/09 22:41:20.96] Connection to the primary restored!
[W000 07/09 22:41:22.97] Disconnecting from database tns_orclp.

新打开一个窗口

$dgmgrl 
DGMGRL for Linux: Release 12.2.0.1.0 - Production on Mon Jul 9 22:42:43 2018

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

Welcome to DGMGRL, type "help" for information.
DGMGRL> 
DGMGRL> connect sys/oracleoracle@tns_orclp;
Connected to "orclp"
Connected as SYSDBA.
DGMGRL> 
DGMGRL> show configuration;

Configuration - dgconf

  Protection Mode: MaxPerformance
  Members:
  orclp  - Primary database
    orcls1 - (*) Physical standby database 

Fast-Start Failover: ENABLED

Configuration Status:
SUCCESS   (status updated 18 seconds ago)

验证

在主库上 shutdown abort

SQL> shutdown abort;
ORACLE instance shut down.

查看备库状态

SQL> select open_mode from v$database;

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

start observer 窗口一直提示错误

[W000 07/09 22:46:50.17] Failed to ping the new standby.
[W000 07/09 22:46:51.17] Try to connect to the new standby orclp.
[W000 07/09 22:46:54.17] Connection to the new standby restored!

旧的master变为新的standby

SQL> startup mount;

这个时候就需要使用 flashback database,如果dg保护级别不够,损失的就是这一部分已提交的数据
类似 postgresql 的 pg_rewind,有兴趣的哥们可以搜搜看。

start observer 窗口有提示信息

[W000 07/09 22:51:26.68] Try to connect to the new standby orclp.
[W000 07/09 22:51:28.68] Connection to the new standby restored!
[W000 07/09 22:52:00.72] Try to connect to the primary tns_orcls1.
[W000 07/09 22:52:02.72] Connection to the primary restored!
[W000 07/09 22:52:03.73] Wait for new primary to be ready to reinstate.
[W000 07/09 22:52:04.73] New primary is now ready to reinstate.
[W000 07/09 22:52:04.73] Issuing REINSTATE command.

22:52:04.73  Monday, July 09, 2018
Initiating reinstatement for database "orclp"...
Reinstating database "orclp", please wait...
Reinstatement of database "orclp" succeeded
22:52:25.65  Monday, July 09, 2018
[W000 07/09 22:52:25.76] Successfully reinstated database orclp.
[W000 07/09 22:52:25.76] The standby orclp is ready to be a FSFO target
[W000 07/09 22:52:25.76] The reinstatement of standby orclp was just done

查询新的standby状态

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ ONLY WITH APPLY

参考:
https://docs.oracle.com/en/database/oracle/oracle-database/12.2/high-availability.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

数据库人生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值