ADG环境备库强制启动——snapshot standby

一、环境说明

主库环境不动的情况下,备库转换为主库,可读写,为了不毁坏原有的ADG环境,并且可以让ADG随时恢复,采用了保存点的方式实现需求。

此类操作,在11g以前的数据库中通过guarantee flashback database功能实现,在11g+的数据库中则是通过Snapshot Standby Database完成。

二、官方说明(11g+)

A snapshot standby database is a fully updatable standby database. A snapshot standby database receives and archives, but does not apply, redo data from a primary database. Redo data received from the primary database is applied when a snapshot standby database is converted back into a physical standby database, after discarding all local updates to the snapshot standby database.

A snapshot standby database typically diverges from its primary database over time because redo data from the primary database is not applied as it is received. Local updates to the snapshot standby database will cause additional divergence. The data in the primary database is fully protected however, because a snapshot standby can be converted back into a physical standby database at any time, and the redo data received from the primary will then be applied.

A snapshot standby database provides disaster recovery and data protection benefits that are similar to those of a physical standby database. Snapshot standby databases are best used in scenarios where the benefit of having a temporary, updatable snapshot of the primary database justifies increased time to recover from primary database failures.

snapshot standby database 是可更新状态,数据库可读写,在此状态时,可以接收和存档redo数据,但是不会应用主库的redo数据。在快照备库所有本地更新被回滚后,切换回物理备库时,开始应用从主库接受到的redo数据。

快照备库时,备库通常时从主库分离出来的,本地变更只会变更在本地的snapshot standby database上。不论此时的备库本地发生什么样的变化,主库的数据都时完好的,不会受到备库的影响。备库可以随时从snapshot状态切换回physical状态。

snapshot模式在灾备和数据保护方面,与物理备库相似。但是snapshot有可以做主库数据的临时更新验证,相当于主库的可读写快照,合理的增加了从主库恢复的时间。

注:使用snapshot模式,需要特别注意备库的归档日志磁盘空间,确保,snapshot期间,备库归档日志不会溢出,否则可能会引起主库的日志清理异常,最终影响主库归档。

三、切换为snapshot standby

  1. 停止日志应用

    alter database recover managed standby database cancel;

    检查应用状态,确定当前已同步到最新数据后,停止日志同步。

  2. 开启FRA快速闪回区(不需要开启flashback)

    select flashback_on from v$database;
    
    FLASHBACK_ON
    ------------------------------------------------------
    NO
    
    
    show parameter recover 
    
    NAME				     TYPE			       VALUE
    ------------------------------------ --------------------------------- ------------------------------
    db_recovery_file_dest		     string
    db_recovery_file_dest_size	     big integer		       0
    db_unrecoverable_scn_tracking	     boolean			       TRUE
    recovery_parallelism		     integer			       0
    
    -----开启FRA-----
    alter system set db_recovery_file_dest='/u01/app/oracle/recover' scope=spfile;
    alter system set db_recovery_file_dest_size=2G scope=spfile;
    
    --重启实例
    shutdown immediate 
    
    startup mount
    

     snapshot不需要开启快速flashback功能

  3. mount状态

    要转换为snapshot状态,备库必须为mount状态

  4. 转换为snapshot

    alter database convert to snapshot standby;
    
    alter database open;
    
    select open_mode,DATABASE_ROLE from v$database;
    
    OPEN_MODE						     DATABASE_ROLE
    ------------------------------------ ----------------------------------
    READ WRITE						     SNAPSHOT STANDBY
    
    
    set line 500
    col RESTORE_POINT_TIME for a10
    col time for a40
    col name for a50
    select * from v$RESTORE_POINT;
    
           SCN DATABASE_INCARNATION# GUARANTEE STORAGE_SIZE TIME					 RESTORE_PO PRESERVED NAME
    ---------- --------------------- --------- ------------ ---------------------------------------- ---------- --------- --------------------------------------------------
      19395945		       1 YES	      524288000 16-DEC-19 03.16.30.000000000 PM 		    YES       SNAPSHOT_STANDBY_REQUIRED_12/16/2019 15:16:30
    

    covert 到snapshot状态时,会自动创建一个保存点,可以在v$resotre_point视图中查看

四、切换回physical standby database

--mount状态下,切换为physical standby
shutdown immediate
startup mount
alter database convert to physical standby;

--重启实例
shutdown immediate;
startup

--开始应用
alter database recover managed standby database disconnect from session;
或者:
alter database recover managed standby database using current logfile disconnect from session;

SQL> select open_mode,DATABASE_ROLE from v$database;

OPEN_MODE						     DATABASE_ROLE
------------------------------------------------------------ ------------------------------------
READ ONLY WITH APPLY					     PHYSICAL STANDBY

set line 500
col RESTORE_POINT_TIME for a10
col time for a40
col name for a50
select * from v$RESTORE_POINT;

no rows selected

[oracle@o11204d1 recover]$ ll
total 4
drwxr-x--- 4 oracle oinstall 4096 Dec 16 15:16 O1124DB_DG

当数据库切换回physical standby时,保存点被自动删除。(务必确认保存点被删除,否则,会写满FRA)

补充:手动删除保存点

drop restore point "SNAPSHOT_STANDBY_REQUIRED_12/16/2019 15:16:30";

 

 

参考:

https://docs.oracle.com/cd/E11882_01/server.112/e41134/manage_ps.htm#SBYDB4801

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Hannah_JK

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

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

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

打赏作者

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

抵扣说明:

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

余额充值