“This is the 18th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021”

Introduce a,

If the source Database does not have a backup set and the disk space is insufficient, the Active Database Duplication can be implemented.

The Active Database Duplication does not require a backup of the source Database. The database files are copied over the network to the secondary instance, which copies the live source database to the target host. RMAN can copy the required files as image copies or backup sets.

_Note: _For active database duplication, the source database must use a server parameter file (SPFILE).

In this approach, the RMAN client connects to the source database as TARGET and to the secondary instance as AUXILIARY.

There are two ways:

Active Database Duplication Using Image Copies

Active Database Duplication Using Backup Sets

Notes: Backup Sets replication is supported after 12.1.

Active database replication using Backup Sets may be preferable to Image Copies in some scenarios:

A. Want to use parallel multi-segment backup, compression, or encryption when copying a database.

See Also:

  • About Compressing Backup Sets During Active Database Duplication

  • About Parallelizing Backup Set Creation During Active Database Duplication

  • About Encrypting Backup Sets During Active Database Duplication

B. The source database does not have sufficient network resources to transfer the required database files to the target database.

C. The system uses the least resources on the source database, minimizing the impact on the source database performance.

2. Active Database Duplication Using Image Copies (push-based method)

The source database transfers the required database files over the network to the secondary instance.

3, Active Database Duplication Using Backup Sets (pull-based method)

The secondary instance connects to the source database through Oracle Net Services and retrieves the required database files from the source database over the network.

RMAN** uses ****(Backup Sets) to perform active database replication if any of the following conditions are met; otherwise, RMAN uses ****(Image Copies)** to perform active database replication.

1, Compressing Backup Sets During Active Database Duplication

DUPLICATE TARGET DATABASE TO dup_db
FROM ACTIVE DATABASE
PASSWORD FILE
USING COMPRESSED BACKUPSET;
Copy the code

2, Parallelizing Backup Set Creation During Active Database Duplication

DUPLICATE TARGET DATABASE TO dup_db
FROM ACTIVE DATABASE
PASSWORD FILE
SECTION SIZE 400M;
Copy the code

3, Encrypting Backup Sets During Active Database Duplication

## Use the SET ENCRYPTION ALGORITHM command before DUPLICATE to specify the ENCRYPTION ALGORITHM.
SET ENCRYPTION ON IDENTIFIED BY password;
Copy the code

Four, pay attention

1. Keep the database file name the same after replication

A. Configure the replication database to use the same directory structure and file name as the source database

B. If the source database uses ASM disk groups, duplicate databases must use ASM disk groups with the same name.

C. If the source database file is Oracle Managed Files, the secondary instance must set the DB_CREATE_FILE_DEST parameter to the same directory location as the source database.

D. If the name of the database file in the source database contains a path, the path name must be the same in the duplicate database.

E. For the Oracle Real Application Clusters (RAC) environment, use the same value for the ORACLE_SID parameter for the source and target databases.

2. Inconsistency between source repository and replication repository directory

A.S ET NEWNAME command

Variable Description
%b

|

Specifies the file name stripped of directory paths. For example, if a data file is named /oradata/prod/financial.dbf, then %b results in financial.dbf.

| |

%f

|

Specifies the absolute file number of the data file for which the new name is generated. For example, if data file 2 is duplicated, then %f generates the value 2.

| |

%I

|

Specifies the DBID.

| |

%N

|

Specifies the tablespace name.

| |

%U

|

Specifies the following format: data-D-%d_id-%I_TS-%N_FNO-%f

|

Sort by priority
1.SET NEWNAME FOR DATAFILE and SET NEWNAME FOR TEMPFILE
2.SET NEWNAME FOR TABLESPACE
3.SET NEWNAME FOR DATABASE

##Example
##1. This script specifies new names for data files 1 through 5 and temporary files 1. The script does not set a new name for data file 6 because it is in the TOOLS tablespace, which has been excluded from the duplicate database.
RUN
{
SET NEWNAME FOR DATAFILE 1 TO '/oradata1/system01.dbf'; 
SET NEWNAME FOR DATAFILE 2 TO '/oradata2/sysaux01.dbf';
SET NEWNAME FOR DATAFILE 3 TO '/oradata3/undotbs01.dbf';
SET NEWNAME FOR DATAFILE 4 TO '/oradata4/users01.dbf'; 
SET NEWNAME FOR DATAFILE 5 TO '/oradata5/users02.dbf';
SET NEWNAME FOR TEMPFILE 1 TO '/oradatat/temp01.dbf'; 
DUPLICATE TARGET DATABASE TO dupdb
  SKIP TABLESPACE tools
  LOGFILE
     GROUP 1 ('/duplogs/redo01a.log'.'/duplogs/redo01b.log') SIZE 4M REUSE, 
     GROUP 2 ('/duplogs/redo02a.log'.'/duplogs/redo02b.log') SIZE 4M REUSE;
}

And use a single SET NEWNAME command to name all data files in the tablespace user. After the example is complete, the file names of the tablespace users are set to/oradatA4 /users01.dbf and /oradata5/users02.dbf.
{
SET NEWNAME FOR TABLESPACE users TO '/oradata%f/%b';
SET NEWNAME FOR DATAFILE 1 TO '/oradata1/system01.dbf';
SET NEWNAME FOR DATAFILE 2 TO '/oradata2/sysaux01.dbf';
SET NEWNAME FOR DATAFILE 3 TO '/oradata3/undotbs01.dbf';
SET NEWNAME FOR TEMPFILE 1 TO '/oradatat/temp01.dbf';
DUPLICATE TARGET DATABASE TO dupdb
SKIP TABLESPACE tools
LOGFILE
   GROUP 1 ('/duplogs/redo01a.log'.'/duplogs/redo01b.log') SIZE 4M REUSE,
   GROUP 2 ('/duplogs/redo02a.log'.'/duplogs/redo02b.log') SIZE 4M REUSE;
}

##3. Use a single SET command to name all data files in the database.
RUN
{
SET NEWNAME FOR DATABASE TO '/oradata/%U';
DUPLICATE TARGET DATABASE TO dupdb
  SKIP TABLESPACE tools
  LOGFILE
    GROUP 1 ('/duplogs/redo01a.log'.'/duplogs/redo01b.log') SIZE 4M REUSE,
    GROUP 2 ('/duplogs/redo02a.log'.'/duplogs/redo02b.log') SIZE 4M REUSE;
}
Copy the code

For OMF and ASM database files, you must use SET NEWNAME… TO NEW command, without explicitly providing the name of the database file.

##Example

##1. The USER tablespace file is hosted using OMF, so use set newname to new
RUN
{
SET NEWNAME FOR TABLESPACE users TO NEW;
SET NEWNAME FOR DATAFILE 3 TO NEW;
SET NEWNAME FOR DATAFILE 1 TO '/oradata1/system01.dbf';
SET NEWNAME FOR DATAFILE 2 TO '/oradata2/sysaux01.dbf';
SET NEWNAME FOR TEMPFILE 1 TO '/oradatat/temp01';
DUPLICATE TARGET DATABASE TO dupdb
  SKIP TABLESPACE tools
  LOGFILE
    GROUP 1 ('/duplogs/redo01a.log'.'/duplogs/redo01b.log') SIZE 4M REUSE,
    GROUP 2 ('/duplogs/redo02a.log'.'/duplogs/redo02b.log') SIZE 4M REUSE;
}

##2. Create file in ASM with SET NEWNAME
RUN
{
SET NEWNAME FOR DATAFILE 1 TO "+DGROUP1";
SET NEWNAME FOR DATAFILE 2 TO "+DGROUP2";
.
.
.
DUPLICATE TARGET DATABASE
TO dupdb
FROM ACTIVE DATABASE
SPFILE SET DB_CREATE_FILE_DEST +DGROUP3;
}
Copy the code

B.A UXNAME command

Specify non-OMF and non-ASM alternative names for duplicate database files.

##Example:

To specify the names of file data files 1 through 5
CONFIGURE AUXNAME FOR DATAFILE 1 TO '/oradata1/system01.dbf';
CONFIGURE AUXNAME FOR DATAFILE 2 TO '/oradata2/sysaux01.dbf';
CONFIGURE AUXNAME FOR DATAFILE 3 TO '/oradata3/undotbs01.dbf';
CONFIGURE AUXNAME FOR DATAFILE 4 TO '/oradata4/users01.dbf'; 
CONFIGURE AUXNAME FOR DATAFILE 5 TO '/oradata5/users02.dbf';
SET NEWNAME FOR TEMPFILE 1 TO '/oradatat/temp01.dbf'; 
DUPLICATE TARGET DATABASE
  TO dupdb
  SKIP TABLESPACE tools
  LOGFILE
     GROUP 1 ('/duplogs/redo01a.log'.'/duplogs/redo01b.log') SIZE 4M REUSE,
     GROUP 2 ('/duplogs/redo02a.log'.'/duplogs/redo02b.log') SIZE 4M REUSE;
Copy the code

C. UPLICATE SPFILE clause of the command

Sets all required initialization parameters related to duplicate database file names, except for the DB_FILE_NAME_CONVERT parameter.

##Example

##1. Assume the source database PROD is on Host1 and its data files are stored in a non-ASM file system. The control file for PROd is located in/oracle/oradata/prod /. You want to copy the source database to the database DUpDB on the remote host host2. You want to store duplicate database files in ASM disk group + DISK1.

DUPLICATE TARGET DATABASE TO dupdb
FROM ACTIVE DATABASE
SPFILE
PARAMETER_VALUE_CONVERT '/oracle/oradata/prod/'.'+DISK1'
SET DB_CREATE_FILE_DEST +DISK1;

##DUPLICATE once the DUPLICATE command is complete, a DUPLICATE database will be created containing data files from ASM disk groups +DISK1, online redo log files and control files.


##2. Assume the source database prod is on host1 and store its data files in ASM disk group +DISK1. You want to copy the target to the database dupDB on the remote host host2. You want to store the dupDB data files in ASM.

DUPLICATE TARGET DATABASE
TO dupdb
FROM ACTIVE DATABASE
SPFILE PARAMETER_VALUE_CONVERT '+DISK1'.'+DISK2'
SET DB_RECOVERY_FILE_DEST_SIZE='750G';

When the DUPLICATE command is complete, a DUPLICATE database will be created containing data files from the larger ASM disk group +DISK2, online redo logs and control files.
Copy the code

D. db_file_name_convert and LOG_FILE_NAME_CONVERT initialization parameters (_non-MO_F)

Limitations:

1. Do not use the DB_FILE_NAME_CONVERT option of the DUPLICATE command to control the generation of new file names in the OMF secondary instance of the source database instance. 2. The LOG_FILE_NAME_CONVERT initialization parameter cannot be used to control the generation of new names for files in duplicate instances of OMF format in source database instances. 3. If you set OMF initialization parameters, do not specify LOG_FILE_NAME_CONVERT. 4. The LOG_FILE_NAME_CONVERT parameter cannot be specified as a clause in the DUPLICATE command and can only be specified in the initialization parameter of the secondary instance.Copy the code

_ Note: _ When copying to a local or remote host without the NOFILENAMECHECK clause, make sure you do not use the name of the online redo log file currently being used by the source database.

3, NOFILENAMECHECK

The CONFIGURE AUXNAME command, the SET NEWNAME command, or the DB_FILE_NAME_CONVERT parameter may generate names that are already used in the target database. In this case, RMAN displays an error during replication. Use the NOFILENAMECHECK option to avoid this error message when copying to a remote host.

_Notes: _ Using NOFILENAMECHECK when copying to localhost overwrites the target database file.

4. Target Oracle installation

_Notes: _ Ensure that the same version of Oracle database software with the same patch level has been installed on both the source and target hosts.

5, NOOPEN

Prevent open replication of databases to resetlogs by specifying the NOOPEN parameter.

6, the static listener

DG needs to use static listening.

SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = former) (ORACLE_HOME = / u01 / app/oracle/product / 11.2.0 / db) (SID_NAME = orcl) ) )Copy the code