The location conversion method of the RMAN database clone file

Source: Internet
Author: User
Tags first string

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

  1. --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
  2. --This parameter can also be used to configure Dataguard is the primary database and standby database file location conversion
  3. --The first string defines the target database file location, and the second string defines the secondary database file location
  4. -As the following example
  5. *.db_file_name_convert = ('/u01/database/sybo3 ', '/u02/database/sybo5 ')
  6. *.log_file_name_convert = ('/u01/database/sybo3 ', '/u02/database/sybo5 ')
  7. --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
  8. --target db Path:/u01/database/sybo3
  9. --auxiliary db Path:/U01/DATABASE/SYBO5
  10. --Do the following definition
  11. *.db_file_name_convert = (' Sybo3 ', ' Sybo5 ')
  12. *.log_file_name_convert = (' Sybo3 ', ' Sybo5 ')
  13. --if it's the following scenario
  14. --target DB Path:
  15. /u01/database/sybo3/oradata/system01.dbf
  16. /u01/database/sybo3/oradata/sysaux01.dbf
  17. /u02/database/sybo3/oradata/undotbs01.dbf
  18. /u02/database/sybo3/oradata/users01.dbf
  19. /u02/database/sybo3/oradata/example01.dbf
  20. --auxiliary DB Path:
  21. /u01/database/sybo5/oradata/system01.dbf
  22. /u01/database/sybo5/oradata/sysaux01.dbf
  23. /u02/database/sybo5/oradata/undotbs01.dbf
  24. /u02/database/sybo5/oradata/users01.dbf
  25. /u02/database/sybo5/oradata/example01.dbf
  26. -As mentioned earlier, because the load point is the same, it can still be defined as above
  27. *.db_file_name_convert = (' Sybo3 ', ' Sybo5 ')
  28. *.log_file_name_convert = (' Sybo3 ', ' Sybo5 ')
  29. -The following is the case after cloning, it is best to clear this two parameters
  30. [[email protected] ~]$ Rman target Sys/[email protected] auxiliary sys/[email protected]
  31. 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
  32. sql> Select name,dbid,open_mode from v$database;
  33. NAME DBID Open_mode
  34. --------- ---------- --------------------
  35. SYBO5 2292457546 READ WRITE
  36. sql> Show Parameter Name_conve
  37. NAME TYPE VALUE
  38. ------------------------------------ ----------- ------------------------------
  39. Db_file_name_convert string Sybo3, Sybo5
  40. Log_file_name_convert string Sybo3, Sybo5
  41. Sql> alter system reset Db_file_name_convert;
  42. System altered.
  43. Sql> alter system reset Log_file_name_convert;
  44. System altered.

2. Using the Rman set newname clause

  1. RMAN provides us with a set newname clause to specify the location of the secondary database data file and the temporary tablespace data file.
  2. 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.
  3. As follows:
  4. Set newname for datafile m to ' <new_dir>/file_name '
  5. Set newname for tempfile N to ' <new_dir>/file_name '
  6. If we can use the following command to clone a database
  7. Rman> Run
  8. {
  9. Set newname for datafile 1 to '/u01/database/sybo5/oradata/system01.dbf ';--Specify a new path for the data file
  10. Set newname for datafile 2 to '/u01/database/sybo5/oradata/sysaux01.dbf ';
  11. Set newname for datafile 3 to '/u01/database/sybo5/oradata/undotbs01.dbf ';
  12. Set newname for datafile 4 to '/u01/database/sybo5/oradata/users01.dbf ';
  13. Set newname for datafile 5 to '/u01/database/sybo5/oradata/example01.dbf ';
  14. Set newname for Tempfile 1 to '/u01/database/sybo5/oradata/temp01.dbf ';--Specify a new path for the log file
  15. Duplicate target database to Sybo5-->duplicate command for cloning databases
  16. LogFile
  17. 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
  18. 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
  19. Group 3 ('/u01/database/sybo5/redo/redo03a.log ','/u01/database/sybo5/redo/redo03b.log ') size 10m;- Number of members, size equals the target database
  20. Switch datafile all; --To update the above new path to the control file, this sentence can be omitted (automatically updated)
  21. }

3. Using Configure Auxname command

  1. Configure Auxname is a new command that starts at Oracle 11g, which stores its values in the control file of the target database
  2. Use the following:
  3. Configure Auxname for datafile N to ' <new_dir>/file_name ';
  4. Configure Auxname for datafile n Clear;
  5. --author:robinson
  6. --blog:http://blog.csdn.net/robinson_0612
  7. The following is the result after setting:
  8. Rman> show Auxname;
  9. RMAN configuration parameters for database with db_unique_name SYBO3 is:
  10. CONFIGURE auxname for datafile '/u01/database/sybo3/oradata/system01.dbf ' to '/u01/database/sybo5/oradata/ SYSTEM01.DBF ';
  11. CONFIGURE auxname for datafile '/u01/database/sybo3/oradata/sysaux01.dbf ' to '/u01/database/sybo5/oradata/ SYSAUX01.DBF ';
  12. CONFIGURE auxname for datafile '/u01/database/sybo3/oradata/undotbs01.dbf ' to '/u01/database/sybo5/oradata/ UNDOTBS01.DBF ';
  13. CONFIGURE auxname for datafile '/u01/database/sybo3/oradata/users01.dbf ' to '/u01/database/sybo5/oradata/ USERS01.DBF ';
  14. CONFIGURE auxname for datafile '/u01/database/sybo3/oradata/example01.dbf ' to '/u01/database/sybo5/oradata/ EXAMPLE01.DBF ';
  15. Rman>run
  16. {
  17. Set until time = "To_date (' 20130725 10:09:53 ', ' yyyymmdd hh24:mi:ss ')" and you can specify Time,scn,sequence
  18. 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
  19. Duplicate target database to clone_db Pfile=/u01/oracle/db_1/dbs/initsybo5.ora
  20. LogFile
  21. '/u01/database/sybo5/redo/redo01a.log ' SIZE 5M,
  22. '/u01/database/sybo5/redo/redo02a.log ' SIZE 5M,
  23. '/u01/database/sybo5/redo/redo03a.log ' SIZE 5M;
  24. }

The location conversion method of the RMAN database clone file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.