zoukankan      html  css  js  c++  java
  • 『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

     

  • 相关阅读:
    iOS MVC、MVVM、MVP详解
    消息队列(mq)是什么?
    使用 tail 结合 grep 查找日志关键字并高亮及显示所在行上下文
    Linux下实现高可用软件-Keepalived基础知识梳理
    手动编译部署LNMP环境(CentOS7.5+Nginx-1.18.0+MySQL-5.7.30+PHP-7.4.14)
    linux 查看硬盘使用情况
    解决vue3.0新建项目无法选中Manually select features
    运行vue项目时报错:You may use special comments to disable some warnings. Use // eslint-disable-next-line to ignore the next line. Use /* eslint-disable */ to ignore all warnings in a file.
    git pull 报错remote: HTTP Basic: Access denied fatal: Authentication failed for 的解决方法
    Excel文档导出——后端返回文件流,前端实现下载功能
  • 原文地址:https://www.cnblogs.com/KT-melvin/p/6816769.html
Copyright © 2011-2022 走看看