Wednesday, August 19, 2015

Convert Standalone to RAC using Active Dataguard Switchover with little downtime


Oracle 11g R2 (11.2.0.3) OE - Linux 5.10 x64
Migrate standalone database into RAC
using Active Standby Database (Dataguard Broker
)


Checking available instance status on RAC where we are going to create RAC standby from standalone primary database.

Purpose for this documentation is to Migrate Database into 2 Node RAC from Standalone Primary database with very little downtime.  Within 15 min of little downtime, I have moved standalone database into 2 Node RAC with all task.  I used Oracle Dataguard Broker to complete this task.

[oracle@vm213 grid]$ ps -ef | grep pmon
oracle    7853     1  0 06:46 ?        00:00:00 asm_pmon_+ASM
oracle    7917  2771  0 06:48 pts/1    00:00:00 grep pmon


[oracle@vm213 grid]$ . oraenv
ORACLE_SID = [oracle] ? +ASM
The Oracle base has been set to /grid/app/oracle
[oracle@vm213 grid]$ asmcmd
ASMCMD> lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512   4096  1048576     15688    15627                0           15627              0             N  DG_DATA1/

Checking register services with listener


[oracle@vm213 admin]$ lsnrctl services

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 18-AUG-2015 08:21:26

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=vm213.ora.com)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
Service "LAVA" has 1 instance(s).
  Instance "LAVA", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
Service "LAVA.ora.com" has 1 instance(s).
  Instance "LAVA", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
Service "LAVAXDB.ora.com" has 1 instance(s).
  Instance "LAVA", status READY, has 1 handler(s) for this service...
    Handler(s):
      "D000" established:0 refused:0 current:0 max:1022 state:ready
         DISPATCHER <machine: vm213.ora.com, pid: 30857>
         (ADDRESS=(PROTOCOL=tcp)(HOST=vm213.ora.com)(PORT=44721))
Service "LAVA_DGMGRL" has 1 instance(s).
  Instance "LAVA", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully

SQL> sho parameter service

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      LAVA.ora.com

Enable Force Logging on Primary (standalone) and preparing for active duplication.

SQL> ALTER DATABASE FORCE LOGGING ;

Database altered.

SQL> alter system set log_archive_dest_2='SERVICE=LAVAS valid_for=(online_logfile,primary_role) db_unique_name=LAVAS' ;

System altered.

SQL> SHOW PARAMETER log_archive_dest_2

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2                   string      SERVICE=LAVAS valid_for=(onlin
                                                 e_logfile,primary_role) db_uni
                                                 que_name=LAVAS

SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;

SQL> ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(LAVA,LAVAS)';

SQL> ALTER SYSTEM SET DG_BROKER_START=TRUE;

SQL> SHOW PARAMETER DB_CREATE_FILE

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest                  string      +DG_DATA1

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO ;

SQL> ALTER DATABASE ADD STANDBY LOGFILE SIZE 100M ;

SQL> ALTER DATABASE ADD STANDBY LOGFILE SIZE 100M ;

SQL> ALTER DATABASE ADD STANDBY LOGFILE SIZE 100M ;

SQL> ALTER DATABASE ADD STANDBY LOGFILE SIZE 100M ;



ON STANDBY SITE

CREATE PARAMETER FILE on RAC Standby

Vi /u01/app/oracle/product/11.2.0/dbhome_1/dbs/initLAVAS1.ora

*.cluster_database=false
*.compatible='11.2.0.0.0'
*.db_create_file_dest='+DATA_DG'
*.db_domain='ora.com'
*.db_name='LAVA'
*.db_unique_name='LAvAS'
LAvA2.instance_number=2
LAVA1.instance_number=1
*.remote_listener='rac-scan:1521'
*.sga_target=663748608
LAVA2.thread=2
LAVA1.thread=1
LAVA1.undo_tablespace='UNDOTBS1'
LAVA2.undo_tablespace='UNDOTBS2'


Create tnsnames.ora on primary and standby site  (on both node)

LAVA =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = vm213.ora.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = LAVA.ora.com)
    )
  )


LAVAS =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac-scan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = LAVAS)
    )
  )


Create Static Listener on Primary and Standby site (on both node)

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = LAVA)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0.3/dbhome_1)
      (SID_NAME = LAVA)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = LAVA_DGMGRL)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0.3/dbhome_1)
      (SID_NAME = LAVA)
    )
  )

LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = vm213.ora.com)(PORT = 1521))
  )


Verify listener on both nodes for standby and Primary

[oracle@rac123 ~]$ lsnrctl services

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 07-JUL-2015 08:56:33

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0 state:ready
         LOCAL SERVER
Service "LAVAS" has 1 instance(s).
  Instance "LAVAS1", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:17 refused:3
         LOCAL SERVER
Service "LAVAS.ora.com" has 1 instance(s).
  Instance "LAVAS1", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:4 refused:0 state:ready
         LOCAL SERVER
Service "LAVAS_DGB.ora.com" has 1 instance(s).
  Instance "LAVAS1", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:4 refused:0 state:ready
         LOCAL SERVER
Service "LAVAS_DGMGRL" has 1 instance(s).
  Instance "LAVAS1", status UNKNOWN, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:0 refused:0
         LOCAL SERVER
The command completed successfully



On Primary Site: Create standby database from primary using active duplication.


[oracle@vm213 admin]$ rman target sys/oracle@LAVA AUXILIARY sys/oracle@lavas

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Aug 18 09:52:57 2015

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

connected to target database: LAVA (DBID=535734803)
connected to auxiliary database: LAVA (not mounted)

Active duplication

RMAN> duplicate target database for standby from active database ;

Starting Duplicate Db at 18-AUG-15
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=27 device type=DISK

contents of Memory Script:
{
   backup as copy reuse
   targetfile  '/u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/orapwLAVA' auxiliary format
 '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwLAVAS1'   ;
}
executing Memory Script

Starting backup at 18-AUG-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=69 device type=DISK
Finished backup at 18-AUG-15

contents of Memory Script:
{
   backup as copy current controlfile for standby auxiliary format  '+DATA_DG/lavas/controlfile/current.269.884406263';
   sql clone "create spfile from memory";
   shutdown clone immediate;
   startup clone nomount;
   sql clone "alter system set  control_files =
  ''+DATA_DG/lavas/controlfile/current.269.884406263'' comment=
 ''Set by RMAN'' scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

Starting backup at 18-AUG-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
output file name=/u01/app/oracle/product/11.2.0.3/dbhome_1/dbs/snapcf_LAVA.f tag=TAG20150818T095318 RECID=2 STAMP=888054800
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 18-AUG-15

sql statement: create spfile from memory

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     663908352 bytes

Fixed Size                     2231312 bytes
Variable Size                197133296 bytes
Database Buffers             461373440 bytes
Redo Buffers                   3170304 bytes

sql statement: alter system set  control_files =   ''+DATA_DG/lavas/controlfile/current.269.884406263'' comment= ''Set by RMAN'' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     663908352 bytes

Fixed Size                     2231312 bytes
Variable Size                197133296 bytes
Database Buffers             461373440 bytes
Redo Buffers                   3170304 bytes

contents of Memory Script:
{
   sql clone 'alter database mount standby database';
}
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 reuse
   datafile  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 +DATA_DG in control file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting backup at 18-AUG-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+DG_DATA1/lava/datafile/system.256.888044287
output file name=+DATA_DG/lavas/datafile/system.270.884406289 tag=TAG20150818T095345
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=+DG_DATA1/lava/datafile/sysaux.257.888044287
output file name=+DATA_DG/lavas/datafile/sysaux.271.884406335 tag=TAG20150818T095345
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=+DG_DATA1/lava/datafile/example.269.888044403
output file name=+DATA_DG/lavas/datafile/example.272.884406381 tag=TAG20150818T095345
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=+DG_DATA1/lava/datafile/undotbs1.258.888044287
output file name=+DATA_DG/lavas/datafile/undotbs1.273.884406405 tag=TAG20150818T095345
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+DG_DATA1/lava/datafile/users.259.888044287
output file name=+DATA_DG/lavas/datafile/users.274.884406413 tag=TAG20150818T095345
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 18-AUG-15

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=2 STAMP=884406415 file name=+DATA_DG/lavas/datafile/system.270.884406289
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=884406415 file name=+DATA_DG/lavas/datafile/sysaux.271.884406335
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=884406415 file name=+DATA_DG/lavas/datafile/undotbs1.273.884406405
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=884406416 file name=+DATA_DG/lavas/datafile/users.274.884406413
datafile 5 switched to datafile copy
input datafile copy RECID=6 STAMP=884406416 file name=+DATA_DG/lavas/datafile/example.272.884406381
Finished Duplicate Db at 18-AUG-15


After successfully creating standby database verify the below commands

[oracle@vm213 ~]$ sqlplus / as sysdba

SQL> alter system switch logfile ;

System altered.

SQL> col dest_name for a39
SQL> col error for a40
SQL> select dest_name , status, error from v$archive_dest where rownum < 3 ;

DEST_NAME                               STATUS    ERROR
--------------------------------------- --------- ----------------------------------------
LOG_ARCHIVE_DEST_1                      VALID
LOG_ARCHIVE_DEST_2                      ERROR     ORA-16047: DGID mismatch between
                                                  destination setting and target database


SQL> save error


Set the LOG_ARCHIVE_CONFIG parameter on Standby to fix above error also set other parameter on RAC Standby as below


SQL> alter system set log_archive_dest_2='SERVICE=LAVA valid_for=(ALL_LOGFILES,ALL_ROLES) db_unique_name=LAVA' ;

SQL> ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(LAVA,LAVAS)';

SQL> ALTER SYSTEM SET DG_BROKER_START=TRUE;

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO ;

SQL> alter system switch logfile ;


After fixing verify the error.  This time error gone.

SQL> alter system switch logfile;
SQL> @error

DEST_NAME            STATUS    ERROR
-------------------- --------- ------
LOG_ARCHIVE_DEST_1   VALID
LOG_ARCHIVE_DEST_2   VALID


Create Broker Configuration

DGMGRL> connect sys/oracle@lava
Connected.

DGMGRL> show configuration
ORA-16532: Data Guard broker configuration does not exist

Configuration details cannot be determined by DGMGRL

DGMGRL> create configuration LAVA_CONFIG AS PRIMARY DATABASE IS LAVA CONNECT IDENTIFIER IS "LAVA" ;
Configuration "lava_config" created with primary database "lava"

DGMGRL> ADD DATABASE LAVAS AS CONNECT IDENTIFIER IS "LAVAS" MAINTAINED AS PHYSICAL ;
Database "lavas" added

DGMGRL> SHOW CONFIGURATION

Configuration - lava_config

  Protection Mode: MaxPerformance
  Databases:
    lava  - Primary database
    lavas - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
DISABLED


Ensure RAC Standby is running on only one node and cluster database parameter must be false else you will get below error

DGMGRL> enable configuration ;
Enabled.

DGMGRL> show configuration  ;

Configuration - lava_config

  Protection Mode: MaxPerformance
  Databases:
    lava  - Primary database
    lavas - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
ORA-16610: command "ENABLE DATABASE lavas" in progress
DGM-17017: unable to determine configuration status

or

DGMGRL> show configuration  ;

Configuration - lava_config

  Protection Mode: MaxPerformance
  Databases:
    lava  - Primary database
    lavas - Physical standby database
      Warning: ORA-16532: Data Guard broker configuration does not exist

Fast-Start Failover: DISABLED

Configuration Status:
WARNING

or if you try to switch you will get below error.

DGMGRL> switchover to lavas
Performing switchover NOW, please wait...
Error: ORA-16644: apply instance not available

Failed.
Unable to switchover, primary database is still "lava"
DGMGRL> show configuration

Configuration - conf1

  Protection Mode: MaxPerformance
  Databases:
    lava  - Primary database
    lavas - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS


Now enable the configuration


DGMGRL> enable configuration ;
Enabled.


As we see below highlighted service.  This services is not registered with our listener on both node.  If we try to switchover without fixing this error, we will get switchover but the primary which became standby will failed to start.  In that case manual intervention is required to fix this.

DGMGRL> show database verbose LAVA

Database - lava

  Role:            PHYSICAL STANDBY
  Intended State:  APPLY-ON
  Transport Lag:   0 seconds
  Apply Lag:       0 seconds
  Real Time Query: OFF
  Instance(s):
    LAVA

  Properties:
    DGConnectIdentifier             = 'LAVA'
    ObserverConnectIdentifier       = ''
    LogXptMode                      = 'ASYNC'
    DelayMins                       = '0'
    Binding                         = 'optional'
    MaxFailure                      = '0'
    MaxConnections                  = '1'
    ReopenSecs                      = '300'
    NetTimeout                      = '30'
    RedoCompression                 = 'DISABLE'
    LogShipping                     = 'ON'
    PreferredApplyInstance          = ''
    ApplyInstanceTimeout            = '0'
    ApplyParallel                   = 'AUTO'
    StandbyFileManagement           = 'AUTO'
    ArchiveLagTarget                = '0'
    LogArchiveMaxProcesses          = '4'
    LogArchiveMinSucceedDest        = '1'
    DbFileNameConvert               = ''
    LogFileNameConvert              = ''
    FastStartFailoverTarget         = ''
    InconsistentProperties          = '(monitor)'
    InconsistentLogXptProps         = '(monitor)'
    SendQEntries                    = '(monitor)'
    LogXptStatus                    = '(monitor)'
    RecvQEntries                    = '(monitor)'
    SidName                         = 'LAVA'
    StaticConnectIdentifier         = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.213)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=LAVA_DGMGRL.ora.com)(INSTANCE_NAME=LAVA)(SERVER=DEDICATED)))'
    StandbyArchiveLocation          = 'USE_DB_RECOVERY_FILE_DEST'
    AlternateLocation               = ''
    LogArchiveTrace                 = '0'
    LogArchiveFormat                = '%t_%s_%r.dbf'
    TopWaitEvents                   = '(monitor)'

Database Status:
SUCCESS

DGMGRL> SHOW DATABASE VERBOSE LAVAS

Database - lavas

  Role:            PRIMARY
  Intended State:  TRANSPORT-ON
  Instance(s):
    LAVAS1
    LAVAS2

  Properties:
    DGConnectIdentifier             = 'LAVAS'
    ObserverConnectIdentifier       = ''
    LogXptMode                      = 'ASYNC'
    DelayMins                       = '0'
    Binding                         = 'OPTIONAL'
    MaxFailure                      = '0'
    MaxConnections                  = '1'
    ReopenSecs                      = '300'
    NetTimeout                      = '30'
    RedoCompression                 = 'DISABLE'
    LogShipping                     = 'ON'
    PreferredApplyInstance          = ''
    ApplyInstanceTimeout            = '0'
    ApplyParallel                   = 'AUTO'
    StandbyFileManagement           = 'AUTO'
    ArchiveLagTarget                = '0'
    LogArchiveMaxProcesses          = '4'
    LogArchiveMinSucceedDest        = '1'
    DbFileNameConvert               = ''
    LogFileNameConvert              = ''
    FastStartFailoverTarget         = ''
    InconsistentProperties          = '(monitor)'
    InconsistentLogXptProps         = '(monitor)'
    SendQEntries                    = '(monitor)'
    LogXptStatus                    = '(monitor)'
    RecvQEntries                    = '(monitor)'
    SidName(*)
    StaticConnectIdentifier(*)
    StandbyArchiveLocation(*)
    AlternateLocation(*)
    LogArchiveTrace(*)
    LogArchiveFormat(*)
    TopWaitEvents(*)
    (*) - Please check specific instance for the property value

Database Status:
SUCCESS

Setting Connection Identifier property on RAC nodes

Edit the services in connection identifier in broker.

Node 1

DGMGRL> SHOW INSTANCE VERBOSE 'LAVAS1'

Instance 'LAVAS1' of database 'lavas'

  Host Name: rac123.ora.com
  PFILE:
  Properties:
    SidName                         = 'LAVAS1'
    StaticConnectIdentifier         = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.158)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=LAVAS_DGMGRL.ora.com)(INSTANCE_NAME=LAVAS1)(SERVER=DEDICATED)))'
    StandbyArchiveLocation          = 'USE_DB_RECOVERY_FILE_DEST'
    AlternateLocation               = ''
    LogArchiveTrace                 = '0'
    LogArchiveFormat                = '%t_%s_%r.dbf'
    TopWaitEvents                   = '(monitor)'

Instance Status:
SUCCESS


DGMGRL>  edit instance 'LAVAS1' ON DATABASE LAVAS SET PROPERTY StaticConnectIdentifier='(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac-scan)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=LAVAS_DGMGRL)(INSTANCE_NAME=LAVAS1)(SERVER=DEDICATED)))' ;
Property "staticconnectidentifier" updated


DGMGRL> show instance verbose 'LAVAS1'

Instance 'LAVAS1' of database 'lavas'

  Host Name: rac123.ora.com
  PFILE:
  Properties:
    SidName                         = 'LAVAS1'
    StaticConnectIdentifier         = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac-scan)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=LAVAS_DGMGRL)(INSTANCE_NAME=LAVAS1)(SERVER=DEDICATED)))'
    StandbyArchiveLocation          = 'USE_DB_RECOVERY_FILE_DEST'
    AlternateLocation               = ''
    LogArchiveTrace                 = '0'
    LogArchiveFormat                = '%t_%s_%r.dbf'
    TopWaitEvents                   = '(monitor)'

Instance Status:
SUCCESS

Node 2

DGMGRL> edit instance 'LAVAS2'  ON DATABASE LAVAS SET PROPERTY StaticConnectIdentifier='(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac-scan)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=LAVAS_DGMGRL)(INSTANCE_NAME=LAVAS2)(SERVER=DEDICATED)))' ;
Property "staticconnectidentifier" updated

DGMGRL> show instance VERBOSE 'LAVAS2'

Instance 'LAVAS2' of database 'lavas'

  Host Name: rac124.ora.com
  PFILE:
  Properties:
    SidName                         = 'LAVAS2'
    StaticConnectIdentifier         = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac-scan)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=LAVAS_DGMGRL)(INSTANCE_NAME=LAVAS2)(SERVER=DEDICATED)))'
    StandbyArchiveLocation          = 'USE_DB_RECOVERY_FILE_DEST'
    AlternateLocation               = ''
    LogArchiveTrace                 = '0'
    LogArchiveFormat                = '%t_%s_%r.dbf'
    TopWaitEvents                   = '(monitor)'

Instance Status:
SHUTDOWN


Now switchover to Standby RAC from Primary (Standalone DB)

DGMGRL> SHOW CONFIGURATION

Configuration - conf1

  Protection Mode: MaxPerformance
  Databases:
    lava  - Primary database
    lavas - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS



DGMGRL> SWITCHOVER TO LAVAS
Performing switchover NOW, please wait...
New primary database "lavas" is opening...
Operation requires shutdown of instance "LAVA" on database "lava"
Shutting down instance "LAVA"...
ORACLE instance shut down.
Operation requires startup of instance "LAVA" on database "lava"
Starting instance "LAVA"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "lavas"

Switchover succeeded to RAC node.

Verify the new primary status


DGMGRL> SHOW CONFIGURATION

Configuration - conf1

  Protection Mode: MaxPerformance
  Databases:
    lavas - Primary database
    lava  - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS


Now I can see the new primary is LAVAS (ON CLUSTER)

SQL> select distinct name,open_mode, instance_name, database_role, flashback_on
from gv$instance,gv$database;

NAME      OPEN_MODE            INSTANCE_NAME    DATABASE_ROLE    FLASHBACK_ON
--------- -------------------- ---------------- ---------------- ------------------
LAVA      READ WRITE           LAVAS1           PRIMARY          YES

SQL> select dest_name , status, error
from v$archive_dest where rownum < 4 ;

DEST_NAME                               STATUS    ERROR
--------------------------------------- --------- -------------------------
LOG_ARCHIVE_DEST_1                      VALID
LOG_ARCHIVE_DEST_2                      VALID



On Standby (Old Primary)

SQL> select distinct name,open_mode, instance_name, database_role, flashback_on
from gv$instance,gv$database;

NAME      OPEN_MODE            INSTANCE_NAME    DATABASE_ROLE    FLASHBACK_ON
--------- -------------------- ---------------- ---------------- ------------------
LAVA      READ ONLY WITH APPLY LAVA             PHYSICAL STANDBY YES


SQL> select PROCESS,STATUS,GROUP#, THREAD#,SEQUENCE#,BLOCK#,BLOCKS
from v$managed_standby ;

PROCESS STATUS       GROUP#  THREAD#  SEQUENCE# BLOCK# BLOCKS
------- ------------ ------- ------- ---------- ------ ------
ARCH    CLOSING      5             1        178   6144    596
ARCH    CONNECTED    N/A           0          0      0      0
ARCH    CONNECTED    N/A           0          0      0      0
ARCH    CLOSING      6             2          6   6144    605
RFS     IDLE         N/A           0          0      0      0
RFS     IDLE         N/A           0          0      0      0
RFS     IDLE         N/A           0          0      0      0
RFS     IDLE         N/A           0          0      0      0
RFS     IDLE         N/A           0          0      0      0
RFS     IDLE         N/A           0          0      0      0
RFS     IDLE         1             1        189   6298      1
RFS     IDLE         10            2         15  20090      1
MRP0    APPLYING_LOG N/A           2         15  20089 204800



Now on New Primary (RAC Cluster)

Register database in cluster

Adding Instance on Node 2

Create link spfile in dbs folder.
Create password file and edit listener and tnsnames as per your requirement

[oracle@rac123 ~]$ srvctl add database -d LAVAS -o '/u01/app/oracle/product/11.2.0/dbhome_1' -c RAC -p '+DATA_DG/lavas/spfilelava.ora' -r PHYSICAL_STANDBY

[oracle@rac123 ~]$ srvctl add instance -d LAVAS -i LAVAS1 -n rac123

[oracle@rac123 ~]$ srvctl add instance -d LAVAS -i LAVAS2 -n rac124


SQL> select thread#, status, enabled, instance, sequence# from v$thread;

   THREAD# STATUS ENABLED  INSTANCE    SEQUENCE#
---------- ------ -------- --------- -----------
         1 OPEN   PUBLIC   LAVAS1           11

SQL> alter system set cluster_database=true scope=spfile sid='*';
SQL> alter system set instance_number=1 scope=spfile sid='LAVAS1';
SQL> alter system set instance_number=2 scope=spfile sid='LAVAS2';
SQL> alter system set remote_listener='rac-scan:1521' scope=spfile sid='*';
SQL> alter system set thread=1 scope=spfile sid='LAVAS1';
SQL> alter system set thread=2 scope=spfile sid='LAVAS2';
SQL> alter system set undo_tablespace='UNDOTBS1' scope=spfile sid='LAVAS1';
SQL> alter system set undo_tablespace='UNDOTBS2' scope=spfile sid='LAVAS2';
SQL> alter database enable public thread 2 ;


SQL> alter database add logfile thread 2 ;
SQL> alter database add logfile thread 2 ;
SQL> alter database add logfile thread 2 ;
SQL> alter database add logfile thread 2 ;


[oracle@rac123 ~]$ srvctl config database -d LAVAS
Database unique name: LAVAS
Database name:
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +DATA_DG/lavas/spfilelava.ora
Domain: ora.com
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: LAVAS
Database instances: LAVAS1,LAVAS2
Disk Groups: DATA_DG
Mount point paths:
Services:
Type: RAC
Database is administrator managed

[oracle@rac123 ~]$ srvctl status database -d LAVAS
Instance LAVAS1 is running on node rac123
Instance LAVAS2 is running on node rac124


SQL> select distinct name,open_mode, instance_name, database_role, flashback_on
from gv$instance,gv$database;
 
NAME      OPEN_MODE            INSTANCE_NAME    DATABASE_ROLE    FLASHBACK_ON
--------- -------------------- ---------------- ---------------- ------------------
LAVA      READ WRITE           LAVAS1           PRIMARY          YES
LAVA      READ WRITE           LAVAS2           PRIMARY          YES


Creates the dictionary views needed for Oracle RAC databases


SQL> @?/rdbms/admin/catclust.sql

Package created.

Package body created.

PL/SQL procedure successfully completed.

View created.

Synonym created.

Grant succeeded.

View created.

….
….

View created.

Grant succeeded.

Synonym created.

View created.

Grant succeeded.

Synonym created.

PL/SQL procedure successfully completed.



Immediately take a full backup to avoid any disaster.



Hope this will help ……. 

No comments:

Post a Comment