When using Rman to clone a database, there is a problem with location conversions if the secondary database (the new database) uses a different path than the target database (the original database). In Oracle, the control file is used to locate the data file and the online redo log file, if there is no correct conversion, the control file can not find the corresponding data file, log file. This oralce provides us with three ways to convert file locations. This article is a description of the three conversion methods.
1. Using Db_file_name_convert and Log_file_name_convert parameters
- --We can define these two parameters in the secondary database parameter file Spfile/pfile for Oracle to automatically convert file locations based on this value
- --This parameter can also be used to configure Dataguard is the primary database and standby database file location conversion
- --The first string defines the target database file location, and the second string defines the secondary database file location
- -As the following example
- *.db_file_name_convert = ('/u01/database/sybo3 ', '/u02/database/sybo5 ')
- *.log_file_name_convert = ('/u01/database/sybo3 ', '/u02/database/sybo5 ')
- --If other information about the location of the secondary database file, such as the load point, is the same, you can define the parameters directly using the following method
- --target db Path:/u01/database/sybo3
- --auxiliary db Path:/U01/DATABASE/SYBO5
- --Do the following definition
- *.db_file_name_convert = (' Sybo3 ', ' Sybo5 ')
- *.log_file_name_convert = (' Sybo3 ', ' Sybo5 ')
- --if it's the following scenario
- --target DB Path:
- /u01/database/sybo3/oradata/system01.dbf
- /u01/database/sybo3/oradata/sysaux01.dbf
- /u02/database/sybo3/oradata/undotbs01.dbf
- /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/sysaux01.dbf
- /u02/database/sybo5/oradata/undotbs01.dbf
- /u02/database/sybo5/oradata/users01.dbf
- /u02/database/sybo5/oradata/example01.dbf
- -As mentioned earlier, because the load point is the same, it can still be defined as above
- *.db_file_name_convert = (' Sybo3 ', ' Sybo5 ')
- *.log_file_name_convert = (' Sybo3 ', ' Sybo5 ')
- -The following is the case after cloning, it is best to clear this two parameters
- [[email protected] ~]$ Rman target Sys/[email protected] auxiliary sys/[email protected]
- Rman> duplicate target database to Sybo5; --When the command is published, Oracle automatically creates the secondary 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 WRITE
- sql> Show Parameter Name_conve
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- Db_file_name_convert string Sybo3, Sybo5
- Log_file_name_convert string Sybo3, Sybo5
- Sql> alter system reset Db_file_name_convert;
- System altered.
- Sql> alter system reset Log_file_name_convert;
- System altered.
2. Using the Rman set newname clause
- RMAN provides us with a set newname clause to specify the location of the secondary database data file and the temporary tablespace data file.
- The command can also be used for a specific tablespace or data file to recover a data file to a non-failed load point because of a load point failure.
- As follows:
- Set newname for datafile m to ' <new_dir>/file_name '
- Set newname for tempfile N to ' <new_dir>/file_name '
- If we can use the following command to clone a database
- Rman> Run
- {
- Set newname for datafile 1 to '/u01/database/sybo5/oradata/system01.dbf ';--Specify a new path for the data file
- Set newname for datafile 2 to '/u01/database/sybo5/oradata/sysaux01.dbf ';
- 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 a new path for the log file
- Duplicate target database to Sybo5-->duplicate command for cloning databases
- LogFile
- Group 1 ('/u01/database/sybo5/redo/redo01a.log ','/u01/database/sybo5/redo/redo01b.log ') size 10m,- , you can specify the log group and the number of members, size
- Group 2 ('/u01/database/sybo5/redo/redo02a.log ','/u01/database/sybo5/redo/redo02b.log ') size 10m, --If the logfile part is not specified, its group number and
- Group 3 ('/u01/database/sybo5/redo/redo03a.log ','/u01/database/sybo5/redo/redo03b.log ') size 10m;- Number of members, size equals the target database
- Switch datafile all; --To update the above new path to the control file, this sentence can be omitted (automatically updated)
- }
3. Using Configure Auxname command
- Configure Auxname is a new command that starts at Oracle 11g, which stores its values in the control file of the target database
- Use the following:
- Configure Auxname for datafile N to ' <new_dir>/file_name ';
- Configure Auxname for datafile n Clear;
- --author:robinson
- --blog:http://blog.csdn.net/robinson_0612
- The following is the result after setting:
- Rman> show Auxname;
- RMAN configuration parameters for database with db_unique_name SYBO3 is:
- 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 (' 20130725 10:09:53 ', ' yyyymmdd hh24:mi:ss ')" and you can specify Time,scn,sequence
- Set newname for Tempfile 1 to '/u01/database/sybo5/oradata/temp01.dbf ';-Note that configure Auxname does not support tempfile, which requires the use of Set newname
- Duplicate target database to clone_db Pfile=/u01/oracle/db_1/dbs/initsybo5.ora
- LogFile
- '/u01/database/sybo5/redo/redo01a.log ' SIZE 5M,
- '/u01/database/sybo5/redo/redo02a.log ' SIZE 5M,
- '/u01/database/sybo5/redo/redo03a.log ' SIZE 5M;
- }
The location conversion method of the RMAN database clone file