• 『ORACLE』 DG切换主备库角色(11g)


    切换前enmo1为主库,enmo2为备库

    [oracle@enmo1 admin]$ sqlplus / as sysdba

    SQL*Plus: Release 11.2.0.4.0 Production on Sat May 6 10:14:57 2017

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


    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options

    查看主库的基本信息:

    SYS@enmo1 hey~1->select open_mode,protection_mode,database_role,switchover_status from v$database;

    OPEN_MODE            PROTECTION_MODE             DATABASE_ROLE         SWITCHOVER_STATUS
    -------------------- ----------------------------- ------------------------ ------------------------
    READ WRITE           MAXIMUM PERFORMANCE      PRIMARY                      TO STANDBY

    查看备库的基本信息:

    SYS@enmo2 hey~2->select open_mode,protection_mode,database_role,switchover_status from v$database;

    OPEN_MODE                   PROTECTION_MODE             DATABASE_ROLE         SWITCHOVER_STATUS
    ------------------------- ----------------------------- ------------------------ ------------------------
    READ ONLY WITH APPLY MAXIMUM PERFORMANCE      PHYSICAL STANDBY      NOT ALLOWED

    备库应用日志保持和主库数据一致(如果不一致,执行如下语句应用日志)

    SYS@enmo2 hey~2->recover managed standby database using current logfile disconnect from session;
    Media recovery complete.

    SYS@enmo2 hey~2->recover managed standby database cancel;
    Media recovery complete.

    主库切换到备库角色并查看切换之后的状态为RECOVERY NEEDED

    SYS@enmo1 hey~1->alter database commit to switchover to physical standby with session shutdown;

    Database altered.

    SYS@enmo1 hey~1->shutdown abort;

    ORACLE instance started.

    Total System Global Area 830930944 bytes
    Fixed Size 2257800 bytes
    Variable Size 700451960 bytes
    Database Buffers 121634816 bytes
    Redo Buffers 6586368 bytes
    Database mounted.
    SYS@enmo1 hey~1->select switchover_status from v$database;

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

    切换应用日志,然后在查看切换状态为TO primary正常:

    SYS@enmo1 hey~1->recover managed standby database using current logfile disconnect from session;
    Media recovery complete.
    SYS@enmo1 hey~1->select switchover_status from v$database;

    SWITCHOVER_STATUS
    --------------------
    TO PRIMARY

    备库切主库:

    SYS@enmo2 hey~2->select open_mode,protection_mode,database_role,switchover_status from v$database;

    OPEN_MODE PROTECTION_MODE DATABASE_ROLE SWITCHOVER_STATUS
    -------------------- -------------------- ---------------- --------------------
    MOUNTED MAXIMUM PERFORMANCE PHYSICAL STANDBY TO PRIMARY

    SYS@enmo2 hey~2->alter database commit to switchover to primary with session shutdown;

    Database altered.

    SYS@enmo2 hey~2->alter database open;

    Database altered.

    SYS@enmo2 hey~2->select switchover_status,database_role from v$database;

    SWITCHOVER_STATUS DATABASE_ROLE
    -------------------- ----------------
    FAILED DESTINATION PRIMARY

    SYS@enmo2 hey~2->select open_mode,protection_mode,database_role from v$database;

    OPEN_MODE PROTECTION_MODE DATABASE_ROLE
    -------------------- -------------------- ----------------
    READ WRITE MAXIMUM PERFORMANCE PRIMARY

     

  • 相关阅读:
    十四、数据库公共字段处理
    十、前端tag、自定义tag、filter和simple_tag
    kafka生产、消费py脚本
    django模板filter及自定义filter
    django基础,前后端分离数据传参
    django基础——使用django form校验数据
    django自带的后台管理框架django-admin
    django基础——前后端分离,页面分页
    django基础——数据库的增删改查
    django基础——models数据库操作
  • 原文地址:https://www.cnblogs.com/KT-melvin/p/6816769.html
Copyright © 2020-2023  润新知