Thursday, May 2, 2013

How to Move Primary Server in a DataGuard Environment to Another Host with Upgrading O/S


Hello everyone,With this my first post, i am gonna show you how to move a primary database server in a dataguard environment from CentOS 5.6 64 bit to Oracle Linux 6 64 bit.


Here is the description of current system:

Primary Server:
- CentOS 5.6 64 bit
- Oracle 11.2.0.3 database : archivelog & flashback enabled
- FRA on same disk : archivelogs + backupsets ..
- 750 GB disk storage

Standby Server:
- Oracle Linux 6.3 64 bit
- Oracle 11.2.0.3 database : archivelog + read only + flashback enabled
- FRA on same disk 
- 300 GB disk storage



In this scenario, the primary server has misconfigured disk systems and an older O/S system. So, we want to use up-to-date O/S and get rid of misconfigured disks, and also protecting archivelogs as well as backups in a efficient manner.

In addition to O/S upgrading, the FRA will be located in a different disk system and online + archive logs will be multiplexed locally & remote.

Here we can see the future environment:




Here are the main steps :
  • Creating a new primary server with OLE 6 64 bit 
  • Oracle software installation on new primary server
  • Move new primary server via standby server
    • Configuring system to new FRA location & multiplexing logs

Step I: Creating the New Primary Server with OLE 6.3 64 bit 


First, i will create a new machine with the following properties and download necessary updates and software.

New Primary Server:


- Oracle Linux 6.3 64 bit
- Oracle 11.2.0.3 database : archivelog & flashback enabled
- FRA on physically different disk : archivelogs + backupsets
- Archivelogs will be multiplexed as locally
- 150 GB disk storage for database files and O/S files and 100GB for FRA


We can download Oracle Linux Enterprise 6.3 from the https://edelivery.oracle.com/linux . And oracle linux 6.3 server setup can be followed from this page.

After the server setup, you should not forget to install necessary updates to server installation.

Step II: Oracle Software Installation on New Primary Server

Here, we can simplify our oracle software installation via oracle-rdbms-server-11gR2-preinstall package. In this page, you can find details for installation the preinstall package.

After this step, the oracle user created for oracle software installation and necessary packages and kernel modifications are made automatically. You can check related files to see changes.

For example :

[oracle@primarydb ~]$ cat /etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
# sysctl.conf(5) for more details.
....

# oracle-rdbms-server-11gR2-preinstall setting for kernel.shmmax is 4398046511104 on x86_64
# oracle-rdbms-server-11gR2-preinstall setting for kernel.shmmax is 4294967295 on i386
kernel.shmmax = 4398046511104

# oracle-rdbms-server-11gR2-preinstall setting for net.core.rmem_default is 262144
net.core.rmem_default = 262144

# oracle-rdbms-server-11gR2-preinstall setting for net.core.rmem_max is 4194304
net.core.rmem_max = 4194304
....

Here in this page, you can find detailed oracle software installation which uses oracle-rdbms-server-11gR2-preinstall package.


Step III: Move to the New Primary Server 

In this part, we are starting the actual work :)


Here is my approach to move new primary machine. Briefly,, :)

First i will switchover to standby machine and then i will copy my configuration in primary machine to newly created machine. And then i will shutdown the primary machine . After that i will duplicate database from standby machine, which is now primary, to newly created machine. And finally i will switchover to newly created machine.

For illustration, steps are mainly:




Here is a detailed agenda that i will follow: 

1- switchover to sbydb
2- remove pridb from dataguard configuration (it will be shutdowned later)
3- create duplicatedb rman file on sbydb
4- edit tnsnames.ora in sbydb to be able to go to primarydb
5- copy tnsnames.ora listener.ora files from sbydb to primarydb
6- edit tnsnames.ora listener.ora in primarydb
7- copy orapw<db_name> from sbydb to primarydb
8- start listener on primarydb
9- check file destinations in primarydb
10- run duplicatedb rman file on sbydb
11- add primarydb to dgbroker configuration
12- enable dataguard configuration
13- switchover to primarydb
14- configure localarchive,new fra location in primarydb
15- create dummy localarchive , new fra locations in sbydb
16- change ip of primarydb to ip of pridb
17- change ip info on necessary files .. listener.ora, tnsnames.ora, /etc/hosts
18- recreate EM on primarydb
19- check rman configuration
20- edit crontab and backup scripts
21- check clients


Before the operation, let me check out the existing configuration and validating the dataguard configuration actually running.


[oracle@pridb ~]$ dgmgrl
DGMGRL for Linux: Version 11.2.0.3.0 - 64bit Production

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

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys@SBYDB
Password:
Connected.
DGMGRL> show configuration

Configuration - DBDGN

  Protection Mode: MaxPerformance
  Databases:
    PRIDB - Primary database
    SBYDB - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

Let me check database running,

[oracle@pridb ~]$ sqlplus "sys as sysdba"

SQL*Plus: Release 11.2.0.3.0 Production on Wed Apr 24 14:26:40 2013

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

Enter password: 

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

SQL> 
SQL> select log_mode,open_mode,database_role,flashback_on from v$database;

LOG_MODE     OPEN_MODE  DATABASE_ROLE    FLASHBACK_ON
------------ -------------------- ---------------- ------------------
ARCHIVELOG   READ WRITE  PRIMARY    YES


1- switchover to sbydb

First, we have to connect dgmgrl on sbydb in order to switchover succesfully and then issue a

switchover command.


DGMGRL> connect sys@SBYDB
Password:
Connected.
DGMGRL> show configuration

Configuration - DGDGN

  Protection Mode: MaxPerformance
  Databases:
    PRIDB - Primary database
    SBYDB - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS
DGMGRL> switchover to 'SBYDB';
Performing switchover NOW, please wait...
New primary database "SBYDB" is opening...
Operation requires shutdown of instance "DB" on database "PRIDB"
Shutting down instance "DB"...
ORACLE instance shut down.
Operation requires startup of instance "DB" on database "PRIDB"
Starting instance "DB"...
Unable to connect to database
ORA-12545: Connect failed because target host or object does not exist

Failed.
Warning: You are no longer connected to ORACLE.

Please complete the following steps to finish switchover:
start up instance "DB" of database "PRIDB"


If you encounter with last error, do not panic. Just startup the pridb manually, then everything works fine. :)


[oracle@pridb ~]$ sqlplus "sys as sysdba"

SQL*Plus: Release 11.2.0.3.0 Production on Wed Apr 24 15:36:09 2013

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

Enter password: 
Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 1.4965E+10 bytes
Fixed Size    2242912 bytes
Variable Size 8623490720 bytes
Database Buffers 6308233216 bytes
Redo Buffers   31297536 bytes
Database mounted.
Database opened.
SQL>

Meanwhile in alert_log of sbydb :

....
Recovery of Online Redo Log: Thread 1 Group 4 Seq 24 Reading mem 0
  Mem# 0: /data/oradata/DB/s_redo04.log
Wed Apr 24 12:36:15 2013
Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE  THROUGH ALL SWITCHOVER DISCONNECT  USING CURRENT LOGFILE
Wed Apr 24 13:00:27 2013
Archived Log entry 14 added for thread 1 sequence 24 ID 0x20a25495 dest 1:
Wed Apr 24 13:00:27 2013
Media Recovery Waiting for thread 1 sequence 25
Wed Apr 24 13:00:30 2013
RFS[3]: Assigned to RFS process 3296
RFS[3]: Selected log 4 for thread 1 sequence 25 dbid 539163043 branch 813428522
Wed Apr 24 13:00:30 2013
Archived Log entry 15 added for thread 1 sequence 25 ID 0x20a25495 dest 1:
Wed Apr 24 13:00:30 2013
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL
MRP0: Background Media Recovery cancelled with status 16037
Errors in file /home/oracle/app/oracle/admin/DB/bdump/diag/rdbms/sbydb/DB/trace/DB_pr00_3190.trc:
ORA-16037: user requested cancel of managed recovery operation
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
Recovered data files to a consistent state at change 8486369303
Wed Apr 24 13:00:31 2013
MRP0: Background Media Recovery process shutdown (DB)
Managed Standby Recovery Canceled (DB)
Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL
Database not available for switchover
  End-Of-REDO archived log file has not been recovered
  Incomplete recovery SCN:1:-103565289 archive SCN:1:-103545283
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE THROUGH LAST SWITCHOVER NODELAY
Media Recovery Start: Managed Standby Recovery (DB)
 started logmerger process
Wed Apr 24 13:00:31 2013
Managed Standby Recovery not using Real Time Apply
Parallel Media Recovery started with 4 slaves
Media Recovery Log /data/archive/1_25_813428522.dbf
Identified End-Of-Redo (switchover) for thread 1 sequence 25 at SCN 0x1.f9d4063d
Resetting standby activation ID 547509397 (0x20a25495)
Media Recovery End-Of-Redo indicator encountered
Media Recovery Applied through change 8486389309
Media Recovery Complete: End-Of-REDO (DB)
Attempt to set limbo arscn 1:4191422013 irscn 1:4191422013 
Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE THROUGH LAST SWITCHOVER NODELAY
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WAIT WITH SESSION SHUTDOWN
ALTER DATABASE SWITCHOVER TO PRIMARY (DB)
Maximum wait for role transition is 15 minutes.
krsv_proc_kill: Killing 2 processes (all RFS)
CLOSE: killing server sessions.
CLOSE: all sessions shutdown successfully.
Wed Apr 24 13:00:34 2013
SMON: disabling cache recovery
Backup controlfile written to trace file /home/oracle/app/oracle/admin/DB/bdump/diag/rdbms/sbydb/DB/trace/DB_rsm0_3128.trc
SwitchOver after complete recovery through change 8486389309
Online log /data/oradata/DB/redo01.log: Thread 1 Group 1 was previously cleared
Online log /data/oradata/DB/redo02.log: Thread 1 Group 2 was previously cleared
Online log /data/oradata/DB/redo03.log: Thread 1 Group 3 was previously cleared
Standby became primary SCN: 8486389307
AUDIT_TRAIL initialization parameter is changed back to its original value as specified in the parameter file.
Switchover: Complete - Database mounted as primary
Completed: ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WAIT WITH SESSION SHUTDOWN
ALTER DATABASE OPEN
Data Guard Broker initializing...
Wed Apr 24 13:00:38 2013
Assigning activation ID 547704874 (0x20a5502a)
Thread 1 advanced to log sequence 27 (thread open)
Wed Apr 24 13:00:38 2013
ARC3: Becoming the 'no SRL' ARCH
Thread 1 opened at log sequence 27
  Current log# 2 seq# 27 mem# 0: /data/oradata/DB/redo02.log
Successful open of redo thread 1
ARC0: Becoming the 'no SRL' ARCH
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
SMON: enabling cache recovery
Archived Log entry 16 added for thread 1 sequence 26 ID 0x20a5502a dest 1:
Wed Apr 24 13:00:39 2013
NSA2 started with pid=25, OS id=3310 
ARC3: Becoming the 'no SRL' ARCH
Wed Apr 24 13:00:39 2013
....

Meanwhile in alert_log of pridb :

....
Wed Apr 24 15:34:49 2013
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY [Process Id: 2641] (DB)
Wed Apr 24 15:34:49 2013
Thread 1 advanced to log sequence 25 (LGWR switch)
  Current log# 1 seq# 25 mem# 0: /data/oradata/DB/redo01.log
Stopping background process QMNC
Wed Apr 24 15:34:49 2013
Archived Log entry 782 added for thread 1 sequence 24 ID 0x20a25495 dest 1:
CLOSE: killing server sessions.
Active process 2870 user 'oracle' program 'oracle@pridb (W000)'
Active process 2870 user 'oracle' program 'oracle@pridb (W000)'
Active process 2870 user 'oracle' program 'oracle@pridb (W000)'
Active process 2870 user 'oracle' program 'oracle@pridb (W000)'
Active process 2870 user 'oracle' program 'oracle@pridb (W000)'
Active process 2870 user 'oracle' program 'oracle@pridb (W000)'
Active process 2870 user 'oracle' program 'oracle@pridb (W000)'
Active process 2870 user 'oracle' program 'oracle@pridb (W000)'
Active process 2870 user 'oracle' program 'oracle@pridb (W000)'
Active process 2870 user 'oracle' program 'oracle@pridb (W000)'
Active process 2870 user 'oracle' program 'oracle@pridb (W000)'
Active process 2870 user 'oracle' program 'oracle@pridb (W000)'
Active process 2870 user 'oracle' program 'oracle@pridb (W000)'
Active process 2870 user 'oracle' program 'oracle@pridb (W000)'
CLOSE: all sessions shutdown successfully.
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Waiting for all FAL entries to be archived...
All FAL entries have been archived.
Waiting for dest_id 2 to become synchronized...
Active, synchronized Physical Standby switchover target has been identified
Switchover End-Of-Redo Log thread 1 sequence 25 has been fixed
Switchover: Primary highest seen SCN set to 0x1.0xf9d4063d
ARCH: Noswitch archival of thread 1, sequence 25
ARCH: End-Of-Redo Branch archival of thread 1 sequence 25
ARCH: LGWR is actively archiving destination LOG_ARCHIVE_DEST_2
ARCH: Standby redo logfile selected for thread 1 sequence 25 for destination LOG_ARCHIVE_DEST_2
Archived Log entry 783 added for thread 1 sequence 25 ID 0x20a25495 dest 1:
ARCH: Archiving is disabled due to current logfile archival
Primary will check for some target standby to have received alls redo
Final check for a synchronized target standby. Check will be made once.
LOG_ARCHIVE_DEST_2 is a potential Physical Standby switchover target
Active, synchronized target has been identified
Target has also received all redo
Backup controlfile written to trace file /home/oracle/app/oracle/admin/DB/bdump/diag/rdbms/pridb/DB/trace/DB_rsm0_2641.trc
Clearing standby activation ID 547509397 (0x20a25495)
The primary database controlfile was created using the
'MAXLOGFILES 16' clause.
There is space for up to 13 standby redo logfiles
Use the following SQL commands on the standby database to create
standby redo logfiles that match the primary database:
ALTER DATABASE ADD STANDBY LOGFILE 'srl1.f' SIZE 262144000;
ALTER DATABASE ADD STANDBY LOGFILE 'srl2.f' SIZE 262144000;
ALTER DATABASE ADD STANDBY LOGFILE 'srl3.f' SIZE 262144000;
ALTER DATABASE ADD STANDBY LOGFILE 'srl4.f' SIZE 262144000;
Archivelog for thread 1 sequence 25 required for standby recovery
Switchover: Primary controlfile converted to standby controlfile succesfully.
Switchover: Complete - Database shutdown required
Completed: ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN
Wed Apr 24 15:35:00 2013
Performing implicit shutdown abort due to switchover to physical standby
Shutting down instance (abort)
License high water mark = 5
USER (ospid: 2902): terminating the instance
Instance terminated by USER, pid = 2902
Wed Apr 24 15:35:03 2013
Instance shutdown complete
ORA-1092 : opitsk aborting process
Wed Apr 24 15:36:15 2013
Starting ORACLE instance (normal)
LICENSE_MAX_SESSION = 0
....
ALTER DATABASE   MOUNT
ARCH: STARTING ARCH PROCESSES
Wed Apr 24 15:36:31 2013
ARC0 started with pid=19, OS id=3094 
ARC0: Archival started
ARCH: STARTING ARCH PROCESSES COMPLETE
ARC0: STARTING ARCH PROCESSES
Successful mount of redo thread 1, with mount id 547684731
Allocated 16777216 bytes in shared pool for flashback generation buffer
Wed Apr 24 15:36:32 2013
ARC1 started with pid=20, OS id=3105 
Starting background process RVWR
Wed Apr 24 15:36:32 2013
RVWR started with pid=21, OS id=3108 
Wed Apr 24 15:36:32 2013
ARC2 started with pid=22, OS id=3110 
Physical Standby Database mounted.
Lost write protection disabled
Wed Apr 24 15:36:32 2013
ARC3 started with pid=23, OS id=3112 
ARC1: Archival started
ARC2: Archival started
ARC1: Becoming the 'no FAL' ARCH
ARC2: Becoming the heartbeat ARCH
ARC2: Becoming the active heartbeat ARCH
Completed: ALTER DATABASE   MOUNT
Wed Apr 24 15:36:33 2013
ALTER DATABASE OPEN
Data Guard Broker initializing...
Data Guard Broker initialization complete
AUDIT_TRAIL initialization parameter is changed to OS, as DB_EXTENDED is NOT compatible for database opened with read-only access
Beginning standby crash recovery.
Serial Media Recovery started
Managed Standby Recovery starting Real Time Apply
Wed Apr 24 15:36:33 2013
Using STANDBY_ARCHIVE_DEST parameter default value as /data/archive/
Media Recovery Log /data/archive/1_25_813428522.dbf
Identified End-Of-Redo (switchover) for thread 1 sequence 25 at SCN 0x1.f9d4063d
Resetting standby activation ID 0 (0x0)
Incomplete Recovery applied until change 8486389309 time 04/24/2013 15:34:51
Completed standby crash recovery.
RFS[1]: Assigned to RFS process 3122
RFS[1]: Opened log for thread 1 sequence 28 dbid 539163043 branch 813428522
ARC3: Archival started
ARC0: STARTING ARCH PROCESSES COMPLETE
SMON: enabling cache recovery
Wed Apr 24 15:36:33 2013
RFS[2]: Assigned to RFS process 3128
RFS[2]: Opened log for thread 1 sequence 27 dbid 539163043 branch 813428522
Archived Log entry 785 added for thread 1 sequence 28 rlc 813428522 ID 0x20a5502a dest 2:
Wed Apr 24 15:36:33 2013
RFS[3]: Assigned to RFS process 3126
RFS[3]: Opened log for thread 1 sequence 26 dbid 539163043 branch 813428522
Archived Log entry 786 added for thread 1 sequence 27 rlc 813428522 ID 0x20a5502a dest 2:
Dictionary check beginning
Archived Log entry 787 added for thread 1 sequence 26 rlc 813428522 ID 0x20a5502a dest 2:
Starting Data Guard Broker (DMON)
Wed Apr 24 15:36:34 2013
INSV started with pid=27, OS id=3131 
Dictionary check complete
Database Characterset is WE8ISO8859P9
Wed Apr 24 15:36:34 2013
NSV1 started with pid=28, OS id=3135 
No Resource Manager plan active
replication_dependency_tracking turned off (no async multimaster replication found)
Physical standby database opened for read only access.
Completed: ALTER DATABASE OPEN
Wed Apr 24 15:36:35 2013
db_recovery_file_dest_size of 7032 MB is 63.32% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.
Wed Apr 24 15:36:38 2013
RSM0 started with pid=30, OS id=3167 
RFS[2]: Selected log 4 for thread 1 sequence 29 dbid 539163043 branch 813428522
Wed Apr 24 15:36:42 2013
Primary database is in MAXIMUM PERFORMANCE mode
Re-archiving standby log 4 thread 1 sequence 29
RFS[4]: Assigned to RFS process 3195
Archived Log entry 788 added for thread 1 sequence 29 ID 0x20a5502a dest 1:RFS[4]: Selected log 5 for thread 1 sequence 30 dbid 539163043 branch 813428522

ALTER SYSTEM SET log_archive_dest_state_1='ENABLE' SCOPE=BOTH;
ALTER SYSTEM SET log_archive_trace=0 SCOPE=BOTH SID='DB';
ALTER SYSTEM SET log_archive_format='%t_%s_%r.dbf' SCOPE=SPFILE SID='DB';
ALTER SYSTEM SET standby_file_management='AUTO' SCOPE=BOTH SID='*';
ALTER SYSTEM SET archive_lag_target=0 SCOPE=BOTH SID='*';
ALTER SYSTEM SET log_archive_max_processes=4 SCOPE=BOTH SID='*';
ALTER SYSTEM SET log_archive_min_succeed_dest=1 SCOPE=BOTH SID='*';
ALTER SYSTEM SET fal_server='sbydb' SCOPE=BOTH;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE  THROUGH ALL SWITCHOVER DISCONNECT  USING CURRENT LOGFILE
Attempt to start background Managed Standby Recovery process (DB)
Wed Apr 24 15:36:44 2013
MRP0 started with pid=32, OS id=3210 
MRP0: Background Managed Standby Recovery process started (DB)
 started logmerger process
Wed Apr 24 15:36:49 2013
Managed Standby Recovery starting Real Time Apply
Parallel Media Recovery started with 4 slaves
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Clearing online redo logfile 1 /data/oradata/DB/redo01.log
Clearing online log 1 of thread 1 sequence number 29
Wed Apr 24 15:36:50 2013
Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE  THROUGH ALL SWITCHOVER DISCONNECT  USING CURRENT LOGFILE
RFS[4]: Selected log 4 for thread 1 sequence 31 dbid 539163043 branch 813428522
Wed Apr 24 15:36:51 2013
Archived Log entry 789 added for thread 1 sequence 30 ID 0x20a5502a dest 1:
Wed Apr 24 15:36:58 2013
Clearing online redo logfile 1 complete
Clearing online redo logfile 2 /data/oradata/DB/redo02.log
Clearing online log 2 of thread 1 sequence number 30
Clearing online redo logfile 2 complete
Clearing online redo logfile 3 /data/oradata/DB/redo03.log
Clearing online log 3 of thread 1 sequence number 31
Wed Apr 24 15:37:13 2013
Clearing online redo logfile 3 complete
Wed Apr 24 15:37:13 2013
Media Recovery Log /data/archive/1_26_813428522.dbf
Media Recovery Log /data/archive/1_27_813428522.dbf
Media Recovery Log /data/archive/1_28_813428522.dbf
Media Recovery Log /data/archive/1_29_813428522.dbf
Media Recovery Log /data/archive/1_30_813428522.dbf
Media Recovery Waiting for thread 1 sequence 31 (in transit)
Recovery of Online Redo Log: Thread 1 Group 4 Seq 31 Reading mem 0
  Mem# 0: /data/oradata/DB/s_redo04.log
...

Now lets check dataguard configuration

DGMGRL> show configuration

Configuration - DBDGN

  Protection Mode: MaxPerformance
  Databases:
    SBYDB - Primary database
    PRIDB - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

Everything seems ok. Now we can get rid of in order to get a consistent environment.

2- remove pridb from dataguard configuration

First  connect to dgbroker on sbysd (new primary database) and issue remove database command to stop log shipping to pridb (standby database).

DGMGRL> connect sys@SBYDB
Password:
Connected.
DGMGRL> show configuration

Configuration - DGDGN

  Protection Mode: MaxPerformance
  Databases:
    PRIDB - Primary database
    SBYDB - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS


DGMGRL> remove database 'PRIDB'

Removed database "PRIDB" from the configuration

DGMGRL> enable configuration

Enabled.

DGMGRL> show configuration

Configuration - DBDGN


  Protection Mode: MaxPerformance
  Databases:
    SBYDB - Primary database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

Meanwhile in alert log of sbydb

....
Wed Apr 24 13:34:20 2013
ALTER SYSTEM SET log_archive_dest_2='' SCOPE=BOTH;
ALTER SYSTEM SET log_archive_dest_state_2='ENABLE' SCOPE=BOTH;
ALTER SYSTEM SET log_archive_config='dg_config=(SBRDB)' SCOPE=BOTH;
ALTER SYSTEM SWITCH ALL LOGFILE start (DB)
ALTER SYSTEM SWITCH ALL LOGFILE complete (DB)
Wed Apr 24 13:34:21 2013
Thread 1 advanced to log sequence 32 (LGWR switch)
  Current log# 1 seq# 32 mem# 0: /data/oradata/DB/redo01.log
Wed Apr 24 13:34:21 2013
Changing destination 2 from remote to local during archival of log#: 3 sequence#: 31 thread#: 1 
Archived Log entry 27 added for thread 1 sequence 31 ID 0x20a5502a dest 1:
Wed Apr 24 13:34:32 2013
ALTER SYSTEM SET log_archive_trace=0 SCOPE=BOTH SID='DB';
ALTER SYSTEM SET log_archive_format='%t_%s_%r.dbf' SCOPE=SPFILE SID='DB';
ALTER SYSTEM SET standby_file_management='AUTO' SCOPE=BOTH SID='*';
ALTER SYSTEM SET archive_lag_target=0 SCOPE=BOTH SID='*';
ALTER SYSTEM SET log_archive_max_processes=4 SCOPE=BOTH SID='*';
ALTER SYSTEM SET log_archive_min_succeed_dest=1 SCOPE=BOTH SID='*';
ALTER SYSTEM SET db_file_name_convert='/PRIDB/','/SBYDB/' SCOPE=SPFILE;
ALTER SYSTEM SET log_file_name_convert='/PRIDB/','/SBYDB/' SCOPE=SPFILE;
...

Meanwhile in alert log of pridb

...
USER: DB_UNIQUE_NAME SBYPR is not in the Data Guard configuration

ALTER SYSTEM SET log_archive_config='dg_config=(PRIDB)' SCOPE=BOTH;

Wed Apr 24 16:08:43 2013

Archived Log entry 790 added for thread 1 sequence 31 ID 0x20a5502a dest 1:

Wed Apr 24 16:08:43 2013
...

As we can see, pridb is not dataguard configuration, we can check this in sbydb by generating an archivelog and check whether the archive log shipped or not 

[oracle@sbydb ~]$ sqlplus sys as sysdba
..
SQL> show parameter archive
...
log_archive_config     string dg_config=(SBYDB)
...
log_archive_dest_state_2     string ENABLE
...

Lets switch logfile several times.

SQL> alter system switch logfile;

System altered.

Lets check archive logs in both machines.

[oracle@sbydb ~]$ ls -ltrh /data/archive/
...
-rw-r----- 1 oracle oinstall  15K Apr 24 13:00 1_28_813428522.dbf
-rw-r----- 1 oracle oinstall  62K Apr 24 13:02 1_29_813428522.dbf
-rw-r----- 1 oracle oinstall 6.5K Apr 24 13:02 1_30_813428522.dbf
-rw-r----- 1 oracle oinstall 1.1M Apr 24 13:34 1_31_813428522.dbf
-rw-r----- 1 oracle oinstall  13K Apr 24 13:43 1_32_813428522.dbf
-rw-r----- 1 oracle oinstall 1.0K Apr 24 13:43 1_33_813428522.dbf
-rw-r----- 1 oracle oinstall 1.5K Apr 24 13:43 1_34_813428522.dbf
-rw-r----- 1 oracle oinstall 1.0K Apr 24 13:43 1_35_813428522.dbf

[oracle@pridb ~]$ ls -ltrh /data/archive/
...
-rw-r----- 1 oracle oinstall 2.5K Apr 24 15:34 1_25_813428522.dbf
-rw-r----- 1 oracle oinstall  15K Apr 24 15:36 1_28_813428522.dbf
-rw-r----- 1 oracle oinstall  53K Apr 24 15:36 1_27_813428522.dbf
-rw-r----- 1 oracle oinstall 1.0K Apr 24 15:36 1_26_813428522.dbf
-rw-r----- 1 oracle oinstall  62K Apr 24 15:36 1_29_813428522.dbf
-rw-r----- 1 oracle oinstall 6.5K Apr 24 15:36 1_30_813428522.dbf
-rw-r----- 1 oracle oinstall 1.1M Apr 24 16:08 1_31_813428522.dbf

Now we are ready to shutdown pridb.

3- create duplicatedb rman command file on sbydb

Here is my rman duplicate command file. I need setting db_unique_name and file name convertions and i have to set memory values correctly according to new host properties.

DUPLICATE TARGET DATABASE

FOR STANDBY

FROM ACTIVE DATABASE

DORECOVER

SPFILE

parameter_value_convert 'SBYDB','PRIDB'

SET DB_UNIQUE_NAME='PRIDB'

SET DB_FILE_NAME_CONVERT='/SBYDB/','/PRIDB/'

SET LOG_FILE_NAME_CONVERT='/SBYDB/','/PRIDB/'

SET LOG_ARCHIVE_DEST_2='SERVICE=SBYDB LGWR ASYNC NOAFFIRM REGISTER VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=SBYDB'

SET STANDBY_FILE_MANAGEMENT='AUTO'
SET FAL_SERVER='SBYDB'
SET FAL_CLIENT='PRIDB'

SET CONTROL_FILES='/data/oradata/DB/control01.ctl','/home/oracle/app/oracle/oradata/DB/control02.ctl'

set memory_target='12G'
set memory_max_target='14G'

NOFILENAMECHECK;

4- edit tnsnames.ora in sbydb to be able to go to primarydb

[oracle@sbydb ~]$ vi /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
...
PRIDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = IP_PRIMARY)(PORT = 1521))
    (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = DB) ) )

SBYDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = IP_SBY )(PORT = 1521))
    (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = DB) ) )

5- copy tnsnames.ora listener.ora files from sbydb to primarydb

[oracle@primarydb ~]$ cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/
[oracle@primarydb admin]$ scp oracle@pridb:/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora .
oracle@pridb's password: 
listener.ora                    100% 1344     1.3KB/s   00:00    
[oracle@primarydb admin]$ 
[oracle@primarydb admin]$ scp oracle@pridb:/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora .
oracle@pridb's password: 
tnsnames.ora                    100%  531     0.5KB/s   00:00 


6- edit tnsnames.ora listener.ora in primarydb

In this part, only change IP_PRI value to IP_PRIMARY (IP address of new host) in both files and restart listener.


Here we can start listener here,

LSNRCTL> start
Starting /home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.1.1.133)(PORT=1521)))
Services Summary...
Service "DB" has 1 instance(s).
  Instance "DB", status UNKNOWN, has 1 handler(s) for this service...
Service "PRIDB" has 1 instance(s).
  Instance "DB", status UNKNOWN, has 1 handler(s) for this service...
Service "PRIDB_DGB" has 1 instance(s).
  Instance "DB", status UNKNOWN, has 1 handler(s) for this service...
Service "PRIDB_DGMGRL" has 1 instance(s).
  Instance "DB", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully


we can also check listener from sbydb,


[oracle@sbydb ~]$ tnsping PRIDB

...

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = IP_PRIMARY)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PRIDB)))
OK (0 msec)


7- copy password file from sbydb to primarydb

We can recreate password file, but it is simple to copy the one on sbydb.


[oracle@primarydb ~]$ cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/
oracle@IP_SBY:/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/initDB.ora .
[oracle@primarydb dbs]$ scp oracle@IP_SBY:/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/orapw* .
oracle@IP_SBY's password: 
orapwDB                   100% 1536     1.5KB/s   00:00    

8- start listener on primarydb

Listener already started.


9- check file destinations in primarydb

This part is very important, because if duplicate command couldn't find file destinations when creating datafiles, logfiles.. etc. it will produce error.


We have to create file important file destinations such as Fast Recovery Area, Archive Log destination, Datafiles , Controlfiles destinations like in sbydb (primary database).

10- run duplicatedb rman command file on sbydb

Finally , we are here :)


Now we are duplicating target database to standby database. For this purpose, we will use rman utility.

There is a restriction here which is there must be an instance in standby database so rman gets connected to standby database.

We can start an instance in nomount state by setting only one parameter which is required.
The db_name parameter...

[oracle@primarydb ~]$ cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/

[oracle@primarydb dbs]$ ls
orapwDB


[oracle@primarydb dbs]$ vi initDB.ora
...
[oracle@primarydb dbs]$ cat initDB.ora 
db_name='DB'

[oracle@primarydb dbs]$ sqlplus "sys as sysdba"
..
Enter password: 
Connected to an idle instance.

SQL> startup nomount pfile=initDB.ora
ORACLE instance started.

Total System Global Area  238034944 bytes
Fixed Size    2227136 bytes
Variable Size  180356160 bytes
Database Buffers   50331648 bytes
Redo Buffers    5120000 bytes
SQL> 

Here we started the instance now we are ready to start to duplicate database.

On the primary database , run

[oracle@sbydb ~]$ rman target / auxiliary sys@PRIDB cmdfile=duplicatedb.rcv log=duplicatedb.log
auxiliary database Password: 
RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21> 22>

Meanwhile in duplicatedb.log

...
executing Memory Script

Starting backup at 24-APR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=771 device type=DISK
Finished backup at 24-APR-13

sql statement: alter system set spfile= ''/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/spfileDB.ora''

contents of Memory Script:
{
   sql clone "alter system set  log_archive_dest_1 = 
 ''location=/data/archive/ valid_for=(all_logfiles,all_roles) db_unique_name=PRIDB '' comment=
 '''' scope=spfile";
   sql clone "alter system set  db_unique_name = 
 ''PRIDB'' comment=
 '''' scope=spfile";
   sql clone "alter system set  db_file_name_convert = 
 ''/SBYDB/'', ''/PRIDB/'' comment=
 '''' scope=spfile";
   sql clone "alter system set  LOG_FILE_NAME_CONVERT = 
 ''/SBYDB/'', ''/PRIDB/'' comment=
 '''' scope=spfile";
   sql clone "alter system set  LOG_ARCHIVE_DEST_2 = 
 ''SERVICE=SBYDB LGWR ASYNC NOAFFIRM REGISTER VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=SBYDB'' comment=
 '''' scope=spfile";
   sql clone "alter system set  STANDBY_FILE_MANAGEMENT = 
 ''AUTO'' comment=
 '''' scope=spfile";
   sql clone "alter system set  FAL_SERVER = 
 ''SBYDB'' comment=
 '''' scope=spfile";
   sql clone "alter system set  FAL_CLIENT = 
 ''PRIDB'' comment=
 '''' scope=spfile";
   sql clone "alter system set  CONTROL_FILES = 
 ''/data/oradata/DB/control01.ctl'', ''/home/oracle/app/oracle/oradata/DB/control02.ctl'' comment=
 '''' scope=spfile";
   sql clone "alter system set  memory_target = 
 6G comment=
 '''' scope=spfile";
   sql clone "alter system set  memory_max_target = 
 7G comment=
 '''' scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
...
Starting restore at 24-APR-13
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=10 device type=DISK

channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 24-APR-13

contents of Memory Script:
{
   sql clone 'alter database mount standby database';
}
executing Memory Script

sql statement: alter database mount standby database

....

executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /data/oradata/DB/temp01.dbf 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 24-APR-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00039 name=/data/oradata/DB/ts_audit01.dbf
output file name=/data/oradata/DB/ts_audit01.dbf tag=TAG20130424T143734
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:55
channel ORA_DISK_1: starting datafile copy
input datafile file number=00030 name=/data/oradata/DB/datafile1.dbf
output file name=/data/oradata/DB/datafile1.dbf tag=TAG20130424T143734
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/data/oradata/DB/undotbs01.dbf
output file name=/data/oradata/DB/undotbs01.dbf tag=TAG20130424T143734

....

Starting backup at 24-APR-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=36 RECID=32 STAMP=813595599
output file name=/data/archive/1_36_813428522.dbf RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 24-APR-13

cataloged archived log
archived log file name=/data/archive/1_36_813428522.dbf RECID=1 STAMP=813595611

datafile 1 switched to datafile copy
input datafile copy RECID=82 STAMP=813595611 file name=/data/oradata/DB/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=83 STAMP=813595611 file name=/data/oradata/DB/sysaux01.dbf
....

contents of Memory Script:
{
   set until scn  8486394109;
   recover
   standby
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 24-APR-13
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 36 is already on disk as file /data/archive/1_36_813428522.dbf
archived log file name=/data/archive/1_36_813428522.dbf thread=1 sequence=36
media recovery complete, elapsed time: 00:00:00
Finished recover at 24-APR-13
Finished Duplicate Db at 24-APR-13

Recovery Manager complete.
...

Now we can see that datafiles,logfiles.. all necessary files are created in standby database.

[oracle@primarydb dbs]$ sqlplus "sys as sysdba"
..
SQL> select log_mode,open_mode,database_role,flashback_on from v$database;

LOG_MODE     OPEN_MODE  DATABASE_ROLE    FLASHBACK_ON
------------ -------------------- ---------------- ------------------
ARCHIVELOG   MOUNTED  PHYSICAL STANDBY NO

Here we can see that database in mount mode, and not in flashback mode. We want our standby database to support flashback , so we have to turn flashback  on.

SQL> alter database flashback on;

Database altered.

SQL> select log_mode,open_mode,database_role,flashback_on from v$database;

LOG_MODE     OPEN_MODE  DATABASE_ROLE    FLASHBACK_ON
------------ -------------------- ---------------- ------------------
ARCHIVELOG   MOUNTED  PHYSICAL STANDBY YES

After that , we can open database. 

SQL> alter database open;

Database altered.

SQL> select log_mode,open_mode,database_role,flashback_on from v$database;

LOG_MODE     OPEN_MODE  DATABASE_ROLE    FLASHBACK_ON
------------ -------------------- ---------------- ------------------
ARCHIVELOG   READ ONLY  PHYSICAL STANDBY YES


11- add primarydb to dgbroker configuration

Now it is time to add primarydb to dataguard configuration. For this purpose, we will use dgmgrl utility. After that log shipping starts automatically.

[oracle@sbydb ~]$ dgmgrl
DGMGRL for Linux: Version 11.2.0.3.0 - 64bit Production

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

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys@SBYDB
Password:
Connected.
DGMGRL> show configuration

Configuration - DGDGN

  Protection Mode: MaxPerformance
  Databases:
    SBYDB - Primary database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL> add database 'PRIDB' as connect identifier is PRIDB maintained as physical;
Database "PRIDB" added
DGMGRL> enable configuration
Enabled.
DGMGRL> show configuration

Configuration - DGDGN

  Protection Mode: MaxPerformance
  Databases:
    SBYDB - Primary database
    PRIDB - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL> 

Meanwhile in alert log of sbydb,

..
Wed Apr 24 15:34:06 2013
NSV0 started with pid=30, OS id=3859 
Wed Apr 24 15:34:15 2013
ALTER SYSTEM SET log_archive_config='dg_config=(SBYDB,PRIDB)' SCOPE=BOTH;
Wed Apr 24 15:34:28 2013
ALTER SYSTEM SET log_archive_dest_2='service="pridb"','LGWR ASYNC NOAFFIRM delay=0 optional compression=disable max_failure=0 max_connections=1 reopen=300 db_unique_name="PRIDB" net_timeout=30','valid_for=(all_logfiles,primary_role)' SCOPE=BOTH;
ALTER SYSTEM SET log_archive_trace=0 SCOPE=BOTH SID='DB';
ALTER SYSTEM SET log_archive_format='%t_%s_%r.dbf' SCOPE=SPFILE SID='DB';
ALTER SYSTEM SET standby_file_management='AUTO' SCOPE=BOTH SID='*';
ALTER SYSTEM SET archive_lag_target=0 SCOPE=BOTH SID='*';
ALTER SYSTEM SET log_archive_max_processes=4 SCOPE=BOTH SID='*';
ALTER SYSTEM SET log_archive_min_succeed_dest=1 SCOPE=BOTH SID='*';
ALTER SYSTEM SET db_file_name_convert='/PRIDB/','/SBYDB/' SCOPE=SPFILE;
ALTER SYSTEM SET log_file_name_convert='/PRIDB/','/SBYDB/' SCOPE=SPFILE;
Wed Apr 24 15:34:31 2013
NSA2 started with pid=34, OS id=3863 
Wed Apr 24 15:34:34 2013
Thread 1 advanced to log sequence 39 (LGWR switch)
  Current log# 2 seq# 39 mem# 0: /data/oradata/DB/redo02.log
Wed Apr 24 15:34:34 2013
Archived Log entry 34 added for thread 1 sequence 38 ID 0x20a5502a dest 1:
******************************************************************
LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2
******************************************************************
Wed Apr 24 15:34:34 2013
ARC3: Standby redo logfile selected for thread 1 sequence 38 for destination LOG_ARCHIVE_DEST_2
LNS: Standby redo logfile selected for thread 1 sequence 39 for destination LOG_ARCHIVE_DEST_2
ALTER SYSTEM ARCHIVE LOG
Thread 1 cannot allocate new log, sequence 40
Checkpoint not complete
  Current log# 2 seq# 39 mem# 0: /data/oradata/DB/redo02.log
Thread 1 advanced to log sequence 40 (LGWR switch)
  Current log# 3 seq# 40 mem# 0: /data/oradata/DB/redo03.log
LNS: Standby redo logfile selected for thread 1 sequence 40 for destination LOG_ARCHIVE_DEST_2
Archived Log entry 38 added for thread 1 sequence 39 ID 0x20a5502a dest 1:
...

Meanwhile in alert log of primarydb,

..

Wed Apr 24 15:34:32 2013

RSM0 started with pid=27, OS id=4432 

ALTER SYSTEM SET log_archive_trace=0 SCOPE=BOTH SID='DB';

ALTER SYSTEM SET log_archive_format='%t_%s_%r.dbf' SCOPE=SPFILE SID='DB';

ALTER SYSTEM SET standby_file_management='AUTO' SCOPE=BOTH SID='*';

ALTER SYSTEM SET archive_lag_target=0 SCOPE=BOTH SID='*';

ALTER SYSTEM SET log_archive_max_processes=4 SCOPE=BOTH SID='*';

ALTER SYSTEM SET log_archive_min_succeed_dest=1 SCOPE=BOTH SID='*';

ALTER SYSTEM SET db_file_name_convert='/SBYDB/','/PRIDB/' SCOPE=SPFILE;

ALTER SYSTEM SET log_file_name_convert='/SBYDB/','/PRIDB/' SCOPE=SPFILE;

ALTER SYSTEM SET fal_server='sbydb' SCOPE=BOTH;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE  THROUGH ALL SWITCHOVER DISCONNECT  USING CURRENT LOGFILE
Attempt to start background Managed Standby Recovery process (DB)
Wed Apr 24 15:34:36 2013
MRP0 started with pid=28, OS id=4434 
MRP0: Background Managed Standby Recovery process started (DB)
 started logmerger process
Wed Apr 24 15:34:41 2013
Managed Standby Recovery starting Real Time Apply
Parallel Media Recovery started with 2 slaves
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Media Recovery Waiting for thread 1 sequence 37
Wed Apr 24 15:34:41 2013
Primary database is in MAXIMUM PERFORMANCE mode
Wed Apr 24 15:34:41 2013
RFS[1]: Assigned to RFS process 4444
RFS[1]: Selected log 4 for thread 1 sequence 38 dbid 539163043 branch 813428522
RFS[2]: Assigned to RFS process 4442
RFS[2]: Selected log 5 for thread 1 sequence 39 dbid 539163043 branch 813428522
Wed Apr 24 15:34:42 2013
Archived Log entry 2 added for thread 1 sequence 38 ID 0x20a5502a dest 1:
Wed Apr 24 15:34:42 2013
Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE  THROUGH ALL SWITCHOVER DISCONNECT  USING CURRENT LOGFILE
Fetching gap sequence in thread 1, gap sequence 37-37
Wed Apr 24 15:34:43 2013
RFS[3]: Assigned to RFS process 4446
RFS[3]: Opened log for thread 1 sequence 37 dbid 539163043 branch 813428522
Archived Log entry 3 added for thread 1 sequence 37 rlc 813428522 ID 0x20a5502a dest 2:
Media Recovery Log /data/archive/1_37_813428522.dbf
Media Recovery Log /data/archive/1_38_813428522.dbf
Media Recovery Waiting for thread 1 sequence 39 (in transit)
Recovery of Online Redo Log: Thread 1 Group 5 Seq 39 Reading mem 0
  Mem# 0: /data/oradata/DB/s_redo05.log
RFS[2]: Selected log 4 for thread 1 sequence 40 dbid 539163043 branch 813428522
Wed Apr 24 15:34:44 2013
Archived Log entry 4 added for thread 1 sequence 39 ID 0x20a5502a dest 1:
Media Recovery Waiting for thread 1 sequence 40 (in transit)
Recovery of Online Redo Log: Thread 1 Group 4 Seq 40 Reading mem 0
  Mem# 0: /data/oradata/DB/s_redo04.log
...

12- enable dataguard configuration

The configuration already enabled.

13- switchover to primarydb

Now it is time to end the whole process :) After issuing a switchover command again, we will finish moving primary server in a dataguard environment tutorial.

This time we logon to primarydb in dgmgrl.

DGMGRL> connect sys@PRIDB
Password:
Connected.
DGMGRL> switchover to 'PRIDB' 
Performing switchover NOW, please wait...
New primary database "PRIDB" is opening...
Operation requires shutdown of instance "DB" on database "SBYDB"
Shutting down instance "DB"...
ORACLE instance shut down.
Operation requires startup of instance "DB" on database "SBYDB"
Starting instance "DB"...
Unable to connect to database
ORA-12545: Connect failed because target host or object does not exist

Failed.
Warning: You are no longer connected to ORACLE.

Please complete the following steps to finish switchover:
start up instance "DB" of database "SBYDB"

DGMGRL> 

Now again, we have to start sbydb manually :) Do not panic :)

[oracle@sbydb ~]$ sqlplus sys as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Apr 24 15:43:57 2013

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

Enter password: 
Connected to an idle instance.

SQL> 
SQL> startup
ORACLE instance started.

Total System Global Area 1.4965E+10 bytes
Fixed Size    2242912 bytes
Variable Size 8623490720 bytes
Database Buffers 6308233216 bytes
Redo Buffers   31297536 bytes
Database mounted.
Database opened.
SQL> select log_mode,open_mode,database_role,flashback_on from v$database;

LOG_MODE     OPEN_MODE  DATABASE_ROLE    FLASHBACK_ON
------------ -------------------- ---------------- ------------------
ARCHIVELOG   READ ONLY  PHYSICAL STANDBY YES


REMEMBER: Here primarydb is hostname for new machine and we use it as pridb

We can see same outputs of alert logs like our first switchover operation . So i pass it here.

Lets check everything :)

[oracle@primarydb ~]$ dgmgrl
DGMGRL for Linux: Version 11.2.0.3.0 - 64bit Production

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

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys@PRIDB
Password:
Connected.
DGMGRL> show configuration

Configuration - DBDGN

  Protection Mode: MaxPerformance
  Databases:
    PRIDB - Primary database
    SBYDB - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

[oracle@primarydb ~]$ sqlplus "sys as sysdba"

SQL*Plus: Release 11.2.0.3.0 Production on Wed Apr 24 15:48:21 2013

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

Enter password: 

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

SQL> 
SQL>  select log_mode,open_mode,database_role,flashback_on from v$database;

LOG_MODE     OPEN_MODE  DATABASE_ROLE    FLASHBACK_ON
------------ -------------------- ---------------- ------------------
ARCHIVELOG   READ WRITE  PRIMARY   YES

Lets check SCNs from both databases

[oracle@primarydb ~]$ sqlplus sys as sysdba
...
SQL> select current_scn from v$database;

CURRENT_SCN
-----------
 8486416808

[oracle@sbydb ~]$ sqlplus sys as sysdba
..
SQL> select current_scn from v$database;

CURRENT_SCN
-----------
 8486416804

Here, actually we finished the tutorial. :)

The following steps will be done in another posts :)

Now, i will change Fast Recovery Area location and define multiple archive and online log locations for system.  You can find detailed tutorial on this page.

Next i will change IP of primarydb to IP of pridb so that clients dont get angry. Then i will recreate Enterprise Manager . You can find detailed tutorial on this page.

Lastly i will create crontab scripts for backup operations. You can find detailed tutorial on this page.


Thanks for reading :)


No comments :

Post a Comment