精华内容
下载资源
问答
  • 客户的一套生产环境采用的架构是Oracle ADG + Keepalived,近期需要进行切换演练,要求我这边保障。ADG本身切换倒没啥可说的,但引入keepalived软件,就需要提前研究下这个架构。其实看了下环境配置,整体思路也非常...

    客户的一套生产环境采用的架构是Oracle ADG + Keepalived,近期需要进行切换演练,要求我这边保障。ADG本身切换倒没啥可说的,但引入keepalived软件,就需要提前研究下这个架构。其实看了下环境配置,整体思路也非常简单,说白了就是利用keepalived软件引入一个VIP,应用侧只需配置连接这个VIP即可。
    依据当前生产环境架构模拟了一套自己的测试环境。

    1.Keepalived相关配置

    关于Keepalived软件的配置和编译安装,可以参考之前《MySQL主主+Keepalived架构安装部署》中Keepalived安装部署章节。
    除了利用keepalived软件引入一个VIP,还有一些配置和脚本,脱敏如下:

    --------------------------------------------------------
    --节点1(192.168.1.124)keepalived.conf文件内容:
    --------------------------------------------------------
    [root@test04 ~]# cat /etc/keepalived/keepalived.conf
    ! Configuration File for keepalived
    
    vrrp_script chk_dg_stats {  
        script "/etc/keepalived/check_dataguard.sh" 
        interval 2
        weight -5
        fall 2  
        rise 1  
    }
    
    vrrp_instance VI_1 {
        state MASTER    
        interface eth0 
        mcast_src_ip 192.168.1.124
        virtual_router_id 131 
        priority 101 
        inopreempt
        advert_int 1         
        authentication {   
            auth_type PASS 
            auth_pass 888888   
        }
        virtual_ipaddress {    
            192.168.1.131
        }
    
        track_script {               
           chk_dg_stats             
        }
    }
    
    --------------------------------------------------------
    --节点2(192.168.1.125)keepalived.conf文件内容:
    --------------------------------------------------------
    [root@test05 ~]# cat /etc/keepalived/keepalived.conf
    ! Configuration File for keepalived
    
    vrrp_script chk_dg_stats {  
        script "/etc/keepalived/check_dataguard.sh" 
        interval 2
        weight -5
        fall 2  
        rise 1  
    }
    
    vrrp_instance VI_1 {
        state BACKUP
        interface eth0 
        mcast_src_ip 192.168.1.125
        virtual_router_id 131 
        priority 99 
        inopreempt
        advert_int 1         
        authentication {   
            auth_type PASS 
            auth_pass 888888   
        }
        virtual_ipaddress {    
            192.168.1.131
        }
    
        track_script {               
           chk_dg_stats             
        }
    }
    
    --------------------------------------------------------
    --所有节点配置脚本check_dataguard.sh,并确认具有x执行权限:
    --------------------------------------------------------
    # cat /etc/keepalived/check_dataguard.sh 
    #!/bin/bash
    dbstats=`ps -ef | grep ora_smon | grep -v grep | wc -l`
    dgstats=`ps -ef | grep ora_mrp | grep -v grep | wc -l`
    
    if [ "${dbstats}" -eq 0  ]; then
    /etc/init.d/keepalived stop
    elif [[ "${dbstats}" -gt 0 ]] && [[ "${dgstats}" -gt 0 ]]; then
    /etc/init.d/keepalived stop
    fi 
    
    说明:脚本check_dataguard.sh主要通过对ora_smon和ora_mrp进程的监控,判断哪种场景下该关闭keepalived服务:
    场景1:当不存在ora_smon进程时(数据库实例Crash);
    场景2:存在ora_smon进程同时存在ora_mrp进程时(已启动mrp进程的备库)。
    
    --添加x执行权限:
    chmod u+x /etc/keepalived/check_dataguard.sh
    [root@test04 ~]# ls -l /etc/keepalived/check_dataguard.sh
    -rwxr--r--. 1 root root 282 Jul 14 22:35 /etc/keepalived/check_dataguard.sh
    [root@test05 ~]# ls -l /etc/keepalived/check_dataguard.sh
    -rwxr--r--. 1 root root 281 Jul 14 22:36 /etc/keepalived/check_dataguard.sh
    

    Bash

    Copy

    2.ADG手工切换步骤

    1)在switchover正式切换前先在主库上手工切换几次日志,确认DG备库同步正常: 
    --PRIMARY(主库192.168.1.124)切换几次日志:
    SQL>
    alter system switch logfile; 
    alter system switch logfile; 
    alter system switch logfile; 
    --Standby (备库192.168.1.125)需确认同步正常没有延迟:
    SQL> 
    select * from v$dataguard_stats; 
    2)主库切换为备库
    -- 在PRIMARY(主库192.168.1.124)查询,确认可切换为备库:
    select OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS, FORCE_LOGGING, DATAGUARD_BROKER, GUARD_STATUS from v$database; 
    -- 在PRIMARY(主库192.168.1.124)操作,切换为备库:
    ALTER DATABASE COMMIT TO SWITCHOVER TO STANDBY WITH SESSION SHUTDOWN;
    3)备库切换为主库
    -- 在Standby(备库192.168.1.125)查询,确认可切换为主库:
    select OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS, FORCE_LOGGING, DATAGUARD_BROKER, GUARD_STATUS from v$database; 
    -- 在Standby(备库192.168.1.125)操作,切换为主库(根据SWITCHOVER_STATUS值确认用下面哪个命令):
    ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
    ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
    
    4)新主库open,新备库启动并开启MRP,新主库启动keepalived服务
    --NEW PRIMARY(新主库192.168.1.125)数据库从mount启动到open状态:
    ALTER DATABASE OPEN;
    --NEW STANDBY(新备库192.168.1.124)数据库startup启动,开启DG日志应用:
    STARTUP
    RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
    --确认NEW STANDBY(新备库192.168.1.124)DG同步正常,没有延迟:
    SQL> 
    select * from v$dataguard_stats; 
    
    5) 新主库启动keepalived服务
    --NEW PRIMARY(新主库192.168.1.125)OS层root用户启动keepalived服务:
    # /etc/init.d/keepalived start
    

    Bash

    Copy

    注意:当演练结束后,若需要switchover主备再次切换,只需要按上面规范步骤重复操作即可(注意主备角色的转换)。

    3.VIP和监听的关系

    源于最早的一次面试,两个节点的RAC,节点1主机Crash,此时应用通过节点1的VIP是否可以连接到数据库?为什么?
    我们都知道节点1主机Crash,其VIP会自动漂移节点2,ping这个IP也是通的,但是通过其连接数据库却不行!会报一个没有监听(ORA-12541: TNS:no listener)的错误。
    具体可参考:RAC 某节点不可用时,对应VIP是否可用
    那这里的环境,同样是VIP的设置,为何却可以通过VIP(192.168.1.131)连接呢?

    [oracle@test03 ~]$ sqlplus sys/oracle@192.168.1.131/demo as sysdba
    
    SQL*Plus: Release 11.2.0.4.0 Production on Tue Jul 14 23:45:23 2020
    
    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
    
    SQL> 
    

    Bash

    Copy

    实际验证,是因为这里主备库的监听配置统一都是主机名:

    [oracle@test04 admin]$ cat listener.ora
    # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
    # Generated by Oracle configuration tools.
    
    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
          (ADDRESS = (PROTOCOL = TCP)(HOST = test04)(PORT = 1521))
        )
      )
    
    ADR_BASE_LISTENER = /u01/app/oracle
    
    [oracle@test05 admin]$ cat listener.ora 
    # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
    # Generated by Oracle configuration tools.
    
    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
          (ADDRESS = (PROTOCOL = TCP)(HOST = test05)(PORT = 1521))
        )
      )
    
    ADR_BASE_LISTENER = /u01/app/oracle
    
    SID_LIST_LISTENER =
      (SID_LIST =
        (SID_DESC =
          (GLOBAL_DBNAME = jingyus)
          (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
          (SID_NAME = jingyu)
        )
      )
    

    Bash

    Copy

    如果将主机名修改为具体的IP地址,则测试同样会报错(ORA-12541: TNS:no listener)。

    展开全文
  • 12c ADG环境 二、现象描述 主库日志切换卡住(hang) SQL> alter system switch logfile; 三、处理过程 1、查看日志 <roidb02:orcldg:/u01/app/oracle/diag/rdbms/orcldg/orcldg/trace>$tail -f al*.log ...

    一、环境
    12c ADG环境

    二、现象描述

    主库日志切换卡住(hang)

    SQL> alter system switch logfile;

    三、处理过程
    1、查看日志

    <roidb02:orcldg:/u01/app/oracle/diag/rdbms/orcldg/orcldg/trace>$tail -f al*.log
    Mon Jan 08 21:04:20 2018
    ARC0: LGWR is scheduled to archive destination LOG_ARCHIVE_DEST_1 after log switch
    Mon Jan 08 21:11:21 2018
    ARC3: LGWR is scheduled to archive destination LOG_ARCHIVE_DEST_1 after log switch
    Mon Jan 08 21:19:21 2018
    ARC0: LGWR is scheduled to archive destination LOG_ARCHIVE_DEST_1 after log switch
    Mon Jan 08 21:26:22 2018
    ARC3: LGWR is scheduled to archive destination LOG_ARCHIVE_DEST_1 after log switch
    Mon Jan 08 21:34:22 2018
    ARC0: LGWR is scheduled to archive destination LOG_ARCHIVE_DEST_1 after log switch
    Mon Jan 08 21:42:19 2018
    ARC0: LGWR is scheduled to archive destination LOG_ARCHIVE_DEST_1 after log switch
    

    2、考虑归档参数

    SQL> show parameter log_archive_dest
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    log_archive_dest                     string
    log_archive_dest_1                   string      service="orcl", SYNC AFFIRM de
                                                     lay=0 optional compression=dis
                                                     able max_failure=0 max_connect
                                                     ions=1 reopen=300 db_unique_na
                                                     me="orcl" net_timeout=10, vali
                                                     d_for=(online_logfile,all_role
                                                     s)
    log_archive_dest_10                  string
    log_archive_dest_11                  string
    log_archive_dest_12                  string
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    log_archive_dest_13                  string
    log_archive_dest_14                  string
    log_archive_dest_15                  string
    log_archive_dest_16                  string
    log_archive_dest_17                  string
    log_archive_dest_18                  string
    log_archive_dest_19                  string
    log_archive_dest_2                   string      location="+DATADG/arch",  vali
                                                     d_for=(STANDBY_LOGFILE,STANDBY
                                                     _ROLE)

    3、参数明显有问题,另开一个会话

    SQL> ALTER SYSTEM SET log_archive_dest_2='location="+DATADG/arch",  valid_for=(ALL_LOGFILES,ALL_ROLES)';
    
    System altered.
    
    SQL> 

    4、查看主库日志

    ALTER SYSTEM SET log_archive_dest_2='location="+DATADG/arch",  valid_for=(ALL_LOGFILES,ALL_ROLES)' SCOPE=BOTH;
    Mon Jan 08 21:49:23 2018
    Archived Log entry 376 added for thread 1 sequence 365 ID 0x58e622f8 dest 2:
    krse_arc_driver_core: Successful archiving of previously failed ORL
    Mon Jan 08 21:49:23 2018
    ******************************************************************
    LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_1
    ******************************************************************
    Mon Jan 08 21:49:24 2018
    Destination LOG_ARCHIVE_DEST_1 no longer supports SYNCHRONIZATION
    Mon Jan 08 21:49:24 2018
    Thread 1 advanced to log sequence 368 (LGWR switch)
      Current log# 1 seq# 368 mem# 0: +DATADG/ORCLDG/ONLINELOG/group_1.399.962961189
      Current log# 1 seq# 368 mem# 1: +DATADG/ORCLDG/ONLINELOG/group_1.402.962961189
    Mon Jan 08 21:49:24 2018
    Archived Log entry 377 added for thread 1 sequence 366 ID 0x58e622f8 dest 2:
    Mon Jan 08 21:49:24 2018
    Archived Log entry 378 added for thread 1 sequence 367 ID 0x58e622f8 dest 2:
    Mon Jan 08 21:49:48 2018
    Destination LOG_ARCHIVE_DEST_1 is SYNCHRONIZED
    Mon Jan 08 21:49:49 2018
    Destination LOG_ARCHIVE_DEST_1 no longer supports SYNCHRONIZATION
    Mon Jan 08 21:49:49 2018
    Thread 1 advanced to log sequence 369 (LGWR switch)
      Current log# 2 seq# 369 mem# 0: +DATADG/ORCLDG/ONLINELOG/group_2.401.962961191
      Current log# 2 seq# 369 mem# 1: +DATADG/ORCLDG/ONLINELOG/group_2.404.962961191
    Mon Jan 08 21:49:49 2018
    Archived Log entry 383 added for thread 1 sequence 368 ID 0x58e622f8 dest 2:

    5、小结
    要理解本地归档路径参数的具体含义










    本文转自 roidba 51CTO博客,原文链接:http://blog.51cto.com/roidba/2058814,如需转载请自行联系原作者

    展开全文
  • (当发生主备角色切换时,redo日志应用会自动停止,因此备库需要执行1次或者多次的日志应用,直到scn号大于旧备用数据库成为新主数据库的SCN号) (实践:主库需要多次切换归档:ALTER SYSTEM SWITCH LOGFILE;) 6...

    方法一、删除failed 主数据库,重新利用新主库搭建standby备库
    1、dbca删除failed库(删除failed库前最好备份一下spfile文件,方便后续修改)
    (或者使用drop database删除failed库)
    2、清理归档日志

    3、配置spfile
    –从主库生成pfile文件(最好是删除failed库前备份一下spfile文件,这样修改比较简单,就不用从正常库复制了)
    create pfile=’/home/oracle/pfile_20200220.ora’ from spfile=’+DATADG/testdbdg/spfiletestdbdg.ora’;

    –修改pfile文件

    –生成新备库的spfile文件
    create spfile=’+DATADG/testdb/spfiletestdb.ora’ from pfile=’/home/oracle/pfile_20200114.ora’;

    –修改 O R A C L E H O M E / d b s 目 录 下 的 p f i l e 文 件 , 指 向 s p f i l e 文 件 [ o r a c l e @ p r i m a r y d b 1 d b s ] ORACLE_HOME/dbs目录下的pfile文件,指向spfile文件 [oracle@primarydb1 dbs] ORACLEHOME/dbspfilespfile[oracle@primarydb1dbs] cat inittestdb1.ora
    SPFILE=’+DATADG/testdb/spfiletestdb.ora’

    [oracle@primarydb2 dbs]$ cat inittestdb2.ora
    SPFILE=’+DATADG/testdb/spfiletestdb.ora’

    4、配置密码文件
    copy到备库1号机:
    scp orapwtestdb2 oracle@10.xxx.xxx.221:/u01/app/oracle/product/11.2.0/db_1/dbs/orapwtestdb1

    copy到备库2号机:
    scp orapwtestdb2 oracle@10.xxx.xxx.222:/u01/app/oracle/product/11.2.0/db_1/dbs/orapwtestdb2

    5、在新备库中创建pfile文件中的相关目录
    [oracle@standbydb1 ~]$ mkdir -p /u01/app/oracle/admin/testdb/adump

    [oracle@standbydb2 ~]$ mkdir -p /u01/app/oracle/admin/testdb/adump

    6、将数据库注册到asm中
    在节点1的oracle用户下执行:

    [oracle@primarydb1 ~]$ srvctl add database -d testdb -o /u01/app/oracle/product/11.2.0/db_1
    [oracle@primarydb1 ~]$ srvctl add instance -d testdb -i testdb1 -n primarydb1
    [oracle@primarydb1 ~]$ srvctl add instance -d testdb -i testdb2 -n primarydb2

    7、将2台实例启动到nomount状态
    SYS@testdb1> startup nomount

    SYS@testdb2> startup nomount

    8、rman连接
    [oracle@primarydb1 ~]$ rman target sys/xxx@testdbdg auxiliary sys/xxx@testdb

    Recovery Manager: Release 11.2.0.4.0 - Production on Thu Feb 20 14:16:08 2020

    Copyright © 1982, 2011, Oracle and/or its affiliates. All rights reserved.

    connected to target database: TESTDB (DBID=2812581150)
    connected to auxiliary database: TESTDB (not mounted)

    9、duplicate
    RMAN> duplicate target database for standby from active database nofilenamecheck;

    10、开库
    SYS@testdb1> select open_mode from gv$database;

    OPEN_MODE

    MOUNTED

    SYS@testdb1> alter database open;

    11、启用实时日志应用
    SYS@testdb1> alter database recover managed standby database using current logfile disconnect from session;

    Database altered.

    12、将2号实例打开
    SYS@testdb2> startup

    13、检查
    备库:
    SYS@testdb1> select name,database_role,open_mode,protection_mode from gv$database;

    NAME DATABASE_ROLE OPEN_MODE PROTECTION_MODE


    TESTDB PHYSICAL STANDBY READ ONLY WITH APPLY MAXIMUM PERFORMANCE
    TESTDB PHYSICAL STANDBY READ ONLY WITH APPLY MAXIMUM PERFORMANCE

    主库:
    SYS@testdbdg1> select name,database_role,open_mode,protection_mode from gv$database;

    NAME DATABASE_ROLE OPEN_MODE PROTECTION_MODE


    TESTDB PRIMARY READ WRITE MAXIMUM PERFORMANCE
    TESTDB PRIMARY READ WRITE MAXIMUM PERFORMANCE

    ------------------------------重建完成----------------------------------------

    方法二、利用Flashback Database策略,将数据库恢复到failover之前的时间点。(前题:主库开启了闪回)

    1、确定旧备用数据库成为主数据库的SCN。
    在新的主数据库上,执行以下查询以确定旧备用数据库成为新主数据库的SCN:
    SYS@testdbdg1> SELECT TO_CHAR(STANDBY_BECAME_PRIMARY_SCN) FROM V$DATABASE;

    TO_CHAR(STANDBY_BECAME_PRIMARY_SCN)

    7745387

    2、闪回failed的主数据库
    关闭旧的主数据库(如有必要),将其mount,并将其闪回到步骤1中查询出来的STANDBY_Become_primary_SCN值。
    [oracle@primarydb1 ~]$ srvctl stop database -d testdb

    SYS@testdb1> startup mount

    SYS@testdb1> FLASHBACK DATABASE TO SCN 7745387;

    3、将数据库转换为物理备用数据库
    3.1在旧的主数据库执行以下语句
    SYS@testdb1> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
    (以上在将控制文件转换为备用控制文件成功后dismount数据库。)

    3.2关库,并重新打开
    SYS@testdb1> SHUTDOWN IMMEDIATE;

    SYS@testdb1> STARTUP;

    4、开始将redo日志重新传输到新的物理备用数据库。
    (在新的主数据库执行以下sql)
    4.1、查询归档日志路径状态
    SELECT s.DEST_NAME,s.STATUS FROM V$ARCHIVE_DEST_STATUS s where s.DESTINATION is not null;

    4.2、如果归档路径状态异常,则运行
    ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;

    4.3、执行日志切换以确保备用数据库开始从新的主数据库接收重做数据,并验证是否已成功发送该数据。在新的主数据库执行以下SQL语句:
    SQL> ALTER SYSTEM SWITCH LOGFILE;
    SQL> SELECT DEST_ID, DEST_NAME, STATUS, PROTECTION_MODE, DESTINATION,ERROR,SRL FROM V$ARCHIVE_DEST_STATUS;

    5、在新的物理备用数据库上启用Redo Apply
    SYS@testdb1> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
    (当发生主备角色切换时,redo日志应用会自动停止,因此备库需要执行1次或者多次的日志应用,直到scn号大于旧备用数据库成为新主数据库的SCN号)
    (实践:主库需要多次切换归档:ALTER SYSTEM SWITCH LOGFILE;)
    6、确认状态
    备库:
    SYS@testdb1> select database_role,switchover_status from gv$database;

    DATABASE_ROLE SWITCHOVER_STATUS


    PHYSICAL STANDBY NOT ALLOWED
    PHYSICAL STANDBY NOT ALLOWED

    主库:
    SYS@testdbdg1> select database_role,switchover_status from gv$database;

    DATABASE_ROLE SWITCHOVER_STATUS


    PRIMARY SESSIONS ACTIVE
    PRIMARY SESSIONS ACTIVE
    ---------------闪回修复完成----------

    方法三、利用RMAN备份将Primary恢复到failover之前,重新进行日志弥补、角色切换
    1、确定旧备用数据库成为主数据库的SCN。
    在新的主数据库上,执行以下查询以确定旧备用数据库成为新主数据库的SCN:
    SYS@testdbdg1> SELECT TO_CHAR(STANDBY_BECAME_PRIMARY_SCN) FROM V$DATABASE;

    TO_CHAR(STANDBY_BECAME_PRIMARY_SCN)

    7745387

    2、Restore and recover 全库
    RMAN> RUN {
    SET UNTIL SCN <standby_became_primary_scn + 1>;
    RESTORE DATABASE; RECOVER DATABASE;
    }

    SQL> RECOVER DATABASE USIING BACKUP CONTROLFILE UNTIL CHANGE -> <standby_became_primary_scn + 1>;

    3、将数据库转换为物理备用数据库
    3.1、转换
    SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;

    3.2、重启
    SQL> SHUTDOWN IMMEDIATE;
    SQL> STARTUP MOUNT;

    4、开始将redo日志重新传输到新的物理备用数据库。
    (在新的主数据库执行以下sql)
    4.1、查询归档日志路径状态
    SELECT s.DEST_NAME,s.STATUS FROM V$ARCHIVE_DEST_STATUS s where s.DESTINATION is not null;

    4.2、如果归档路径状态异常,则运行
    ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;

    4.3、执行日志切换以确保备用数据库开始从新的主数据库接收重做数据,并验证是否已成功发送该数据。在新的主数据库执行以下SQL语句:
    SQL> ALTER SYSTEM SWITCH LOGFILE;
    SQL> SELECT DEST_ID, DEST_NAME, STATUS, PROTECTION_MODE, DESTINATION,ERROR,SRL FROM V$ARCHIVE_DEST_STATUS;

    5、在新的物理备用数据库上启用Redo Apply
    SYS@testdb1> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;

    ---------------rman备份完成----------

    展开全文
  • oracle11g ADG主备切换

    2019-09-24 01:35:44
    oracle11g ADG主备切换 1、主库 SQL> select name,open_mode,switchover_status from v$database; NAME OPEN_MODE SWITCHOVER_STATUS--------- -------------------- --------------------PROD1 READ WRITE .....

    oracle11g ADG主备切换

    1、主库

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

    NAME OPEN_MODE SWITCHOVER_STATUS
    --------- -------------------- --------------------
    PROD1 READ WRITE TO STANDBY

    SQL> alter system switch logfile;

    System altered.

    SQL> alter system archive log current;

    System altered.

    SQL> alter database commit to switchover to physical standby with session shutdown;

    Database altered.

    SQL> shutdown abort
    ORACLE instance shut down.
    SQL> startup mount
    ORACLE instance started.

    Total System Global Area 849530880 bytes
    Fixed Size 1348244 bytes
    Variable Size 511708524 bytes
    Database Buffers 331350016 bytes
    Redo Buffers 5124096 bytes
    Database mounted.
    SQL> select switchover_status from v$database;

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

    SQL> alter database open;

    Database altered.

    SQL> select switchover_status from v$database;

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

     

    2、备库

    SQL> alter database commit to switchover to primary with session shutdown;

    Database altered.

    SQL> alter database open;

    Database altered.

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

    NAME OPEN_MODE SWITCHOVER_STATUS
    --------- -------------------- --------------------
    PROD1 READ WRITE TO STANDBY

     

    3、新备库(原主库)启用实时日志应用

     

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

     

    Database altered.

     

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

     

    NAME OPEN_MODE SWITCHOVER_STATUS
    --------- -------------------- --------------------
    PROD1 READ ONLY WITH APPLY NOT ALLOWED

     

    参考链接:

    https://blog.csdn.net/kadwf123/article/details/83092607

    http://blog.chinaunix.net/uid-26313110-id-5748048.html

     

    转载于:https://www.cnblogs.com/orcl-2018/p/11565424.html

    展开全文
  • 3 主库切换归档确保最新数据同步至ADG端 alter system checkpoint; alter system switch logfile; alter system checkpoint; alter system switch logfile; alter system archive log current; alter
  • ADG备库切换成snapshot

    2017-06-09 10:28:25
    切换成snapshop standby: 1.设置flash recovery area以及合理的db_recovery_file_dest_size,db_recovery_file_dest_size根据实际情况设计...
  • ADG三种模式切换详解

    2021-09-08 14:21:30
    protection>>availability>>performance顺序直接操作即可 实例演示 由最大性能模式切换为最大可用模式 先查看ADG当前模式 --主库执行 SQL> select database_role,protection_mode,protection_level from v$database...
  • 测试过的应用环境: 主库:oracle11gr2 RAC 备库:oracle11gr2 单节点HAS 配置文件(config.ini)说明:
  • Oracle ADG 数据库完整部署、切换、备份、运维手册(绝对干货)。 阿里云上部署Oracle ADG,并且带有节点故障自动切换功能。同时,也包括数据库异常故障的处理,比如死锁、数据误删除进行恢复 Oracle ADG DG Broker ...
  • ADG主备库切换 - Failover

    千次阅读 2021-07-10 23:23:25
    在备用数据库上,此状态表示尚未从主数据库接收到切换请求。 TO PRIMARY - 数据库已准备好切换到主角色。 v$database 1 查看是否存在Gap select thread#, low_sequence#, high_sequence# from v$archive_gap; v$...
  • 阿里云上部署Oracle ADG,并且带有节点故障自动切换功能。同时,也包括数据库异常故障的处理,比如死锁、数据误删除进行恢复
  • 1,将ADG切换至Snapshot Standby sqlplus / as sysdba recover managed standby database cancel; ALTER DATABASE CONVERT TO SNAPSHOT STANDBY; alter database open; exit 2,将Snapshot Standby切换至ADG sqlplus...
  • ADG swicthover操作(主备切换

    千次阅读 2017-06-21 17:44:40
    ADG switch over(主备切换) 1:准备工作 1.1检查ADG状态是否正常 Standby Sql>select process,status fromv$managed_standby;   Note:RFS为idle。MRP0为APPLYING_LOG。   Primary Sql>SELECT RECOVERY...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 1,076
精华内容 430
关键字:

adg切换