Method for converting the cloned file location in the RMAN Database

Source: Internet
Author: User

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 mongouard to convert the file location between the master database and the standby database.
-- The first string is used to define the location of the target database file, and the second string is used to define the location of the auxiliary database file
-- Example below
*. Db_file_name_convert = ('/u01/database/sybo5','/u02/database/sybo5 ')
*. Log_file_name_convert = ('/u01/database/sybo5','/u02/database/sybo5 ')

-- If other information related to the location of the auxiliary database file, such as the loading points, is the same, you can use the following method to define parameters:
-- 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 scenarios
-- 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 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 = ('sybo5', 'sybo5 ')

-- The following is the case after cloning. It is best to clear these two parameters.
[Oracle @ linux3 ~] $ Rman target sys/oracle @ Sybo auxiliary sys/oracle @ sybo5

RMAN> duplicate target database to sybo5; -- after the command is released, Oracle automatically creates 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
---------------------------------------
Sybo 5 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. 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 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 used to clone a database
Logfile
Group 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, size
Group 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 the target database
Switch datafile all; --> used to update the new path to the control file. This statement 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.
The usage is as follows:
Configure auxname for datafile n to '<new_dir>/file_name ';
Configure auxname for datafile n clear;

-- Author: Robinson
-- Blog:

User-managed database clone

RMAN-based database cloning on the same machine

RMAN duplicate Database

Related Article

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.