How to Create a Physical Standby Database Using Rman Duplicate Command (1)

Embed Size (px)

Citation preview

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    1/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    Alejandro Vargas | Principal Support ConsultantOracle Advanced Customer Services

    INDEX

    INDEX ...................................................................................................................................... 1Summary ................................................................................................................................. 2Prepare the Standby Database init.ora ................................................................................. 2Setup the Network ................................................................................................................... 3

    Using Rman Connect to the Primary from the Standby Server and Execute the Duplicatecommand ................................................................................................................................. 4Check the standby just created ............................................................................................... 9Enable the broker on both the primary and standby databases ........................................... 10Prepare the Listener and tnsnames files to enable DG Broker .............................................11Check connectivity from both servers to both nodes ............................................................ 12Create the Broker configuration ............................................................................................ 13Check that both databases are in sync ................................................................................. 14Enable Flashback database .................................................................................................. 16Test Switchover ..................................................................................................................... 18Test Failover .......................................................................................................................... 19

    Once the problem with the primary is solved, mount the database and reinstate it from thebroker console ....................................................................................................................... 21

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    2/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    Summary

    This document contains a quick, step-by-step walk over the procedure of creating a PhysicalStandby Database using Rman Duplicate command, not using any backup.

    Setting up a physical standby database is a simple operation when the required infrastructureis ready.

    We need 2 servers, a network that communicate both of them, and storage connected to theservers that is proportional to the database size + extra space for archive logs and backups.

    The Oracle Home is installed on both servers at the same patch level; you may use also clon-ing to install the RDBMS home on the standby server.

    Prepare the Standby Database init.ora

    Make a copy of the Primary init.ora and change the highlighted values

    [oracle@lnx2 dbs]$ cat initneo.ora

    *.audit_trail='db'

    *.compatible='11.2.0.0.0'

    #*.control_files= -- commented out

    *.db_block_size=8192

    *.db_domain=''

    *.db_name='sati'

    *.db_unique_name='neo'

    *.db_create_file_dest='/oracle/app/oradata'

    *.db_recovery_file_dest='/oracle/app/flash_recovery_area'

    *.db_recovery_file_dest_size=4039114752

    *.diagnostic_dest='/oracle/app'

    *.local_listener='LISTENER_NEO'

    *.memory_target=262144000

    *.open_cursors=300

    *.processes=150

    *.remote_login_passwordfile='EXCLUSIVE'*.undo_tablespace='UNDOTBS1'

    *.audit_file_dest='/oracle/app/admin/neo/adump'

    http://blogs.oracle.com/AlejandroVargas/2010/11/oracle_rdbms_home_install_usin.htmlhttp://blogs.oracle.com/AlejandroVargas/2010/11/oracle_rdbms_home_install_usin.htmlhttp://blogs.oracle.com/AlejandroVargas/2010/11/oracle_rdbms_home_install_usin.htmlhttp://blogs.oracle.com/AlejandroVargas/2010/11/oracle_rdbms_home_install_usin.html
  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    3/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    Setup the Network

    # listener.ora Network Configuration File: /oracle/app/product/11.2.0/dbhome_1/net-work/admin/listener.ora

    # Generated by Oracle configuration tools.

    LISTENER =

    (DESCRIPTION_LIST =

    (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = lnx2)(PORT = 1521))

    )

    )

    SID_LIST_LISTENER =

    (SID_LIST =

    (SID_DESC =

    (GLOBAL_DBNAME = neo)

    (ORACLE_HOME = /oracle/app/product/11.2.0/dbhome_1 )

    (SID_NAME = neo)

    )

    )

    ADR_BASE_LISTENER = /oracle/app

    # tnsnames.ora Network Configuration File: /oracle/app/product/11.2.0/dbhome_1/net-work/admin/tnsnames.ora

    # Generated by Oracle configuration tools.

    SATI =

    (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = lnx1)(PORT = 1521))

    (CONNECT_DATA =

    (SERVER = DEDICATED)

    (SERVICE_NAME = sati)

    )

    )

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    4/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    NEO =(DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = lnx2)(PORT = 1521))

    (CONNECT_DATA =

    (SERVER = DEDICATED)

    (SERVICE_NAME = neo) (UR=A)

    )

    )

    LISTENER_NEO =

    (DESCRIPTION_LIST =

    (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = lnx2)(PORT = 1521))

    )

    )

    Using Rman Connect to the Primary from the Standby Server and Execute theDuplicate command

    [oracle@lnx2 dbs]$ rman target sys/oracle@sati auxiliary sys/oracle@neo

    Recovery Manager: Release 11.2.0.1.0 - Production on Fri Nov 5 15:38:56 2010

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

    connected to target database: SATI (DBID=1784854517)

    connected to auxiliary database: SATI (not mounted)

    RMAN> run {

    2> allocate channel prmy1 type disk;3> allocate auxiliary channel stby type disk;

    4> duplicate target database for standby from active database

    5> ;

    6> }

    using target database control file instead of recovery catalog

    allocated channel: prmy1

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    5/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    channel prmy1: SID=42 device type=DISK

    allocated channel: stby

    channel stby: SID=20 device type=DISK

    Starting Duplicate Db at 05-NOV-10

    contents of Memory Script:

    {

    backup as copy reusetargetfile '/oracle/app/product/11.2.0/dbhome_1/dbs/orapwsati' auxiliary format

    '/oracle/app/product/11.2.0/dbhome_1/dbs/orapwneo' ;

    }

    executing Memory Script

    Starting backup at 05-NOV-10

    Finished backup at 05-NOV-10

    contents of Memory Script:

    {

    sql clone "alter system set control_files =

    ''/oracle/app/oradata/NEO/controlfile/o1_mf_6f8twy27_.ctl'',''/oracle/app/flash_recovery_area/NEO/controlfile/o1_mf_6f8twy2m_.ctl'' comment=

    ''Set by RMAN'' scope=spfile";

    backup as copy current controlfile for standby auxiliary format'/oracle/app/oradata/NEO/controlfile/o1_mf_6f8twy27_.ctl';

    restore clone controlfile to'/oracle/app/flash_recovery_area/NEO/controlfile/o1_mf_6f8twy2m_.ctl' from

    '/oracle/app/oradata/NEO/controlfile/o1_mf_6f8twy27_.ctl';

    sql clone "alter system set control_files =

    ''/oracle/app/oradata/NEO/controlfile/o1_mf_6f8twy27_.ctl'',''/oracle/app/flash_recovery_area/NEO/controlfile/o1_mf_6f8twy2m_.ctl'' comment=

    ''Set by RMAN'' scope=spfile";

    shutdown clone immediate;

    startup clone nomount;

    }

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    6/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    executing Memory Script

    sql statement: alter system set control_files = ''/oracle/app/oradata/NEO/control-file/o1_mf_6f8twy27_.ctl'',''/oracle/app/flash_recovery_area/NEO/controlfile/o1_mf_6f8twy2m_.ctl'' comment=''Set by RMAN'' scope=spfile

    Starting backup at 05-NOV-10

    channel prmy1: starting datafile copy

    copying standby control file

    output file name=/oracle/app/product/11.2.0/dbhome_1/dbs/snapcf_sati.ftag=TAG20101105T153624 RECID=5 STAMP=734283385

    channel prmy1: datafile copy complete, elapsed time: 00:00:04

    Finished backup at 05-NOV-10

    Starting restore at 05-NOV-10

    channel stby: copied control file copy

    Finished restore at 05-NOV-10

    sql statement: alter system set control_files = ''/oracle/app/oradata/NEO/control-file/o1_mf_6f8twy27_.ctl'',''/oracle/app/flash_recovery_area/NEO/controlfile/o1_mf_6f8twy2m_.ctl'' comment=''Set by RMAN'' scope=spfile

    Oracle instance shut down

    connected to auxiliary database (not started)

    Oracle instance started

    Total System Global Area 263639040 bytes

    Fixed Size 1335892 bytes

    Variable Size 192941484 bytes

    Database Buffers 67108864 bytes

    Redo Buffers 2252800 bytes

    allocated channel: stby

    channel stby: SID=18 device type=DISK

    contents of Memory Script:

    {

    sql clone 'alter database mount standby database';

    }

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    7/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    executing Memory Script

    sql statement: alter database mount standby database

    contents of Memory Script:

    {

    set newname for clone tempfile 1 to new;

    switch clone tempfile all;

    set newname for clone datafile 1 to new;

    set newname for clone datafile 2 to new;

    set newname for clone datafile 3 to new;

    set newname for clone datafile 4 to new;

    set newname for clone datafile 5 to new;

    backup as copy reusedatafile 1 auxiliary format new

    datafile 2 auxiliary format new

    datafile 3 auxiliary format new

    datafile 4 auxiliary format new

    datafile 5 auxiliary format new

    ;

    sql 'alter system archive log current';

    }

    executing Memory Script

    executing command: SET NEWNAME

    renamed tempfile 1 to /oracle/app/oradata/NEO/datafile/o1_mf_temp_%u_.tmp in con-trol file

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    Starting backup at 05-NOV-10

    channel prmy1: starting datafile copy

    input datafile file number=00001 name=/oracle/app/oradata/SATI/datafile/o1_mf_sys-tem_6d6sqcbv_.dbf

    output file name=/oracle/app/oradata/NEO/datafile/o1_mf_system_05ls8hkd_.dbftag=TAG20101105T153645

    channel prmy1: datafile copy complete, elapsed time: 00:01:59

    channel prmy1: starting datafile copy

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    8/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    input datafile file number=00002name=/oracle/app/oradata/SATI/datafile/o1_mf_sysaux_6d6sqwmb_.dbf

    output file name=/oracle/app/oradata/NEO/datafile/o1_mf_sysaux_06ls8ho5_.dbftag=TAG20101105T153645

    channel prmy1: datafile copy complete, elapsed time: 00:01:14

    channel prmy1: starting datafile copy

    input datafile file number=00005 name=/oracle/app/oradata/SATI/datafile/o1_mf_ex-ample_6d6xjybg_.dbf

    output file name=/oracle/app/oradata/NEO/datafile/o1_mf_example_07ls8hqg_.dbftag=TAG20101105T153645

    channel prmy1: datafile copy complete, elapsed time: 00:00:16

    channel prmy1: starting datafile copy

    input datafile file number=00003 name=/oracle/app/oradata/SATI/datafile/o1_mf_un-dotbs1_6d6sr03n_.dbf

    output file name=/oracle/app/oradata/NEO/datafile/o1_mf_undotbs1_08ls8hr0_.dbftag=TAG20101105T153645

    channel prmy1: datafile copy complete, elapsed time: 00:00:07

    channel prmy1: starting datafile copy

    input datafile file number=00004name=/oracle/app/oradata/SATI/datafile/o1_mf_users_6d6sr3p3_.dbf

    output file name=/oracle/app/oradata/NEO/datafile/o1_mf_users_09ls8hr8_.dbftag=TAG20101105T153645

    channel prmy1: datafile copy complete, elapsed time: 00:00:02

    Finished backup at 05-NOV-10

    sql statement: alter system archive log current

    contents of Memory Script:

    {

    switch clone datafile all;

    }

    executing Memory Script

    datafile 1 switched to datafile copy

    input datafile copy RECID=5 STAMP=734283797 file name=/oracle/app/oradata/NEO/data-file/o1_mf_system_05ls8hkd_.dbf

    datafile 2 switched to datafile copy

    input datafile copy RECID=6 STAMP=734283797 file name=/oracle/app/oradata/NEO/data-file/o1_mf_sysaux_06ls8ho5_.dbf

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    9/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    datafile 3 switched to datafile copy

    input datafile copy RECID=7 STAMP=734283798 file name=/oracle/app/oradata/NEO/data-

    file/o1_mf_undotbs1_08ls8hr0_.dbfdatafile 4 switched to datafile copy

    input datafile copy RECID=8 STAMP=734283799 file name=/oracle/app/oradata/NEO/data-file/o1_mf_users_09ls8hr8_.dbf

    datafile 5 switched to datafile copy

    input datafile copy RECID=9 STAMP=734283799 file name=/oracle/app/oradata/NEO/data-file/o1_mf_example_07ls8hqg_.dbf

    Finished Duplicate Db at 05-NOV-10

    released channel: prmy1

    released channel: stby

    RMAN> **end-of-file**

    RMAN>

    Check the standby just created

    [oracle@lnx2 dbs]$ sql

    SQL*Plus: Release 11.2.0.1.0 Production on Sat Nov 6 03:20:12 2010

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

    Connected to:

    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

    With the Partitioning, OLAP, Data Mining and Real Application Testing options

    SQL> select open_mode,database_role from V$Database;

    OPEN_MODE DATABASE_ROLE

    -------------------- ----------------

    MOUNTED PHYSICAL STANDBY

    SQL> archive log list;

    Database log mode Archive Mode

    Automatic archival Enabled

    Archive destination USE_DB_RECOVERY_FILE_DEST

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    10/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    Oldest online log sequence 0

    Next log sequence to archive 0

    Current log sequence 0

    SQL> show parameters broker

    NAME TYPE VALUE

    ------------------------------------ ----------- ------------------------------

    dg_broker_config_file1 string /oracle/app/product/11.2.0/dbh

    ome_1/dbs/dr1neo.dat

    dg_broker_config_file2 string /oracle/app/product/11.2.0/dbh

    ome_1/dbs/dr2neo.dat

    dg_broker_start boolean FALSE

    Enable the broker on both the primary and standby databases

    On The Primary:

    SQL> show parameters broker

    NAME TYPE VALUE

    ------------------------------------ ----------- -----------------------

    dg_broker_config_file1 string /oracle/app/product/11.2.0/dbh

    ome_1/dbs/dr1sati.dat

    dg_broker_config_file2 string /oracle/app/product/11.2.0/dbh

    ome_1/dbs/dr2sati.dat

    dg_broker_start boolean FALSE

    SQL> alter system set dg_broker_start=true scope=both;

    System altered.

    On the Standby:

    SQL> show parameters broker

    NAME TYPE VALUE

    ------------------------------------ ----------- --------------------

    dg_broker_config_file1 string /oracle/app/product/11.2.0/dbh

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    11/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    ome_1/dbs/dr1neo.dat

    dg_broker_config_file2 string /oracle/app/product/11.2.0/dbh

    ome_1/dbs/dr2neo.dat

    dg_broker_start boolean FALSE

    SQL> alter system set dg_broker_start=true scope=both;

    System altered.

    Prepare the Listener and tnsnames files to enable DG Broker

    On The Primary:

    SID_LIST_LISTENER =

    (SID_LIST =

    (SID_DESC =

    (GLOBAL_DBNAME = sati_DGMGRL )

    (ORACLE_HOME = /oracle/app/product/11.2.0/dbhome_1 )

    (SID_NAME = sati )

    )

    )

    On The Standby:

    SID_LIST_LISTENER =

    (SID_LIST =

    (SID_DESC =

    (GLOBAL_DBNAME = neo_DGMGRL )

    (ORACLE_HOME = /oracle/app/product/11.2.0/dbhome_1 )

    (SID_NAME = neo )

    )

    )

    tnsnames.ora entries for both Primary and Standby:

    NEO =

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    12/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = lnx2)(PORT = 1521))

    (CONNECT_DATA =

    (SERVER = DEDICATED)

    (SERVICE_NAME = neo_DGMGRL) (UR=A)

    )

    )

    Check connectivity from both servers to both nodes

    Node 1:

    [oracle@lnx1 admin]$ sqlplus sys/oracle@neo as sysdba ;

    SQL*Plus: Release 11.2.0.1.0 Production on Sat Nov 6 03:32:22 2010

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

    Connected to:

    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

    With the Partitioning, OLAP, Data Mining and Real Application Testing options

    SQL> exit

    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Pro-duction

    With the Partitioning, OLAP, Data Mining and Real Application Testing options

    [oracle@lnx1 admin]$ sqlplus sys/oracle@sati as sysdba ;

    SQL*Plus: Release 11.2.0.1.0 Production on Sat Nov 6 03:32:39 2010

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

    Connected to:

    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

    With the Partitioning, OLAP, Data Mining and Real Application Testing options

    Node 2:

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    13/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    [oracle@lnx2 admin]$ sqlplus sys/oracle@neo as sysdba

    SQL*Plus: Release 11.2.0.1.0 Production on Sat Nov 6 03:37:43 2010

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

    Connected to:

    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

    With the Partitioning, OLAP, Data Mining and Real Application Testing options

    SQL> exit

    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Pro-

    ductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options

    [oracle@lnx2 admin]$ sqlplus sys/oracle@sati as sysdba

    SQL*Plus: Release 11.2.0.1.0 Production on Sat Nov 6 03:37:52 2010

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

    Connected to:

    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

    With the Partitioning, OLAP, Data Mining and Real Application Testing options

    Create the Broker configuration

    [oracle@lnx1 admin]$ dgmgrl sys/oracle

    DGMGRL for Linux: Version 11.2.0.1.0 - Production

    Copyright (c) 2000, 2009, Oracle. All rights reserved.

    Welcome to DGMGRL, type "help" for information.

    Connected.

    DGMGRL> create configuration dgsati as primary database is sati connect identifieris sati;

    Configuration "dgsati" created with primary database "sati"

    DGMGRL> add database neo as connect identifier is neo maintained as physical;

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    14/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    Database "neo" added

    DGMGRL> show configuration;

    Configuration - dgsati

    Protection Mode: MaxPerformance

    Databases:

    sati - Primary database

    neo - Physical standby database

    Fast-Start Failover: DISABLED

    Configuration Status:

    DISABLED

    DGMGRL> enable configuration;

    Enabled

    DGMGRL> enable database neo;

    Enabled.

    Check that both databases are in sync

    Script:

    ------

    CLEAR SCREEN

    ARCHIVE LOG LIST;

    col host_name for a10

    col db_unique_name for a10

    col name for a10

    select NAME,DB_UNIQUE_NAME,HOST_NAME,OPEN_MODE,DATABASE_ROLE from v$database, v$in-stance ;

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    15/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    On the Primary:

    Database log mode Archive Mode

    Automatic archival Enabled

    Archive destination /oracle/app/flash_recovery_area/SATI/archivelog

    Oldest online log sequence 13

    Next log sequence to archive 15

    Current log sequence 15

    NAME DB_UNIQUE_ HOST_NAME OPEN_MODE DATABASE_ROLE

    ---------- ---------- ---------- -------------------- ----------------

    SATI sati lnx1 READ WRITE PRIMARY

    On the Standby:

    Database log mode Archive Mode

    Automatic archival EnabledArchive destination USE_DB_RECOVERY_FILE_DEST

    Oldest online log sequence 13

    Next log sequence to archive 0

    Current log sequence 15

    NAME DB_UNIQUE_ HOST_NAME OPEN_MODE DATABASE_ROLE

    ---------- ---------- ---------- -------------------- ----------------

    SATI neo lnx2 MOUNTED PHYSICAL STANDBY

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    16/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    Enable Flashback database

    On The Primary Database:

    SQL> alter system set db_flashback_retention_target=60 scope=both;

    System altered.

    SQL> shutdown immediate;Database closed.

    Database dismounted.

    ORACLE instance shut down.

    On The Standby Database:

    SQL> alter system set db_flashback_retention_target=60 scope=both;

    System altered.

    SQL> alter database flashback on;

    Database altered.

    SQL> select name,database_role,flashback_on from v$database;

    NAME DATABASE_ROLE FLASHBACK_ON

    --------- ---------------- ------------------

    SATI PHYSICAL STANDBY YES

    On The Primary Database:

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    17/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    SQL> startup mount

    ORACLE instance started.

    Total System Global Area 263639040 bytes

    Fixed Size 1335892 bytes

    Variable Size 222301612 bytes

    Database Buffers 37748736 bytes

    Redo Buffers 2252800 bytes

    Database mounted.

    SQL> alter database flashback on;

    Database altered.

    SQL> alter database open;

    Database altered.

    SQL> select name,database_role,flashback_on from v$database;

    NAME DATABASE_ROLE FLASHBACK_ON

    ---------- ---------------- ------------------

    SATI PRIMARY YES

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    18/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    Test Switchover

    Note that it is important to connect using user/password@database syntax otherwise DG-MGRL will not succeed to shutdown and restart the old primary as the new standby, and youwill be requested to do that manually

    See ORA-1031 Insufficient Privileges During Switchover via DGMGRL (Doc ID 740327.1)

    [oracle@lnx1 ~]$ dgmgrl sys/oracle@neo

    DGMGRL for Linux: Version 11.2.0.1.0 - Production

    Copyright (c) 2000, 2009, Oracle. All rights reserved.

    Welcome to DGMGRL, type "help" for information.

    Connected.

    DGMGRL> switchover to sati

    Performing switchover NOW, please wait...

    New primary database "sati" is opening...

    Operation requires shutdown of instance "neo" on database "neo"

    Shutting down instance "neo"...

    ORA-01109: database not open

    Database dismounted.

    ORACLE instance shut down.

    Operation requires startup of instance "neo" on database "neo"

    Starting instance "neo"...

    ORACLE instance started.

    Database mounted.

    Switchover succeeded, new primary is "sati"

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    19/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    Test Failover

    Failover differ from switchover because instead of converting the primary into a standby, theprimary crashes and is left as it is, while the standby is opened as primary.

    in order to convert the failed primary into a standby you should have enabled flashback data-base, otherwise you will need to rebuild the failed primary.

    Status before the crash, sati is the primary:

    Database log mode Archive Mode

    Automatic archival Enabled

    Archive destination USE_DB_RECOVERY_FILE_DEST

    Oldest online log sequence 108

    Next log sequence to archive 110

    Current log sequence 110

    NAME DB_UNIQUE_ HOST_NAME OPEN_MODE DATABASE_ROLE

    ---------- ---------- ---------- -------------------- ----------------

    SATI sati lnx1 READ WRITE PRIMARY

    Neo is the standby:

    Database log mode Archive Mode

    Automatic archival Enabled

    Archive destination USE_DB_RECOVERY_FILE_DEST

    Oldest online log sequence 108

    Next log sequence to archive 0

    Current log sequence 109

    NAME DB_UNIQUE_ HOST_NAME OPEN_MODE DATABASE_ROLE

    ---------- ---------- ---------- -------------------- ----------------

    SATI neo lnx2 MOUNTED PHYSICAL STANDBY

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    20/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    Database Sati crashes:

    SQL> shutdown abort;

    ORACLE instance shut down.

    Sun Nov 07 11:55:46 2010

    Shutting down instance (abort)

    License high water mark = 4

    USER (ospid: 7185): terminating the instance

    Instance terminated by USER, pid = 7185

    Sun Nov 07 11:55:48 2010

    Instance shutdown complete

    DBA doesnt succeed to restart the database and initiate failover to the Standby:

    [oracle@lnx1 ~]$ dgmgrl sys/oracle@neo

    DGMGRL for Linux: Version 11.2.0.1.0 - Production

    Copyright (c) 2000, 2009, Oracle. All rights reserved.

    Welcome to DGMGRL, type "help" for information.

    Connected.

    DGMGRL> show configuration

    Configuration - dgsati

    Protection Mode: MaxPerformance

    Databases:

    sati - Primary database

    neo - Physical standby database

    Fast-Start Failover: DISABLED

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    21/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    Configuration Status:ORA-01034: ORACLE not available

    ORA-16625: cannot reach database "sati"

    DGM-17017: unable to determine configuration status

    DGMGRL> failover to neo

    Performing failover NOW, please wait...

    Failover succeeded, new primary is "neo"

    From the database, note that a new incarnation was created:

    Database log mode Archive Mode

    Automatic archival Enabled

    Archive destination USE_DB_RECOVERY_FILE_DEST

    Oldest online log sequence 1

    Next log sequence to archive 1

    Current log sequence 1

    NAME DB_UNIQUE_ HOST_NAME OPEN_MODE DATABASE_ROLE

    ---------- ---------- ---------- -------------------- ----------------

    SATI neo lnx2 READ WRITE PRIMARY

    Once the problem with the primary is solved, mount the database andreinstate it from the broker console

    SQL> startup mount;

    ORACLE instance started.

    Total System Global Area 263639040 bytes

    Fixed Size 1335892 bytes

    Variable Size 222301612 bytes

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    22/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    Database Buffers 37748736 bytes

    Redo Buffers 2252800 bytes

    Database mounted.

    Note that the database is on the previous incarnation and still see itself as a primary:

    Database log mode Archive Mode

    Automatic archival Enabled

    Archive destination USE_DB_RECOVERY_FILE_DEST

    Oldest online log sequence 108

    Next log sequence to archive 110

    Current log sequence 110

    NAME DB_UNIQUE_ HOST_NAME OPEN_MODE DATABASE_ROLE

    ---------- ---------- ---------- -------------------- ----------------

    SATI sati lnx1 MOUNTED PRIMARY

    From dgmgrl check the configuration and reinstate sati:

    ------------------------------------------------------

    DGMGRL> show configuration

    Configuration - dgsati

    Protection Mode: MaxPerformance

    Databases:

    neo - Primary database

    sati - Physical standby database (disabled)

    ORA-16661: the standby database needs to be reinstated

    Fast-Start Failover: DISABLED

    Configuration Status:

    SUCCESS

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    23/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    DGMGRL> reinstate database satiReinstating database "sati", please wait...

    Operation requires shutdown of instance "sati" on database "sati"

    Shutting down instance "sati"...

    ORA-01109: database not open

    Database dismounted.

    ORACLE instance shut down.

    Operation requires startup of instance "sati" on database "sati"

    Starting instance "sati"...

    ORACLE instance started.

    Database mounted.

    Continuing to reinstate database "sati" ...

    Reinstatement of database "sati" succeeded

    On sati's alertlog we see it was flashed back and synched with the new primary:

    Sun Nov 07 12:04:43 2010

    FLASHBACK DATABASE TO SCN 1057456

    Flashback Restore Start

    Flashback Restore Complete

    Flashback Media Recovery Start

    Serial Media Recovery started

    ...

    Completed: FLASHBACK DATABASE TO SCN 1057456

    alter database convert to physical standby

    ALTER DATABASE CONVERT TO PHYSICAL STANDBY (sati)

    Clearing standby activation ID 1786143206 (0x6a7661e6)

    ...

  • 8/3/2019 How to Create a Physical Standby Database Using Rman Duplicate Command (1)

    24/24

    How To Create a Physical Standby DatabaseUsing RMAN Duplicate CommandOver the Network

    Media Recovery ContinuingMedia Recovery Log/oracle/app/flash_recovery_area/SATI/archivelog/2010_11_07/o1_mf_1_1_6fg1n3n6_.arc

    Media Recovery Log/oracle/app/flash_recovery_area/SATI/archivelog/2010_11_07/o1_mf_1_2_6fg1n4xl_.arc

    Media Recovery Log/oracle/app/flash_recovery_area/SATI/archivelog/2010_11_07/o1_mf_1_3_6fg1nr82_.arc

    Status after reinstate on both databases:

    The new Standby:

    Database log mode Archive Mode

    Automatic archival Enabled

    Archive destination USE_DB_RECOVERY_FILE_DEST

    Oldest online log sequence 4

    Next log sequence to archive 0

    Current log sequence 4

    NAME DB_UNIQUE_ HOST_NAME OPEN_MODE DATABASE_ROLE

    ---------- ---------- ---------- -------------------- ----------------

    SATI sati lnx1 MOUNTED PHYSICAL STANDBY

    The new Primary:

    Database log mode Archive Mode

    Automatic archival Enabled

    Archive destination USE_DB_RECOVERY_FILE_DEST

    Oldest online log sequence 2

    Next log sequence to archive 4

    Current log sequence 4

    NAME DB_UNIQUE_ HOST_NAME OPEN_MODE DATABASE_ROLE

    ---------- ---------- ---------- -------------------- ----------------

    SATI neo lnx2 READ WRITE PRIMARY