(一)Installing the Oracle Database Software on the Destination Host
If the source and destination host are different, then you must install the Oracle Database software on the destination host so that the auxiliary instance can be created. You can install the software in one of the following ways:
- Perform a normal installation with Oracle Universal Installer (OUI).
Install an Oracle Database that is the same release as the source database. Do not create a database; install the software only. Apply any required patches.
- Clone the source Oracle home.
Use OUI to clone the source Oracle home. This ensures that all patches applied to the source database are present in the duplicate database.
(二)Creating an Initialization Parameter File for the Auxiliary Instance
An initialization parameter file is required to start the auxiliary instance. The initialization parameter file must contain at least the DB_NAME and DB_DOMAIN initialization parameters. Additional parameters may be specified if required. Setting DB_DOMAIN enables you to connect to the default database service when connecting with a net service name.
DB_NAME(Required)
The same name used in the DUPLICATE command. If you are using DUPLICATE to create a standby database, then the name must be the same as the primary database. The DB_NAME setting for the duplicate database must be unique among databases in its Oracle home.
DB_BLOCK_SIZE(Required if this initialization parameter is set in the source database)
The block size for the duplicate database. This block size must match the block size of the source database. If the source database parameter file contains a value for the DB_BLOCK_SIZE initialization parameter, then you must specify the same value for the auxiliary instance. If no DB_BLOCK_SIZE is specified in the source database initialization parameter file, however, then do not specify DB_BLOCK_SIZE in the auxiliary instance.
- Create an initialization parameter file manually
- Do one of the following:
- Copy the initialization parameter file from the source host to the destination host, placing it in the operating system-specific default location, and then modify DB_NAME and DB_DOMAIN. If you are duplicating a CDB, ensure that the ENABLE_PLUGGABLE_DATABASE parameter is present and set to TRUE.
- Complete these steps:
Using a text editor, create an empty file for use as a text-based initialization parameter file, and save it in the operating system-specific default location.
In the parameter file, set DB_NAME and DB_DOMAIN. These are the only required parameters.
If the auxiliary instance is to be a CDB, then set the following parameter:
ENABLE_PLUGGABLE_DATABASE=TRUE
- Set the various location parameters such as CONTROL_FILES and DB_RECOVERY_FILE_DEST.
- If necessary, set other initialization parameters like those needed for Oracle Real Application Clusters:
- Set the required environment variables, such as ORACLE_HOME and ORACLE_SID
- (Optional) Set initialization parameters that specify the location of the duplicate database files
CONTROL_FILES
DB_FILE_NAME_CONVERT
LOG_FILE_NAME_CONVERT
DB_CREATE_FILE_DEST
DB_CREATE_ONLINE_FILE_DEST_n
RECOVERY_FILE_DEST.
- Start SQL*Plus and connect to the auxiliary instance as a user with SYSDBA or SYSBACKUP privileges. Start the auxiliary instance in NOMOUNT mode. No PFILE parameter on the STARTUP command is necessary if the file is in the default location.
SQL> STARTUP NOMOUNT;
Example 25-1 Sample Initialization Parameter File for the Auxiliary Instance
DB_NAME=dupdb
CONTROL_FILES=(/dup/oracle/oradata/prod/control01.ctl,
dup/oracle/oradata/prod/control02.ctl)
DB_FILE_NAME_CONVERT=(/oracle/oradata/prod/,/dup/oracle/oradata/prod/)
LOG_FILE_NAME_CONVERT=(/oracle/oradata/prod/redo,/dup/oracle/oradata/prod/redo)
- Copying the Server Parameter File from the Source Database
If the source database uses a server parameter file, then including the SPFILE clause in the DUPLICATE command directs RMAN to use the server parameter file from the source database for the auxiliary instance. For backup-based duplication, the server parameter file is restored from backups. For active database duplication, the server parameter file is copied from the source database to the auxiliary instance.
使用PARAMETER_VALUE_CONVERT 或SET 子句更改源库SPFILE参数
You can modify the values that were copied or restored from the server parameter file of the source database by using the PARAMETER_VALUE_CONVERT option of SPFILE or the SET clause of the DUPLICATE.
如果源库使用的是PFILE,虽然能在duplicate command中使用PFILE选项复制到auxiliary database,但不能更改参数要手动改
When the source database uses a text-based initialization parameter file, use the PFILE clause in the DUPLICATE command to copy the source database's initialization parameter file to the auxiliary instance.
(三)Creating a Password File for the Auxiliary Instance
Connections to the auxiliary instance can be established by using operating system authentication or password file authentication.
For backup-based duplication, you can either create a password file or use operating system authentication to connect to the auxiliary instance. For active database duplication, you must use password file authentication.
Setting up a password file is also mandatory when duplicating to a remote host.
Password files are always copied when you create a standby database using RMAN duplication.
In all other cases, password files are copied only if you specify PASSWORD FILE in the DUPLICATE command.
Use one of the following options to create a password file for the auxiliary instance on the destination host:
- Use operating system-specific utilities to copy the source database password file to the destination host and then rename it to match the auxiliary instance name. This is applicable only if the source and destination hosts are on the same platform.
- Create the password file manually. Ensure that the password for the SYSDBA and SYSBACKUP users are the same in the source database and auxiliary instance.
- Create the password file with the orapwd utility. The SYSBACKUP option creates a SYSBACKUP entry in the new password file.
- Specify the PASSWORD FILE option on the DUPLICATE... FROM ACTIVE DATABASE command.
RMAN copies the source database password file to the destination host and overwrites any existing password file for the auxiliary instance. This technique is useful if the source database password file has multiple passwords to make available on the duplicate database.
When using active database duplication, the password file must contain at least two passwords, for the SYS user and the SYSBACKUP user. These passwords must match the passwords in the source database.
- Establishing Oracle Net Connectivity Between the Source Database and Auxiliary Instance
The auxiliary instance must be available through Oracle Net Services if any of the following conditions is true:
The RMAN client is run from a host other than the destination host
The duplication technique chosen is active database duplication
The destination host is different from the source host
To perform active database duplication, you must connect to the auxiliary instance with SYSDBA or SYSBACKUP privilege and by using a net service name.
The source database to which RMAN is connected as TARGET uses this net service name to connect directly to the auxiliary database instance.
Example 25-2 Example: Establishing Oracle Net Connectivity Between the Source Database and Auxiliary Instance
Assume that the DB_NAME of the source database is src the source host name is src.example.com. The DB_NAME of the auxiliary instance is dup and the auxiliary instance is created on the host dup.example.com.
Use the following steps to establish Oracle Net connectivity between the source database and the auxiliary instance:
- In the tnanames.ora file of the source database:
dupdb = (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dup.example.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=dup)))
- On the destination host, create tnsnames.ora in the $ORACLE_HOME/admin/network folder
srcdb = (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=src.example.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=src)))
- Starting the Auxiliary Instance
Because the auxiliary instance does not yet have a control file, you can only start the instance in NOMOUNT mode.
- Making the Oracle Keystore Available to the Destination Host
If transparent encryption is configured on the source database, then you must ensure that the Oracle software keystore from the source database is available to the auxiliary instance. The Oracle software keystore contains the TDE master key used to decrypt encrypted backups (for backup-based duplication) and database/tablespace data (for active database duplication of TDE-encrypted databases or tablespaces). Manually copy the source database keystore to the destination host.
The following are requirements for the keystore at the duplicate database:
- The keystore must be in the default location, or in the location indicated by the sqlnet.ora file.
- Permissions on the Oracle keystore file must be set so that the database can access the file.
- During duplication, the auxiliary instance is restarted thereby causing the Oracle software keystore to become unavailable. To ensure that the auxiliary instance has access to the keystore, set the ENCRYPTION_WALLET_LOCATION parameter in the sqlnet.ora file such that it points to the keystore location.
- With Oracle Real Application Clusters (Oracle RAC), register the auxiliary instance statically with an Oracle Grid Infrastructure listener and use the ENVS parameter in thesqlnet.ora file of the Oracle Grid home to specify environment variables that set the keystore location and the unique name of the database.
The following example sets the ENVS parameter in sqlnet.ora to specify the keystore location and unique database name:
(ENVS="ORACLE_UNQNAME=cdbrptl, ENCRYPTION_WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=/etc/ORACLE/WALLETS/cdbrpt1)))")
- If the source database uses a password-based software keystore (not an auto-login software keystore), then you must provide the keystore password before you begin the duplication.
Use the SET command with the DECRYPTION WALLET OPEN IDENTIFIED BY clause to specify the password that must be used to open the keystore.
The following command specifies the password used to open the keystore (where password is a placeholder for the actual password that you enter):
SET DECRYPTION WALLET OPEN IDENTIFIED BY password;