All technological notes.
password file for the auxiliary instance.auxiliary instance.initialization parameter file for the auxiliary instance.auxiliary instance in NOMOUNT mode.target database.backups and archived redo log files are available.auxiliary channels if needed.DUPLICATE command.text initialization parameter file for the auxiliary instance.The text initialization parameter file must reside on the same host as the RMAN client that you use to execute the DUPLICATE command.
Specify parameters as follows:
DB_NAME(required):
target database and the duplicate database are in the same Oracle home, you must set DBE_NAME to a different name.Oracle homes, you must ensure that the name of the duplicate database differs from the other names in its Oracle home.DUPLICATE command.CONTROL_FILES
SET NEWNAME option and Oracle Managed Files (OMF).duplicate database host.data files:
SET NEWNAME command:
SET NEWNAME FOR DATAFILE command within a RUN block to specify new names for the data files.CONFIGURE AUXNAME command (deprecated for recovery set data files)DB_FILE NAME CONVERT parameter with the DUPLICATE command.SET NEWNAME clauses:
database or in a named tablespace.DUPLICATE, RESTORE, and SWITCH commands in the RUN
block.The order of precedence for the SET NEWNAME command is as follows:
SET NEWNAME FOR DATAFILE and SET NEWNAME FOR TEMPFILESET NEWNAME FOR TABLESPACESET NEWNAME FOR DATABASEExample:
RUN {
SET NEWNAME FOR DATABASE TO '/uOl/app/oracle/oradata/dupldb/%b';
DUPLICATE TARGET DATABASE TO dupldb
LOGFILE
GROUP 1 ('/u0l/app/oracle/oradata/dupldb/redo0Ola.log', '/u0l/app/oracle/oradata/dupldb/redo0lb.log') SIZE 50M REUSE,
GROUP 2 ('/u0l/app/oracle/oradata/dupldb/redo02a.log', '/u0l/app/oracle/oradata/dupldb/redo02b.log') SIZE 50M REUSE,
GROUP 3 ('/u0l/app/oracle/oradata/dupldb/redo03a.log"', '/u0l/app/oracle/oradata/dupldb/redo03b.log') SIZE 50M REUSE;
}
SET NEWNAME| Syntax Element | Description |
|---|---|
%b |
Specifies the file name without the directory path *NEW* |
%f |
Specifies the absolute file number of the data file for which the new name is generated |
%I |
Specifies the DBID |
%N |
Specifies the tablespace name |
%U |
Specifies a system-generated file name of the format: data-D-%d_id-%I_TS-%N_FNO-%f |
substitution variables of the SET NEWNAME command.
%b, %f, and $U.%I and %N are optional variables.-- The example shows the SET NEWNAME FOR TABLESPACE command to set default names with a substitution variable, together with explicit SET NEWNAME clauses.
RUN
{
SET NEWNAME FOR DATAFILE 1 TO '/oradatal/system0l.dbf';
SET NEWNAME FOR DATAFILE 2 TO '/oradata2/sysaux0l.dbf';
SET NEWNAME FOR DATAFILE 3 TO '/oradata3/undotbs0l.dbf';
SET NEWNAME FOR DATAFILE 4 TO '/oradatad/usersOl.dbf';
SET NEWNAME FOR TABLESPACE example TO '/oradata5/%b'; --
DUPLICATE TARGET DATABASE TO dupldb;
}
Alternatively, specify the following parameters to explicitly control the naming of the files of your auxiliary database:
CONTROL_FILESDB_FILE_NAME_CONVERTLOG_FILE_NAME_CONVERTdatabase files when you execute the DUPLICATE command.You can control the naming of the files by specifying the following initialization parameters in the auxiliary instance initialization parameter file:
CONTROL_FILES:
control files in this parameter.control file in a default control destination.CREATE CONTROLFILE command in the SQL Reference manual for specific information.DB_FILE_NAME_CONVERT:
data files for the auxiliary database.DB_FILE_NAME_CONVERT = 'stringl', 'string2',
string1: the pattern of the target database file name
string2: the pattern of the auxiliary database file name.DB_FILE_NAME_CONVERT parameter as an option to the DUPLICATE DATABASE command.LOG_FILE_NAME_CONVERT:
redo log files for the auxiliary database.LOG_FILE_NAME_CONVERT = 'stringl', 'string2',
string1: the pattern of the target database file namestring2: the pattern of the auxiliary database file name.LOGFILE clause of the DUPLICATE DATABASE command to specify redo log file names.initialization parameters to control the naming of the files, you can use the following techniques to rename the redo log files:
LOGFILE clause of the DUPLICATE command.initialization parameters:
DB_CREATE_FILE_DEST,DB_CREATE_ONLINE_DEST_n,DB_RECOVERY_FILE_DEST.CONTROL_FILES='/u0l/app/oracle/oradata/aux/control0l.ctl"', '/u0l/app/oracle/oradata/aux/control02.ctl', '/u0l/app/oracle/oradata/aux/control03.ctl'
DB_FILE NAME CONVERT='/u0l/app/oracle/oradata/orcl','/u0l/app/oracle/oradata/aux'
LOG_FILE_NAME CONVERT='/u0l/app/oracle/oradata/orcl','/u0l/app/oracle/oradata/aux'
text initialization parameter file, invoke SQL*Plus to start the auxiliary instance in NOMOUNT mode.RMAN creates a default server parameter file for the auxiliary instance if the following conditions are true:
standby database.Server parameter files are not being duplicated.auxiliary instance was not started with a server parameter file.server parameter file (SPFILE) from your text initialization parameter file.CREATE SPFILE before or after you have started the instance.-- start up nomount
startup nomount pfile='$HOME/auxinstance/initAUX.ora'
create spfile from pfile='$HOME/auxinstance/initAUX.ora';
duplicate host.
network file system (NFS) mounted file system or a storage area network (SAN) LUN.full and incremental backups during the duplication process.Archived redo log files needed to recover the duplicate database to the desired point in time must be accessible on the duplicate host.Archived redo log files can be:
local disk of the duplicate database node or mounted across a network by some means such as network file system (NFS).要么传输到本地或 mountAuxiliary channels:
RMAN and an auxiliary database instance.If automatic channels are not configured, can manually allocate auxiliary channels:
target database instance, the auxiliary instance, and recovery catalog if applicable.auxiliary channel within the RUN block.ALLOCATE AUXILIARY CHANNEL command must match the media where the backups of the target database are located.备份能被渠道接触
auxiliary instance must be started with the NOMOUNT option, and the target database must be mounted or open.rman target sys@trgt auxiliary sys@auxdb
RUN
{
-- multiple channel
ALLOCATE AUXILIARY CHANNEL auxl DEVICE TYPE DISK;
ALLOCATE AUXILIARY CHANNEL aux2 DEVICE TYPE DISK;
DUPLICATE TARGET DATABASE to auxdb;
-- ...
}
When you execute the DUPLICATE command, RMAN performs the operations:
server parameter file for the auxiliary instance if the following conditions are true:
Server parameter files are not being duplicated.auxiliary instance was not started with a server parameter file.target connection.control file from the active database.data files to the auxiliary instance.data files.data files with incremental backups and archived redo log files to a noncurrent point in time.
online redo log files in the source database are not backed up and cannot be applied to the duplicate database.redo log file archived by the source database. 最近的恢复点是最新近的 redo logauxiliary instance in NOMOUNT mode.control file, which then creates and stores the new, unique database identifier DBID in the data files of the duplicated database.duplicate database with the RESETLOGS option.online redo log files for the duplicate database.Note: If the DUPLICATE DATABASE command fails, you can re-execute the DUPLICATE DATABASE command and the duplication process attempts to resume from the point of failure. 如果失败, 可以重新执行.将从失败点开始.
DUPLICATE Command| Option | Purpose |
|---|---|
SKIP READONLY |
Excludes read-only tablespaces |
SKIP TABLESPACE |
Excludes named tablespaces |
TABLESPACE |
Includes named tablespaces |
NOFILENAMECHECK |
Prevents checking of file names |
OPEN RESTRICTED |
Enables RESTRICTED SESSION automatically |
NOOPEN |
Leaves duplicate database in MOUNT mode |
NOREDO |
Signals RMAN that the application of redo logs should be suppressed during recovery |
UNDO TABLESPACE |
Must be specified when target database is not open and there is no recovery catalog connection |
SKIP TABLESPACE:
SYSTEM tablespace or tablespaces containing undo or rollback segments.NOFILENAMECHECK:
target database data files with the same name as duplicate database data files are in use.target database and duplicate database data files and redo log files use the same names.target database host.
NOFILENAMECHECK in this situation, RMAN returns an error.NOOPEN:
MOUNT mode.block change trackingfast incremental backups or flashback database settingsNOREDO:
redo logs should not be applied during the recovery phase of the duplication operation.NOARCHIVELOG mode at the time of the backup or when the archived redo log files are not available for use during the duplication operation.ARCHIVELOG mode is being duplicated to a point in time when it was in NOARCHIVELOG mode.DUPLICATE operation and the database is in NOARCHIVELOG mode, you must use the NOREDO option to inform RMAN of the database mode.
UNDO TABLESPACE:
sys user in any of the duplicated tablespaces during nonwhole database duplication.SYSTEM, SYSAUX, and undo segment tablespaces are excluded from this check.target database is not open and a recovery catalog is not being used during the duplication, RMAN cannot obtain the undo tablespace names.
UNDO TABLESPACE option to provide the names of undo segment tablespaces.You must be logged in to the CDB root as a user who is granted the SYSDBA or SYSBACKUP role.
multitenant container databases including all or individual PDBs by using the DUPLICATE command.auxiliary instance as a CDB.
ENABLE_PLUGGABLE_DATABASE=TRUE in the initialization parameter file.PDBs, RMAN also duplicates the CDB root (CDESR0OOT) and the PDB seed (pDB$ SEED).CDB that contains the CDB root, the CDB seed, and the duplicated PDBs. 会复制 CDB+seed+pdb-- duplicate a single PDB
DUPLICATE DATABASE TO cdbl
PLUGGABLE DATABASE pdbl;
-- duplicate a set of PDBs
DUPLICATE DATABASE TO cdbl
PLUGGABLE DATABASE pdbl, pdb3;
-- duplicate all the databases in the CDB, except a PDB
DUPLICATE DATABASE TO cdbl
SKIP PLUGGABLE DATABASE pdb3;
-- duplicate a PDB and tablespaces of other PDBs
DUPLICATE DATABASE TO cdbl
PLUGGABLE DATABASE pdbl TABLESPACE pdb2:users;
Duplicate a PDB or PDB tablespaces in active mode to an existing opened CDB.
PDB at a time.COMPATIBLE initialization parameter to 18.1 or higher.destination CDB in READ WRITE mode.REMOTE_RECOVERY_FILE_DEST initialization parameter in the destination CDB to the location where to restore foreign archive log files.PDB can be duplicated directly into an open CDB.The passwords for target and auxiliary connections must be the same when using active duplicate.
RMAN should be connected to the CDB root of the target and auxiliary instances.
Non-CDB to PDB duplication is not supported.SPFILE, NO STANDBY, FARSYNC STANDBY, and LOG_FILE_NAME_CONVERT keywords are not supported.NORESUME, DB_FILE_NAME_CONVERT, SECTION SIZE, and USING COMPRESSED BACKUPSET keywords are supported.
REMOTE_RECOVERY_FILE_DEST initialization parameter in CDB2.ALTER SYSTEM
SET REMOTE_RECOVERY_FILE_DEST='/dir_to_restore_archive log files';
TARGET for DUPLICATE command): CDB1CONNECT TARGET "sys@cdbl AS SYSDBA"
auxiliary instance
read/write mode.CONNECT AUXILIARY "sys@cdb2 AS SYSDBA"
DUPLICATE PLUGGABLE DATABASE pdbl TO cdb2 FROM ACTIVE DATABASE;
REMOTE_RECOVERY_FILE_DEST initialization parameter in CDB2.ALTER SYSTEM SET REMOTE_RECOVERY_ FILE DEST='/dir_to_restore_archive log files';
TARGET for DUPLICATE command): CDB1CONNECT TARGET "sys@cdb1 AS SYSDBA"
auxiliary instance:
read/write mode.CONNECT AUXILIARY "sys@cdb2 AS SYSDBA"
DUPLICATE PLUGGABLE DATABASE pdbl AS pdb2 TO cdb2 FROM ACTIVE DATABASE;
ORCLCDE: the active databaseDBTEST: the aulilary databaseDETEST database
initdbtest.ora).-- create dir for df of dbtest database
mkdir -p /u01/app/oracle/oradata/dbtest
-- create dir for fra of dbtest database
mkdir -p /u01/app/oracle/dbtest_fra
-- create dir for cdb in dbtest'fra
mkdir -p /u01/app/oracle/dbtest_fra/orclcdb
# Launch the Oracle Net Manager utility.
netmgr


cat $ORACLE_HOME/network/admin/tnsnames.ora
# reload listener
lsnrctl reload
# check listener status
lsnrctl status
. oraenv
# ORACLE_SID = [orclcdb] ? dbtest
# ORACLE HOME = [/home/oracle] ? /u01/app/oracle/product/19.0.0/dbhome_1
orapwd file=$ORACLE_HOME/dbs/orapwdbtest entries=15
# welcome!23
ls $ORACLE_HOME/dbs/*pwdbtest*
-- create spfile
vi $ORACLE_HOME/dbs/initdbtest.ora
# db_name=dbtest
# remote_login_passwordfile=exclusive
-- confirm
cat $ORACLE_HOME/dbs/initdbtest.ora
MOUNT mode with pfilesqlplus / as sysdba
startup NOMOUNT pfile='/u01/app/oracle/product/19.0.0/dbhome_1/dbs/initdbtest.ora'
exit
-- confirm: show how many instance is running by smon
pgrep -lfa smon
. oraenv
-- ORACLE_SID = [dbtest] ? orcl
sqlplus / as sysdba
-- confirm compatible
show parameter compatible
-- Confirm your backup location and size.
show parameter db_recover
-- confirm archive log mode
ARCHIVE LOG LIST
rman target sys@orcl auxiliary sys@dbtest
ORCL database as the DETEST databaseDUPLICATE TARGET DATABASE TO dbtest FROM ACTIVE DATABASE
SPFILE PARAMETER_VALUE_CONVERT
'/u01/app/oracle/oradata/ORCL', '/u01/app/oracle/oradata/dbtest',
'/u01/app/oracle/fast_recovery_area','/u01/app/oracle/dbtest_fra',
'ORCL', 'DBTEST'
SET DB_RECOVERY_FILE_DEST_SIZE='10G'
SET DB_FILE_NAME_CONVERT='ORCL', 'DBTEST';
. oraenv
# ORACLE_SID = [orclcdb] ? dbtest
# ORACLE HOME = [/home/oracle] ? /u01/app/oracle/product/19.0.0/dbhome_1
sqlplus / as sysdba
-- get cdb
SELECT NAME, CDB, CON_ID FROM V$DATABASE;
-- get db and mode
select dbid, name, created, open_mode from v$database;
-- list pdb
show pdbs
. oraenv
-- ORACLE_SID = [dbtest] ? orcl
sqlplus hr@ORCLPDB
SELECT * FROM regions;
exit
# Create dir to Set the initialization parameter `REMOTE_RECOVERY_FILE_DEST` to restore foreign archive logs.
mkdir -p /home/oracle/labs/fra
# Create the directory for the new PDB data files.
mkdir -p /u01/app/oracle/oradata/DBTEST/dbtestpdb1
REMOTE_RECOVERY_FILE_DEST. oraenv
-- ORACLE_SID = [dbtest] ? dbtest
-- ORACLE HOME = [/home/oracle] ? /u01/app/oracle/product/19.0.0/dbhome_1
sqlplus / AS SYSDBA
ALTER SYSTEM SET
REMOTE_RECOVERY_FILE_DEST='/home/oracle/labs/fra'
SCOPE=BOTH;
EXIT
rman
-- connect target
CONNECT TARGET sys@ORCL
-- Connect to the auxiliary instance DBTEST into which you will duplicate ORCLPDE1 as DBTESTPDBI.
CONNECT AUXILIARY sys@DBTEST
-- duplicate a pdb
DUPLICATE PLUGGABLE DATABASE orclpdb AS dbtestpdb1
FROM ACTIVE DATABASE
DB_FILE_NAME_CONVERT
('/u01/app/oracle/oradata/ORCL/orclpdb/', '/u01/app/oracle/oradata/DBTEST/dbtestpdb1/');
exit
sqlplus / AS SYSDBA
SHOW PDBS
ALTER SESSION SET CONTAINER=DBTESTPDB1;
SELECT * FROM hr.regions;
EXIT
rman TARGET "'sys@dbtest AS sysdba'"
STARTUP FORCE MOUNT
ALTER SYSTEM ENABLE RESTRICTED SESSION;
DROP DATABASE INCLUDING BACKUPS NOPROMPT;
vi /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
vi /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/tnsnames.ora
lsnrctl reload
lsnrctl status
rm -rf /home/oracle/labs/fra
rm -rf /u01/app/oracle/oradata/dbtest
rm -rf /u01/app/oracle/dbtest_fra