Thursday, June 26, 2014

Create ASM Standby Database for a NON-ASM Active Primary Database in 11g

In this post I'll create a ASM Physical Database on a different host from a NON-ASM Active Primary database.

Here:-

Database_Type     Database_Name      Host   
Primary           db1                node1.oracle.com
Standby           sdb1               node2.oracle.com

Step 1.

Copy the parameter file from the Primary DB host to Standby DB host under $ORACLE_HOME/dbs/ and made the possible changes.

db1.__db_cache_size=432013312
db1.__java_pool_size=4194304
db1.__large_pool_size=4194304
db1.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
db1.__pga_aggregate_target=415236096
db1.__sga_target=620756992
db1.__shared_io_pool_size=0
db1.__shared_pool_size=171966464
db1.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/sdb1/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.db_create_file_dest='+DATA/'
*.db_recovery_file_dest='+DATA/'
#*.control_files='/u01/app/oracle/oradata/sdb1/control01.ctl','/u01/app/oracle/fast_recovery_area/sdb1/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='db1'
*.db_unique_name='sdb1'

*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=sdb1XDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
*.fal_client='sdb1'*.log_archive_config='DG_CONFIG=(db1,sdb1)'
*.log_archive_dest_1='LOCATION=+DATA/sdb1/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=sdb1'
*.log_archive_dest_2='SERVICE=db1 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) COMPRESSION=ENABLE DB_UNIQUE_NAME=db1'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_file_name_convert='db1','sdb1'
*.db_recovery_file_dest_size=7516192768
*.db_recovery_file_dest='+DATA/'



Step 2.

Copy the Oracle Password file from Primary machine to standby machine under $ORACLE_HOME/dbs/.

Step 3.

Make an entry into listener and tnsnames files for Primary and standby Databases.

For instance SDB1.

Entries Into Listener.ora

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = node2.oracle.com)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = db1)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
    )

  )

Entries Into tnsnames.ora

DB1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 17x.x.xx.xx)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = db1)
    )
  )

SDB1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 17x.2xx.xx.x)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = db1)
    )
  )

Step 4.

Start the standby database in nomount mode

export ORACLE_SID=db1

SQL> startup nomount pfile=/u01/app/oracle/product/11.2.0/db_1/dbs/initdb1.ora

ORACLE instance started.

Total System Global Area  171581440 bytes
Fixed Size                  1343668 bytes
Variable Size             117444428 bytes
Database Buffers           50331648 bytes
Redo Buffers                2461696 bytes

Step 5.

From Primary Database use the following command.

run

{

duplicate target database for standby from active database

spfile

parameter_value_convert 'db1','sdb1'

set db_file_name_convert='/u01/app/oracle/oradata/db1/','+DATA/sdb1/'

set log_file_name_convert='/u01/app/oracle/oradata/db1/','+DATA/sdb1/'

set db_recovery_file_dest_size='5G'

set db_recovery_file_dest='+DATA/'

set control_files='+DATA/'

set db_unique_name='sdb1'

set fal_client='sdb1'

set fal_server='db1'

set standby_file_management='AUTO'

set log_archive_config='dg_config=(db1,sdb1)'

set log_archive_dest_2='service=sdb1 ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=sdb1'

;

}


[oracle@node1 dbs]$ rman target / auxiliary sys/oracle@sdb1

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Jun 26 12:59:34 2014

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

connected to target database: DB1 (DBID=1444093493)

connected to auxiliary database: DB1 (not mounted)

RMAN> run

{

duplicate target database for standby from active database

spfile

parameter_value_convert 'db1','sdb1'

set db_file_name_convert='/u01/app/oracle/oradata/db1/','+DATA/sdb1/'

set log_file_name_convert='/u01/app/oracle/oradata/db1/','+DATA/sdb1/'

set db_recovery_file_dest_size='5G'

set db_recovery_file_dest='+DATA/'

set control_files='+DATA/'

set db_unique_name='sdb1'

set fal_client='sdb1'

set fal_server='db1'

set standby_file_management='AUTO'

set log_archive_config='dg_config=(db1,sdb1)'

set log_archive_dest_2='service=sdb1 ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=sdb1'

;

}

2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19>

Starting Duplicate Db at 26-JUN-14

using target database control file instead of recovery catalog

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=25 device type=DISK

contents of Memory Script:

{

backup as copy reuse

targetfile '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwdb1' auxiliary format

'/u01/app/oracle/product/11.2.0/db_1/dbs/orapwdb1' targetfile

'/u01/app/oracle/product/11.2.0/db_1/dbs/spfiledb1.ora' auxiliary format

'/u01/app/oracle/product/11.2.0/db_1/dbs/spfiledb1.ora' ;

sql clone "alter system set spfile= ''/u01/app/oracle/product/11.2.0/db_1/dbs/spfiledb1.ora''";

}

executing Memory Script

Starting backup at 26-JUN-14

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=42 device type=DISK

Finished backup at 26-JUN-14

sql statement: alter system set spfile= ''/u01/app/oracle/product/11.2.0/db_1/dbs/spfiledb1.ora''

contents of Memory Script:

{

sql clone "alter system set audit_file_dest =

''/u01/app/oracle/admin/sdb1/adump'' comment=

'''' scope=spfile";

sql clone "alter system set dispatchers =

''(PROTOCOL=TCP) (SERVICE=sdb1XDB)'' comment=

'''' scope=spfile";

sql clone "alter system set log_archive_dest_1 =

''LOCATION=/u01/app/oracle/fast_recovery_area/sdb1/archivelog/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=db1'' comment=

'''' scope=spfile";

sql clone "alter system set db_file_name_convert =

''/u01/app/oracle/oradata/db1/'', ''+DATA/sdb1/'' comment=

'''' scope=spfile";

sql clone "alter system set log_file_name_convert =

''/u01/app/oracle/oradata/db1/'', ''+DATA/sdb1/'' comment=

'''' scope=spfile";

sql clone "alter system set db_recovery_file_dest_size =

5G comment=

'''' scope=spfile";

sql clone "alter system set db_recovery_file_dest =

''+DATA/'' comment=

'''' scope=spfile";

sql clone "alter system set control_files =

''+DATA/'' comment=

'''' scope=spfile";

sql clone "alter system set db_unique_name =

''sdb1'' comment=

'''' scope=spfile";

sql clone "alter system set fal_client =

''sdb1'' comment=

'''' scope=spfile";

sql clone "alter system set fal_server =

''db1'' comment=

'''' scope=spfile";

sql clone "alter system set standby_file_management =

''AUTO'' comment=

'''' scope=spfile";

sql clone "alter system set log_archive_config =

''dg_config=(db1,sdb1)'' comment=

'''' scope=spfile";

sql clone "alter system set log_archive_dest_2 =

''service=sdb1 ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=sdb1'' comment=

'''' scope=spfile";

shutdown clone immediate;

startup clone nomount;

}

executing Memory Script

sql statement: alter system set audit_file_dest = ''/u01/app/oracle/admin/sdb1/adump'' comment= '''' scope=spfile

sql statement: alter system set dispatchers = ''(PROTOCOL=TCP) (SERVICE=sdb1XDB)'' comment= '''' scope=spfile

sql statement: alter system set log_archive_dest_1 = ''LOCATION=/u01/app/oracle/fast_recovery_area/sdb1/archivelog/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=db1'' comment= '''' scope=spfile

sql statement: alter system set db_file_name_convert = ''/u01/app/oracle/oradata/db1/'', ''+DATA/sdb1/'' comment= '''' scope=spfile

sql statement: alter system set log_file_name_convert = ''/u01/app/oracle/oradata/db1/'', ''+DATA/sdb1/'' comment= '''' scope=spfile

sql statement: alter system set db_recovery_file_dest_size = 5G comment= '''' scope=spfile

sql statement: alter system set db_recovery_file_dest = ''+DATA/'' comment= '''' scope=spfile

sql statement: alter system set control_files = ''+DATA/'' comment= '''' scope=spfile

sql statement: alter system set db_unique_name = ''sdb1'' comment= '''' scope=spfile

sql statement: alter system set fal_client = ''sdb1'' comment= '''' scope=spfile

sql statement: alter system set fal_server = ''db1'' comment= '''' scope=spfile

sql statement: alter system set standby_file_management = ''AUTO'' comment= '''' scope=spfile

sql statement: alter system set log_archive_config = ''dg_config=(db1,sdb1)'' comment= '''' scope=spfile

sql statement: alter system set log_archive_dest_2 = ''service=sdb1 ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=sdb1'' comment= '''' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)

Oracle instance started

Total System Global Area 1033670656 bytes

Fixed Size 1349476 bytes

Variable Size 595593372 bytes

Database Buffers 432013312 bytes

Redo Buffers 4714496 bytes

contents of Memory Script:

{

sql clone "alter system set control_files =

''+DATA/sdb1/controlfile/current.286.851259597'' comment=

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

backup as copy current controlfile for standby auxiliary format '+DATA/sdb1/controlfile/current.277.851259601';

sql clone "alter system set control_files =

''+DATA/sdb1/controlfile/current.277.851259601'' comment=

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

shutdown clone immediate;

startup clone nomount;

}

executing Memory Script

sql statement: alter system set control_files = ''+DATA/sdb1/controlfile/current.286.851259597'' comment= ''Set by RMAN'' scope=spfile

Starting backup at 26-JUN-14

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/db_1/dbs/snapcf_db1.f tag=TAG20140626T130002 RECID=19 STAMP=851259603

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

Finished backup at 26-JUN-14

sql statement: alter system set control_files = ''+DATA/sdb1/controlfile/current.277.851259601'' comment= ''Set by RMAN'' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)

Oracle instance started

Total System Global Area 1033670656 bytes

Fixed Size 1349476 bytes

Variable Size 595593372 bytes

Database Buffers 432013312 bytes

Redo Buffers 4714496 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 tempfile 1 to

"+DATA/sdb1/temp01.dbf";

switch clone tempfile all;

set newname for datafile 1 to

"+DATA/sdb1/system01.dbf";

set newname for datafile 2 to

"+DATA/sdb1/sysaux01.dbf";

set newname for datafile 3 to

"+DATA/sdb1/undotbs01.dbf";

set newname for datafile 4 to

"+DATA/sdb1/users01.dbf";

set newname for datafile 5 to

"+DATA/sdb1/test01.dbf";

backup as copy reuse

datafile 1 auxiliary format

"+DATA/sdb1/system01.dbf" datafile

2 auxiliary format

"+DATA/sdb1/sysaux01.dbf" datafile

3 auxiliary format

"+DATA/sdb1/undotbs01.dbf" datafile

4 auxiliary format

"+DATA/sdb1/users01.dbf" datafile

5 auxiliary format

"+DATA/sdb1/test01.dbf" ;

sql 'alter system archive log current';

}

executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to +DATA/sdb1/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 26-JUN-14

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile copy

input datafile file number=00001 name=/u01/app/oracle/oradata/db1/system01.dbf

output file name=+DATA/sdb1/system01.dbf tag=TAG20140626T130028

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=/u01/app/oracle/oradata/db1/sysaux01.dbf

output file name=+DATA/sdb1/sysaux01.dbf tag=TAG20140626T130028

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25

channel ORA_DISK_1: starting datafile copy

input datafile file number=00005 name=/u01/app/oracle/oradata/db1/test01.dbf

output file name=+DATA/sdb1/test01.dbf tag=TAG20140626T130028

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=/u01/app/oracle/oradata/db1/undotbs01.dbf

output file name=+DATA/sdb1/undotbs01.dbf tag=TAG20140626T130028

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=/u01/app/oracle/oradata/db1/users01.dbf

output file name=+DATA/sdb1/users01.dbf tag=TAG20140626T130028

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

Finished backup at 26-JUN-14

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=19 STAMP=851259739 file name=+DATA/sdb1/system01.dbf

datafile 2 switched to datafile copy

input datafile copy RECID=20 STAMP=851259739 file name=+DATA/sdb1/sysaux01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=21 STAMP=851259739 file name=+DATA/sdb1/undotbs01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=22 STAMP=851259739 file name=+DATA/sdb1/users01.dbf

datafile 5 switched to datafile copy

input datafile copy RECID=23 STAMP=851259739 file name=+DATA/sdb1/test01.dbf

Finished Duplicate Db at 26-JUN-14

RMAN>


Step 6.

Open the database in OPEN mode and start the recovery.

SQL> select name,open_mode from v$database;

NAME OPEN_MODE

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

DB1 MOUNTED

SQL> recover managed standby database using current logfile disconnect;

Media recovery complete.
 

 
SQL> recover managed standby database using current logfile disconnect;

Media recovery complete.

SQL> recover managed standby database cancel;

Media recovery complete.

SQL> alter database open;

Database altered.

SQL> recover managed standby database using current logfile disconnect;

Media recovery complete.

SQL> select process,status from v$managed_standby;

PROCESS STATUS

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

ARCH CONNECTED

ARCH CONNECTED

ARCH CONNECTED

ARCH CONNECTED

RFS IDLE

RFS IDLE

RFS IDLE

RFS IDLE

MRP0 APPLYING_LOG

9 rows selected.


Step 7. 

Now Check the Standby DB  Status.

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

NAME OPEN_MODE DATABASE_ROLE

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

DB1 READ ONLY WITH APPLY PHYSICAL STANDBY




SQL> select group#,member,status from v$logfile

2 /

GROUP# MEMBER STATUS

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

3 +DATA/sdb1/redo03.log

2 +DATA/sdb1/redo02.log

1 +DATA/sdb1/redo01.log

4 +DATA/sdb1/onlinelog/group_4.279.851259755

5 +DATA/sdb1/onlinelog/group_5.281.851259759

6 +DATA/sdb1/onlinelog/group_6.282.851259763

6 rows selected.

SQL> select name from v$controlfile;

NAME

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

+DATA/sdb1/controlfile/current.277.851259601

 

SQL> select FILE# ,NAME,STATUS from v$datafile;

FILE# NAME STATUS

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

1 +DATA/sdb1/system01.dbf SYSTEM

2 +DATA/sdb1/sysaux01.dbf ONLINE

3 +DATA/sdb1/undotbs01.dbf ONLINE

4 +DATA/sdb1/users01.dbf ONLINE

5 +DATA/sdb1/test01.dbf ONLINE

 

No comments:

Post a Comment