Quantcast
Channel: Deiby Gomez's Activities
Viewing all articles
Browse latest Browse all 108

Active Duplicate Database Scenarios and the location of the datafiles

$
0
0

There are  some misconceptions about DUPLICATE DATABASE operation and where the datafiles are located. I have seen some DBAs saying that  only *_name_convert parameters should be used,  but most of them forget how *_name_convert parameters work when the parameter db_create_file_dest is set. In this article I will show you the behaviour of DUPLICATE DATABASE operations with the following scenarios:

  1. Set db_create_file_dest
  2. Set db_create_file_dest and also db_file_name_convert
  3. Unset db_create_file_dest and also db_file_name_convert
  4. Set only db_file_name_convert

The goal of the article is to provide you a clear concept about which parameters to set when you are duplicating a database, of course this depends on your needs. Every environment is different and you have to adapt the concepts to your environment.

Additionally to the parameters that we are talking about don't forget to set properly the following parameters, specially when you are duplicating a database in the same server:

  • control_files
  • db_create_online_log_dest_* (When applies)
  • log_file_name_convert (when applies)
  • pdb_file_name_convert (when applies)

Of course, you can always use "SET NEWNAME" to explicitly say where your datafiles will be located. 

Let's start with our first scenario:

1. Set db_create_file_dest

Firstable let me provide you the definition of this parameters from Oracle Documentation:

"DB_CREATE_FILE_DEST specifies the default location for Oracle-managed datafiles. This location is also used as the default location for Oracle-managed control files and online redo logs if none of the DB_CREATE_ONLINE_LOG_DEST_n initialization parameters are specified.

If a file system directory is specified as the default location, then the directory must already exist; Oracle does not create it. The directory must have appropriate permissions that allow Oracle to create files in it. Oracle generates unique names for the files, and a file thus created is an Oracle-managed file."

Good, what the definition is saying basically is "set this parameter and all your files will be created there", let's see how it works.

The datafiles of my target database (the source database that is being duplicated) are located in the directory "/data/db1" because I am using OMF.


SQL> select name from v$database;

NAME
---------
DB1

SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
/data/db1/DB1/datafile/o1_mf_users_cnnz774t_.dbf
/data/db1/DB1/datafile/o1_mf_undotbs1_cnnz784o_.dbf
/data/db1/DB1/datafile/o1_mf_system_cnnz5sx2_.dbf
/data/db1/DB1/datafile/o1_mf_sysaux_cnnz42rx_.dbf

All the Oracle network and also the Static services are already configured, so don't worry about that, let's go directly to the point.

I will proceed now to duplicate the database "db1" to the database "db2" using ACTIVE DUPLICATE DATABASE. But the most important part here is that in the database "db2" I have set the parameter db_create_file_dest to the value "/data/db2" and I am not using any *_name_convert parameter. Most of the people think that *_name_convert parameters are the main and only parameter that we have to set when dealing with duplicate operations, but let's break that myth:

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
db2

SQL> show parameters db_create_file_dest

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string /data/db2

SQL> show parameters db_file_name_convert

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
SQL>

 

Duplicate operation:

[oracle@db12102 ~]$ rman target sys/manager1@db1 auxiliary=sys/manager1@db2

Recovery Manager: Release 12.1.0.2.0 - Production on Sun May 29 03:33:25 2016

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

connected to target database: DB1 (DBID=1506943872)
connected to auxiliary database: DB2 (not mounted)

RMAN>DUPLICATE TARGET DATABASE TO 'DB2'
FROM ACTIVE DATABASE ;2> 3>

Starting Duplicate Db at 29-MAY-16
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=22 device type=DISK
current log archived

...

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: using network backup set from service db1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /data/db2/DB2/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service db1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to /data/db2/DB2/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service db1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /data/db2/DB2/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service db1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00006 to /data/db2/DB2/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 29-MAY-16

...

datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=913088087 file name=/data/db2/DB2/datafile/o1_mf_system_cno6w4bs_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=6 STAMP=913088087 file name=/data/db2/DB2/datafile/o1_mf_sysaux_cno6wcwq_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=7 STAMP=913088087 file name=/data/db2/DB2/datafile/o1_mf_undotbs1_cno6wm3m_.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=8 STAMP=913088087 file name=/data/db2/DB2/datafile/o1_mf_users_cno6wn2x_.dbf

...

archived log for thread 1 with sequence 5 is already on disk as file /data/db2/DB2/archivelog/2016_05_29/o1_mf_1_5_cno6wohb_.arc
archived log for thread 1 with sequence 6 is already on disk as file /data/db2/DB2/archivelog/2016_05_29/o1_mf_1_6_cno6wpoh_.arc
archived log file name=/data/db2/DB2/archivelog/2016_05_29/o1_mf_1_5_cno6wohb_.arc thread=1 sequence=5
archived log file name=/data/db2/DB2/archivelog/2016_05_29/o1_mf_1_6_cno6wpoh_.arc thread=1 sequence=6
media recovery complete, elapsed time: 00:00:00
Finished recover at 29-MAY-16
Oracle instance started

...

contents of Memory Script:
{
set newname for clone tempfile 1 to new;
switch clone tempfile all;
catalog clone datafilecopy "/data/db2/DB2/datafile/o1_mf_sysaux_cno6wcwq_.dbf",
"/data/db2/DB2/datafile/o1_mf_undotbs1_cno6wm3m_.dbf",
"/data/db2/DB2/datafile/o1_mf_users_cno6wn2x_.dbf";
switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /data/db2/DB2/datafile/o1_mf_temp_%u_.tmp in control file

cataloged datafile copy
datafile copy file name=/data/db2/DB2/datafile/o1_mf_sysaux_cno6wcwq_.dbf RECID=1 STAMP=913088112
cataloged datafile copy
datafile copy file name=/data/db2/DB2/datafile/o1_mf_undotbs1_cno6wm3m_.dbf RECID=2 STAMP=913088112
cataloged datafile copy
datafile copy file name=/data/db2/DB2/datafile/o1_mf_users_cno6wn2x_.dbf RECID=3 STAMP=913088112

datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=913088112 file name=/data/db2/DB2/datafile/o1_mf_sysaux_cno6wcwq_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=913088112 file name=/data/db2/DB2/datafile/o1_mf_undotbs1_cno6wm3m_.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=3 STAMP=913088112 file name=/data/db2/DB2/datafile/o1_mf_users_cno6wn2x_.dbf

...

Cannot remove created server parameter file
Finished Duplicate Db at 29-MAY-16

Let's confirm if the datafiles were created where are suppose to:

SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
/data/db2/DB2/datafile/o1_mf_system_cno6w4bs_.dbf
/data/db2/DB2/datafile/o1_mf_sysaux_cno6wcwq_.dbf
/data/db2/DB2/datafile/o1_mf_undotbs1_cno6wm3m_.dbf
/data/db2/DB2/datafile/o1_mf_users_cno6wn2x_.dbf

And let's take a look into the online redo logs:

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/data/db2/DB2/onlinelog/o1_mf_3_cno6xfpc_.log
/data/db2/DB2/onlinelog/o1_mf_3_cno6xft1_.log
/data/db2/DB2/onlinelog/o1_mf_2_cno6xf8v_.log
/data/db2/DB2/onlinelog/o1_mf_2_cno6xfdk_.log
/data/db2/DB2/onlinelog/o1_mf_1_cno6xdr1_.log
/data/db2/DB2/onlinelog/o1_mf_1_cno6xdx4_.log

How can be this possible? If you remember we didn't set any db_create_online_log_dest_* parameter, however Oracle created the redologs in the directory used by db_create_file_dest. The answer is easy, at the beginning of this scenario we provided the definition of "db_create_file_dest" parameter, in that definition it says that if we don't set any db_create_online_log_dest_* parameter the redologs will be created (as we already saw) in the same directory that "db_create_file_dest" .


2. Set db_create_file_dest and also db_file_name_convert

Now let's see the second and, for me it's the most interesting scenario, when we have set the parameter "db_create_file_dest" but also the parameter "db_file_name_convert".

SQL> show parameters db_create_file_dest

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string /data/db1

SQL> show parameters db_file_name_convert

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string /data/db1, /data/db2

What do you think is gonna happen? Let me show you:

[oracle@db12102 db2]$ rman target sys/manager1@db1 auxiliary=sys/manager1@db2

Recovery Manager: Release 12.1.0.2.0 - Production on Sun May 29 04:06:43 2016

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

connected to target database: DB1 (DBID=1506943872)
connected to auxiliary database: DB2 (not mounted)

RMAN> DUPLICATE TARGET DATABASE TO 'DB2'
FROM ACTIVE DATABASE ;

...

contents of Memory Script:
{
sql clone "alter system set control_files =
''/data/db2/DB2/controlfile/o1_mf_cnnz809t_.ctl'', ''/data/db2/DB2/controlfile/o1_mf_cnnz80by_.ctl'' comment=
''Set by RMAN'' scope=spfile";
sql clone "alter system set db_name =
''DB1'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''DB2'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone from service 'db1' primary controlfile;
alter clone database mount;
}

...

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service db1
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/data/db2/DB2/controlfile/o1_mf_cnnz809t_.ctl
output file name=/data/db2/DB2/controlfile/o1_mf_cnnz80by_.ctl
Finished restore at 29-MAY-16

database mounted

contents of Memory Script:
{
set newname for datafile 1 to
"/data/db2/DB1/datafile/o1_mf_system_cnnz5sx2_.dbf";
set newname for datafile 3 to
"/data/db2/DB1/datafile/o1_mf_sysaux_cnnz42rx_.dbf";
set newname for datafile 4 to
"/data/db2/DB1/datafile/o1_mf_undotbs1_cnnz784o_.dbf";
set newname for datafile 6 to
"/data/db2/DB1/datafile/o1_mf_users_cnnz774t_.dbf";
restore
from service 'db1' clone database
;
sql 'alter system archive log current';
}

...

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service db1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /data/db2/DB1/datafile/o1_mf_system_cnnz5sx2_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service db1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to /data/db2/DB1/datafile/o1_mf_sysaux_cnnz42rx_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service db1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /data/db2/DB1/datafile/o1_mf_undotbs1_cnnz784o_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service db1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00006 to /data/db2/DB1/datafile/o1_mf_users_cnnz774t_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 29-MAY-16

...

datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=913090093 file name=/data/db1/DB2/datafile/o1_mf_system_cno8tlk0_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=6 STAMP=913090093 file name=/data/db1/DB2/datafile/o1_mf_sysaux_cno8v1z0_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=7 STAMP=913090093 file name=/data/db1/DB2/datafile/o1_mf_undotbs1_cno8v97v_.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=8 STAMP=913090093 file name=/data/db1/DB2/datafile/o1_mf_users_cno8vb56_.dbf

...

archived log for thread 1 with sequence 9 is already on disk as file /data/db2/DB2/archivelog/2016_05_29/o1_mf_1_9_cno8vcmr_.arc
archived log for thread 1 with sequence 10 is already on disk as file /data/db2/DB2/archivelog/2016_05_29/o1_mf_1_10_cno8vdsj_.arc
archived log file name=/data/db2/DB2/archivelog/2016_05_29/o1_mf_1_9_cno8vcmr_.arc thread=1 sequence=9
archived log file name=/data/db2/DB2/archivelog/2016_05_29/o1_mf_1_10_cno8vdsj_.arc thread=1 sequence=10
media recovery complete, elapsed time: 00:00:00
Finished recover at 29-MAY-16
Oracle instance started

...

contents of Memory Script:
{
set newname for tempfile 1 to
"/data/db2/DB1/datafile/o1_mf_temp_cnnz83hz_.tmp";
switch clone tempfile all;
catalog clone datafilecopy "/data/db1/DB2/datafile/o1_mf_sysaux_cno8v1z0_.dbf",
"/data/db1/DB2/datafile/o1_mf_undotbs1_cno8v97v_.dbf",
"/data/db1/DB2/datafile/o1_mf_users_cno8vb56_.dbf";
switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /data/db2/DB1/datafile/o1_mf_temp_cnnz83hz_.tmp in control file

cataloged datafile copy
datafile copy file name=/data/db1/DB2/datafile/o1_mf_sysaux_cno8v1z0_.dbf RECID=1 STAMP=913090117
cataloged datafile copy
datafile copy file name=/data/db1/DB2/datafile/o1_mf_undotbs1_cno8v97v_.dbf RECID=2 STAMP=913090117
cataloged datafile copy
datafile copy file name=/data/db1/DB2/datafile/o1_mf_users_cno8vb56_.dbf RECID=3 STAMP=913090117

datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=913090117 file name=/data/db1/DB2/datafile/o1_mf_sysaux_cno8v1z0_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=913090117 file name=/data/db1/DB2/datafile/o1_mf_undotbs1_cno8v97v_.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=3 STAMP=913090117 file name=/data/db1/DB2/datafile/o1_mf_users_cno8vb56_.dbf

...

Recovery Manager complete.
[oracle@db12102 db2]$

 

The duplicate has finished, Let's see where the datafiles are located:

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
db2

SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
/data/db1/DB2/datafile/o1_mf_system_cno8tlk0_.dbf
/data/db1/DB2/datafile/o1_mf_sysaux_cno8v1z0_.dbf
/data/db1/DB2/datafile/o1_mf_undotbs1_cno8v97v_.dbf
/data/db1/DB2/datafile/o1_mf_users_cno8vb56_.dbf

if you thought the datafiles were going to be created in the directory of "db_file_name_convert" this surely will be interesting for you. As you see, Oracle didn't use the values set in the parameter "db_file_name_convert", instead of that, Oracle kept using the value of the parameter "db_create_file_dest" and from that directory Oracle started to create all the OMF Directories. So even if your source database and your duplicated database are using the same value of "db_create_file_dest", you will not overwrite your database, as long as you didn't forget to change the "db_unique_name" parameter :)

3. Unset db_create_file_dest and also db_file_name_convert

I wish you do not be in this scenario. This scenario is when you forgot everything about parameters and you went directly to the duplicate operation. You didn't set any *_name_convert parameter nor "db_create_file_dest".

Here the parameters:

SQL> show parameters convert

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
log_file_name_convert string
pdb_file_name_convert string

SQL> show parameters db_create_

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string
db_create_online_log_dest_1 string
db_create_online_log_dest_2 string
db_create_online_log_dest_3 string
db_create_online_log_dest_4 string
db_create_online_log_dest_5 string

 

Let's start the duplicate operation:

[oracle@db12102 db2]$ rman target sys/manager1@db1 auxiliary=sys/manager1@db2

Recovery Manager: Release 12.1.0.2.0 - Production on Sun May 29 03:55:59 2016

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

connected to target database: DB1 (DBID=1506943872)
connected to auxiliary database: DB2 (not mounted)

RMAN> DUPLICATE TARGET DATABASE TO 'DB2'
FROM ACTIVE DATABASE;2> 3>

...

contents of Memory Script:
{
sql clone "alter system set control_files =
''/data/db2/DB2/controlfile/o1_mf_cnnz809t_.ctl'', ''/data/db2/DB2/controlfile/o1_mf_cnnz80by_.ctl'' comment=
''Set by RMAN'' scope=spfile";
sql clone "alter system set db_name =
''DB1'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''DB2'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone from service 'db1' primary controlfile;
alter clone database mount;
}

...

Starting restore at 29-MAY-16
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=21 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service db1
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/data/db2/DB2/controlfile/o1_mf_cnnz809t_.ctl
output file name=/data/db2/DB2/controlfile/o1_mf_cnnz80by_.ctl
Finished restore at 29-MAY-16

database mounted
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 05/29/2016 03:57:10
RMAN-05501: aborting duplication of target database
RMAN-05001: auxiliary file name /data/db1/DB1/datafile/o1_mf_users_cnnz774t_.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary file name /data/db1/DB1/datafile/o1_mf_undotbs1_cnnz784o_.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary file name /data/db1/DB1/datafile/o1_mf_sysaux_cnnz42rx_.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary file name /data/db1/DB1/datafile/o1_mf_system_cnnz5sx2_.dbf conflicts with a file used by the target database

RMAN>

As it was expected, in this scenario, the Duplicate will try to overwrite your datafiles and this is not good for you specially when you are duplicating a database in the same server.

4. Set only db_file_name_convert

The last scenario is the commonest one, I am sure you are used to use it. It's when we don't care about to set "db_create_file_dest" parameter and we only use the parameter "db_file_name_convert" which is not bad, as I said at the beginning, all depends of your needs, the goal of this article is to provide you some examples and what's the behaviour in every scenario.

SQL> show parameters db_create_

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string
db_create_online_log_dest_1 string
db_create_online_log_dest_2 string
db_create_online_log_dest_3 string
db_create_online_log_dest_4 string
db_create_online_log_dest_5 string

SQL> show parameters convert db_file_name_convert

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string /data/db1, /data/db2

 

Duplicate operation:

[oracle@db12102 db2]$ rman target sys/manager1@db1 auxiliary=sys/manager1@db2

Recovery Manager: Release 12.1.0.2.0 - Production on Sun May 29 04:16:58 2016

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

connected to target database: DB1 (DBID=1506943872)
connected to auxiliary database: DB2 (not mounted)

RMAN> DUPLICATE TARGET DATABASE TO 'DB2'
FROM ACTIVE DATABASE;

...

allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=21 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service db1
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/data/db2/DB2/controlfile/o1_mf_cnnz809t_.ctl
output file name=/data/db2/DB2/controlfile/o1_mf_cnnz80by_.ctl
Finished restore at 29-MAY-16

database mounted

contents of Memory Script:
{
set newname for datafile 1 to
"/data/db2/DB1/datafile/o1_mf_system_cnnz5sx2_.dbf";
set newname for datafile 3 to
"/data/db2/DB1/datafile/o1_mf_sysaux_cnnz42rx_.dbf";
set newname for datafile 4 to
"/data/db2/DB1/datafile/o1_mf_undotbs1_cnnz784o_.dbf";
set newname for datafile 6 to
"/data/db2/DB1/datafile/o1_mf_users_cnnz774t_.dbf";
restore
from service 'db1' clone database
;
sql 'alter system archive log current';
}
...

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service db1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /data/db2/DB1/datafile/o1_mf_system_cnnz5sx2_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service db1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to /data/db2/DB1/datafile/o1_mf_sysaux_cnnz42rx_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service db1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /data/db2/DB1/datafile/o1_mf_undotbs1_cnnz784o_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service db1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00006 to /data/db2/DB1/datafile/o1_mf_users_cnnz774t_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 29-MAY-16

...

datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=913090692 file name=/data/db2/DB1/datafile/o1_mf_system_cnnz5sx2_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=6 STAMP=913090692 file name=/data/db2/DB1/datafile/o1_mf_sysaux_cnnz42rx_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=7 STAMP=913090692 file name=/data/db2/DB1/datafile/o1_mf_undotbs1_cnnz784o_.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=8 STAMP=913090692 file name=/data/db2/DB1/datafile/o1_mf_users_cnnz774t_.dbf

...

starting media recovery

archived log for thread 1 with sequence 12 is already on disk as file /data/db2/DB2/archivelog/2016_05_29/o1_mf_1_12_cno9g2p7_.arc
archived log for thread 1 with sequence 13 is already on disk as file /data/db2/DB2/archivelog/2016_05_29/o1_mf_1_13_cno9g3vx_.arc
archived log file name=/data/db2/DB2/archivelog/2016_05_29/o1_mf_1_12_cno9g2p7_.arc thread=1 sequence=12
archived log file name=/data/db2/DB2/archivelog/2016_05_29/o1_mf_1_13_cno9g3vx_.arc thread=1 sequence=13
media recovery complete, elapsed time: 00:00:00
Finished recover at 29-MAY-16
Oracle instance started

...

contents of Memory Script:
{
set newname for tempfile 1 to
"/data/db2/DB1/datafile/o1_mf_temp_cnnz83hz_.tmp";
switch clone tempfile all;
catalog clone datafilecopy "/data/db2/DB1/datafile/o1_mf_sysaux_cnnz42rx_.dbf",
"/data/db2/DB1/datafile/o1_mf_undotbs1_cnnz784o_.dbf",
"/data/db2/DB1/datafile/o1_mf_users_cnnz774t_.dbf";
switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /data/db2/DB1/datafile/o1_mf_temp_cnnz83hz_.tmp in control file

cataloged datafile copy
datafile copy file name=/data/db2/DB1/datafile/o1_mf_sysaux_cnnz42rx_.dbf RECID=1 STAMP=913090713
cataloged datafile copy
datafile copy file name=/data/db2/DB1/datafile/o1_mf_undotbs1_cnnz784o_.dbf RECID=2 STAMP=913090713
cataloged datafile copy
datafile copy file name=/data/db2/DB1/datafile/o1_mf_users_cnnz774t_.dbf RECID=3 STAMP=913090713

datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=913090713 file name=/data/db2/DB1/datafile/o1_mf_sysaux_cnnz42rx_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=913090713 file name=/data/db2/DB1/datafile/o1_mf_undotbs1_cnnz784o_.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=3 STAMP=913090713 file name=/data/db2/DB1/datafile/o1_mf_users_cnnz774t_.dbf

...

database opened
Cannot remove created server parameter file
Finished Duplicate Db at 29-MAY-16

And let's confirm what we already expected, the datafiles were created in the directory used by "db_file_name_convert"

SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
/data/db2/DB1/datafile/o1_mf_system_cnnz5sx2_.dbf
/data/db2/DB1/datafile/o1_mf_sysaux_cnnz42rx_.dbf
/data/db2/DB1/datafile/o1_mf_undotbs1_cnnz784o_.dbf
/data/db2/DB1/datafile/o1_mf_users_cnnz774t_.dbf

Conclusión:

  • If you don't set db_create_file_dest nor db_file_name_convert, be sure that you are not in the same server :) , oracle will use the same directory structure than the target DB.
  • If you set db_create_file_dest and db_file_name_convert, Oracle will ignore db_file_name_convert and it will use only db_create_file_dest
  • If you set only db_create_file_dest, it's is ok, Oracle will use it.
  • If you set only db_file_name_convert,  it's is ok, Oracle will use it.

Follow me:

      


Viewing all articles
Browse latest Browse all 108

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>