When using RMAN to clone a database, if the secondary database (new database) uses a different path from the target database (original database), there is a problem of location conversion. In Oracle, the control file is used to locate the data file and redo the log file online. If the conversion is not correct, the control file cannot find the corresponding data file or log file. Oralce provides three methods for converting file locations. This article describes the three conversion methods.
1. Use the db_file_name_convert and log_file_name_convert Parameters
-- We can define these two parameters in the parameter file spfile/pfile of the auxiliary database for Oracle to automatically convert the File Location Based on this value. This parameter can also be used to configure the primary uard to be the master database and standby. database File Location conversion-the first string is used to define the location of the target database file, the second string is used to define the location of the auxiliary database file-the following example *. db_file_name_convert = ('/u01/database/sybo5','/u02/database/sybo5 ')*. log_file_name_convert = ('/u01/database/sybo3', '/u02/database/sybo5') -- if other information about the location of the auxiliary database file, such as the loading points, is the same, you can directly use the following method to define the parameter -- target dB path:/u01/database/sybo3 -- auxiliary dB path:/u01 /Database/sybo5 -- define as follows *. db_file_name_convert = ('sybo5', 'sybo5 ')*. log_file_name_convert = ('sybo5', 'sybo5') -- in the following case -- target dB path: /u01/database/sybo3/oradata/system01.dbf/u01/database/sybo3/oradata/logs/u02/database/sybo3/oradata/logs/u02/database/sybo3/oradata/users01.dbf /u02/database/sybo3/oradata/example01.dbf -- auxiliary dB path: /u01/database/sybo5/oradata/system01.dbf /U01/database/sybo5/oradata/logs/u02/database/sybo5/oradata/logs/u02/database/sybo5/oradata/users01.dbf/u02/database/sybo5/oradata/example01.dbf -- as described above, since the loading points are the same, they can still be defined as above *. db_file_name_convert = ('sybo5', 'sybo5 ')*. log_file_name_convert = ('sybo3', 'sybo5') -- The following figure shows the clone scenario. It is best to clear these two parameters [Oracle @ linux3 ~] $ RMAN target sys/Oracle @ sybo3 auxiliary sys/Oracle @ sybo5rman> duplicate target database to sybo5; -- after this command is released, oracle will automatically create auxiliary database log files and temporary tablespace data files based on the target database SQL> select name, dbid, open_mode from V $ database; name dbid open_mode --------- ---------- sybo5 2292457546 read writesql> show parameter name_convename type value =----------- mongodb_file_name_convert string sybo3, mongostring sybo3, sybo5sql> alter system reset comment; System altered. SQL> alter system reset log_file_name_convert; System altered.
2. Use the RMAN set newname clause
RMAN provides the set newname clause for specifying the location of the auxiliary database data files and temporary tablespace data files. This command can also be used to restore a data file to a non-fault loading point due to a failed loading point in a specific tablespace or data file. As follows: set newname for datafile m to '<new_dir>/file_name 'set newname for tempfile n to' <new_dir>/file_name '. For example, we can use the following command to clone the database RMAN> run {set newname for datafile 1 to '/u01/database/sybo5/oradata/system01.dbf '; --> specify the new path set newname for datafile 2 to '/u01/database/sybo5/oradata/sysaux01.dbf' for the data file '; set newname for datafile 3 to '/u01/database/sybo5/oradata/undotbs01.dbf'; Set newname for datafile 4 to'/u01/database/sybo5/oradata/users01.dbf '; set newname for datafile 5 to '/u01/database/sybo5/oradata/example01.dbf'; Set newname for tempfile 1 to'/u01/database/sybo5/oradata/temp01.dbf '; --> specify the new path duplicate target database to sybo5 for the log file --> the duplicate command is used to clone the database logfilegroup 1 ('/u01/database/sybo5/Redo/redo01a. log', '/u01/database/sybo5/Redo/redo01b. log ') Size 10 m, --> You can specify the log group and number of members, sizegroup 2 ('/u01/database/sybo5/Redo/redo02a. log', '/u01/database/sybo5/Redo/redo02b. log') Size 10 m, --> If the logfile part is not specified, the number of groups and group 3 ('/u01/database/sybo5/Redo/redo03a. log', '/u01/database/sybo5/Redo/redo03b. log') Size 10 m; --> Number of Members, size is equivalent to switch datafile all to the target database; --> used to update the new path to the control file, this sentence can be omitted (automatically updated )}
3. Use the configure auxname command
Configure auxname is a new command provided at the beginning of Oracle 11g. This configuration command stores its value in the control file of the target database for usage as follows: configure auxname for datafile n to '<new_dir>/file_name'; configure auxname for datafile n clear; -- Author: Robinson -- Blog: created RMAN> show auxname; RMAN configuration parameters for database with db_unique_name sybo3 are: Configure auxname for datafile '/u01/database/sybo3/oradata/system01.dbf' to '/u01/database/sybo5/oradata/system01.dbf '; configure auxname for datafile '/u01/database/sybo3/oradata/sysaux01.dbf' to '/u01/database/sybo5/oradata/sysaux01.dbf '; configure auxname for datafile '/u01/database/sybo3/oradata/undotbs01.dbf' to '/u01/database/sybo5/oradata/undotbs01.dbf '; configure auxname for datafile '/u01/database/sybo3/oradata/users01.dbf' to '/u01/database/sybo5/oradata/users01.dbf '; configure auxname for datafile '/u01/database/sybo3/oradata/example01.dbf' to '/u01/database/sybo5/oradata/example01.dbf '; RMAN> run {set until time = "to_date ('1970 10:09:53 ', 'yyyymmdd hh24: MI: ss')"; --> You can specify time, SCN, sequence set newname for tempfile 1 to '/u01/database/sybo5/oradata/temp01.dbf'; --> Note: Configure auxname does not support tempfile, set newnameduplicate target database to clone_db pfile =/u01/Oracle/db_1/dbs/initsybo5.oralogfile '/u01/database/sybo5/Redo/redo01a must be used here. log 'size 5 m, '/u01/database/sybo5/Redo/redo02a. log 'size 5 m, '/u01/database/sybo5/Redo/redo03a. log 'size 5 m ;}
References
User-managed database clone
RMAN-based database cloning on the same machine
Oracle cold backup
Oracle Hot Backup
Concept of Oracle backup recovery
Oracle instance recovery
Oracle recovery based on user management
System tablespace management and Backup Recovery
Sysaux tablespace management and recovery
Oracle backup control file recovery (unsing backup controlfile)
RMAN overview and architecture
RMAN configuration, Monitoring and Management
Detailed description of RMAN backup
RMAN restoration and recovery
Create and use RMAN catalog
Create RMAN storage script based on catalog
Catalog-based RMAN backup and recovery
RMAN backup path confusion
Customize the date and time format displayed by RMAN
Backup and recovery of read-only tablespace
Incomplete recovery of Oracle based on user management
Understanding using backup controlfile
Use RMAN for recovery from different machine backups (WIN platform)
Use RMAN to migrate a file system database to ASM
Oracle backup policy (RMAN) in Linux)
Linux RMAN backup shell script
Use RMAN to migrate the database to a different machine
Run the SQL statement at the RMAN prompt.
Oracle RMAN-based Incomplete recovery (Incomplete recovery by RMAN)