Different directory recovery for Rman backup set under Linux

Source: Internet
Author: User
Tags sqlplus

Yesterday at the customer did an Rman recovery, the production library to get a copy to the test library, the total library of about 80G, a total of 2 hours, when the customer's environment is Windows 11.2.0.3, this morning under Linux re-test a bit, recorded for everyone reference

Environment:

All operations are distinguished by host name

SOURCE Library:

Host name Bre1 instance named Bre1 data file directory under/u01/app/oradata

Target Library:

Host name Bre2 data file ready to be placed under/bre1/oradata

Needless to say, the following is the actual procedure

1. Create a backup set in the source library and copy it to the target library

The copied directory can be used in the same directory as the original backup, or it may be inconsistent

Backup system tablespace Rman automatically backs up parameter files and control files

Rman> Backup Database format '/home/oracle/%u.bak '; Starting backup at 21-aug-2014 10:03:35using channel Ora_disk_1channel ora_disk_1:starting full datafile backup Setchanne L ora_disk_1:specifying datafile (s) in Backup setinput datafile file number=00001 name=/u01/app/oracle/oradata/bre1/ System01.dbfinput datafile file number=00002 name=/u01/app/oracle/oradata/bre1/sysaux01.dbfinput datafile file number =00003 name=/u01/app/oracle/oradata/bre1/undotbs01.dbfinput datafile file number=00005 name=/u01/app/oracle/oradata /bre1/test.dbfinput datafile file number=00004 name=/u01/app/oracle/oradata/bre1/users01.dbfchannel ORA_DISK_1: Starting piece 1 at 21-aug-2014 10:03:36channel ora_disk_1:finished piece 1 at 21-aug-2014 10:03:51piece Handle=/home/ora Cle/03pggb7o_1_1.bak tag=tag20140821t100336 Comment=nonechannel ora_disk_1:backup set complete, elapsed time: 00:00:15channel ora_disk_1:starting full datafile backup Setchannel ora_disk_1:specifying datafile (s) in Backup setinclu Ding curRent control file in Backup setincluding current SPFILE in Backup Setchannel ora_disk_1:starting piece 1 at 21-aug-2014 1 0:03:52channel ora_disk_1:finished piece 1 at 21-aug-2014 10:03:53piece Handle=/home/oracle/04pggb87_1_1.bak tag= tag20140821t100336 Comment=nonechannel ora_disk_1:backup set complete, elapsed time:00:00:01finished backup at 21-AUG-2 014 10:03:53[[email protected] ~]$ SCP Bre1:/home/oracle/03pggb7o_1_1.bak. The authenticity of host ' Bre1 (192.168.56.45) ' can ' t be established. RSA key fingerprint is 73:56:4c:3a:01:3f:50:c8:d8:3a:5d:d5:21:00:6a:fe. Is you sure want to continue connecting (yes/no)? yeswarning:permanently added ' bre1,192.168.56.45 ' (RSA) to the list of known hosts.                                                                                     [email protected] ' s Password:03pggb7o_1_1.bak 100% 336MB 37.3mb/s 00:09 [[email protected] ~]$ SCP Bre1:/home/oracle/04pggb87_1_1.bak. [email protected] ' s password:04pggb87_1_1. bak 100% 9600KB 9.4mb/s 00:00   


2. Restore SPFile, open the database using Nomount

Edit one of the simplest pfile, only db_name:

[Email protected] dbs]$ VI initbre1.ora[[email protected] dbs]$ cat Initbre1.ora Db_name=bre1

Then you can nomount open the database:

Sql> Startup Nomount;oracle instance started. Total System Global area  229683200 bytesfixed size    2251936 bytesvariable size  171967328 bytesdatabase Buffers   50331648 Bytesredo buffers    

Then use Rman to recover the SPFile:


Try to take care of the database using SPFile

[Email protected] ~]$ sqlplus/as sysdbasql*plus:release 11.2.0.4.0 Production on Thu 10:08:01 2014Copyright (c) 1982, Oracle.  All rights reserved. Connected to an idle instance. Sql> startup Nomount;ora-01078:failure in processing system parameterslrm-00109:could not open parameter file '/u01/a Pp/oracle/product/11.2.0/db_1/dbs/initbre1.ora ' sql> startup nomount;ora-01078:failure in processing system Parameterslrm-00109:could not open parameter file '/u01/app/oracle/product/11.2.0/db_1/dbs/initbre1.ora ' SQL> Startup Nomount;ora-09925:unable to create audit trail filelinux-x86_64 error:2: No such file or directoryadditional inf ormation:9925
There are many related directories are not created, you can use strings Spfilebre1.ora to view the contents of SPFile, build the relevant directory, and give permission. These all do well after nomount open the database no longer error.

3. Recovery control files

Login to Rman, the control file restore will be restored to the location specified in the parameter file, so the parameter file specified by the control file directory must exist, or error, such as the beginning of the following I did not create an error, and then create the completion will not error, if you want to restore to other places, You can modify the parameter file to specify the appropriate address.

rman> restore Controlfile from '/home/oracle/04pggb87_1_1.bak '; Starting restore at 21-aug-2014 10:26:14using channel Ora_disk_1channel ora_disk_1:restoring control fileRMAN-00571: = = = ========================================================rman-00569: =============== ERROR MESSAGE STACK FOLLOWS = = = ===========rman-00571: ===========================================================rman-03002:failure of Restore Command at 08/21/2014 10:26:15ora-19870:error while restoring backup piece/home/oracle/04pggb87_1_1.bakora-19504: Failed to create file '/u01/app/oracle/oradata/bre1/control01.ctl ' ora-27040:file create error, unable to create Filelinu x-x86_64 error:2: No such file or directoryadditional information:1rman> restore controlfile from '/HOME/ORACLE/04PGG B87_1_1.bak '; Starting restore at 21-aug-2014 10:26:50using channel Ora_disk_1channel ora_disk_1:restoring control fileRMAN-00571: = = = ========================================================rman-00569: =============== ERROR MEssage STACK follows ===============rman-00571: =========================================================== Rman-03002:failure of Restore command at 08/21/2014 10:26:51ora-19504:failed to create file "/u01/app/oracle/fast_recove Ry_area/bre1/control02.ctl "Ora-27040:file create error, unable to create filelinux-x86_64 error:2: No such file or Direc Toryadditional information:1ora-19600:input file is control file (/U01/APP/ORACLE/ORADATA/BRE1/CONTROL01.CTL) Ora-19601:output file is control file (/u01/app/oracle/fast_recovery_area/bre1/control02.ctl) rman> restore Controlfile from '/home/oracle/04pggb87_1_1.bak '; Starting restore at 21-aug-2014 10:27:24using channel Ora_disk_1channel ora_disk_1:restoring control FileChannel ORA_DIS K_1:restore complete, elapsed time:00:00:01output file Name=/u01/app/oracle/oradata/bre1/control01.ctloutput file name=/u01/app/oracle/fast_recovery_area/bre1/control02.ctlfinished Restore at 21-aug-2014 10:27:25

4.mount database, registering backup sets

Restart the database and you can boot directly to mount

Sql> Startup Mount;oracle instance started. Total System Global area  835104768 bytesfixed size    2257840 bytesvariable size  503319632 bytesdatabase Buffers  322961408 Bytesredo buffers    

If there is a change in the file directory where the backup set is located, you need to register the backup set by manual catalog, here we copy the copied backup file to/home/oracle/backup, demo the manual catalog backup set

[[email protected] ~]$ ls03pggb7o_1_1.bak 04pggb87_1_1.bak pfile.ora test[[email protected] ~]$ mkdir Backup [[email protected] ~]$ mv *.bak backup[[email protected] ~]$ ls backup03pggb7o_1_1.bak 04pggb87_1_1.bakRMAN& Gt Catalog backuppiece '/home/oracle/backup/03pggb7o_1_1.bak '; Starting implicit crosscheck backup at 21-aug-2014 10:32:10using target database control file instead of recovery Cataloga llocated Channel:ora_disk_1channel ora_disk_1:sid=10 Device type=diskcrosschecked 1 objectsfinished implicit Crosscheck backup at 21-aug-2014 10:32:10starting implicit crosscheck copy at 21-aug-2014 10:32:10using channel ORA_DISK_1  Finished implicit crosscheck copy at 21-aug-2014 10:32:11searching for all files in the recovery areacataloging files...no Files catalogedcataloged backup piecebackup piece Handle=/home/oracle/backup/03pggb7o_1_1.bak recid=2 STAMP= 856175531rman> Catalog backuppiece '/home/oracle/backup/04pggb87_1_1.bak '; cataloged backup Piecebackup PiecE Handle=/home/oracle/backup/04pggb87_1_1.bak recid=3 stamp=856175550 

5. Use set NewName to restore a data file to a different directory

The original data file directory under/u01/admin/oradata, we restore the data file to/bre1/oradata below,%b means to get only the file name, no directory information

[[email protected] ~]# mkdir-p/bre1/oradata[[email protected] ~]# chown-r oracle:oinstall/bre1[[email  protected] ~]$ rman target/recovery manager:release 11.2.0.4.0-production on Thu 10:36:10 2014Copyright (  c) 1982, the Oracle and/or its affiliates. All rights reserved.connected to target Database:bre1 (dbid=2522432392, not open) Run{allocate channel ch1 device type dis  K;set newname for database to '/bre1/oradata/%b '; restore Database;release channel ch1;6>}using target database control File instead of recovery catalogallocated channel:ch1channel ch1:sid=396 device type=diskexecuting command:set NEWNAME Starting restore at 21-aug-2014 10:38:03channel ch1:starting datafile backup set Restorechannel ch1:specifying datafile ( s) to restore from backup Setchannel ch1:restoring datafile 00001 to/bre1/oradata/system01.dbfchannel ch1:restoring dat Afile 00002 to/bre1/oradata/sysaux01.dbfchannel ch1:restoring datafile 00003 to/bre1/oradata/undotbs01.dBfchannel ch1:restoring datafile 00004 to/bre1/oradata/users01.dbfchannel ch1:restoring datafile 00005 to/bre1/oradata /test.dbfchannel ch1:reading from backup Piece/home/oracle/backup/03pggb7o_1_1.bakchannel ch1:piece handle=/home/ Oracle/backup/03pggb7o_1_1.bak Tag=tag20140821t100336channel ch1:restored backup piece 1channel ch1:restore complete, Elapsed time:00:00:45finished Restore at 21-aug-2014 10:38:48released channel:ch1 data files are in: [[email protected] ~]# Ls-l/bre1/oradatatotal 1564468-rw-r-----1 Oracle Oinstall 629153792, 10:38 sysaux01.dbf-rw-r-----1 Oracle Oinsta ll 734011392 10:38 system01.dbf-rw-r-----1 Oracle Oinstall 20979712-10:38 test.dbf-rw-r-----1 Oracle Oins Tall 209723392 10:38 undotbs01.dbf-rw-r-----1 Oracle Oinstall 6561792-10:38 users01.dbf

The data said that you can use the switch datafile all to directly modify the file directory in the control file, but I tried to look like no, or need to manually rename, the following is I manually modify the control file in the data file directory, first look at the current data file directory

Sql> select name from V$datafile; NAME--------------------------------------------------------------------------------/u01/app/oracle/oradata/ bre1/system01.dbf/u01/app/oracle/oradata/bre1/sysaux01.dbf/u01/app/oracle/oradata/bre1/undotbs01.dbf/u01/app/ Oracle/oradata/bre1/users01.dbf/u01/app/oracle/oradata/bre1/test.dbfsql> select name from V$tempfile; NAME--------------------------------------------------------------------------------/u01/app/oracle/oradata/ Bre1/temp01.dbfsql> Select member from V$logfile; MEMBER--------------------------------------------------------------------------------/u01/app/oracle/oradata/ Bre1/redo01.log/u01/app/oracle/oradata/bre1/redo02.log/u01/app/oracle/oradata/bre1/redo03.log

I wrote a concatenation of SQL to convert the data file directory:

Select ' ALTER DATABASE rename file ' | | name| | ' to '/bre1/oradata ' | | substr (name,length (name)-instr (reverse (name), '/') +1,instr (reverse (name), '/')) | | '; ' from V$datafile
UNION ALL
Select ' ALTER DATABASE rename file ' | | name| | ' to '/bre1/oradata ' | | substr (name,length (name)-instr (reverse (name), '/') +1,instr (reverse (name), '/')) | | '; ' from V$tempfile
UNION ALL
Select ' ALTER DATABASE rename file ' | | member| | ' to '/bre1/oradata ' | | SUBSTR (Member,length (member)-INSTR (reverse (Member), '/') +1,instr (reverse (Member), '/')) | | '; ' from V$logfile
;

Select ' ALTER DATABASE rename file ' | | name| | ' to '/bre1/oradata ' | | substr (name,length (name)-instr (reverse (name), '/') +1,instr (reverse (name), '/')) | | '; ' from v$datafileunion Allselect ' ALTER DATABASE rename file ' | | name| | ' to '/bre1/oradata ' | | substr (name,length (name)-instr (reverse (name), '/') +1,instr (reverse (name), '/')) | | '; ' from v$tempfileunion Allselect ' ALTER DATABASE rename file ' | | member| | ' to '/bre1/oradata ' | | SUBSTR (Member,length (member)-INSTR (reverse (Member), '/') +1,instr (reverse (Member), '/')) | | '; ' from V$logfile 6; ' Alterdatabaserenamefile ' | | name| | " To '/bre1/oradata ' | | SUBSTR (name,length (name)-instr (REVERSE (name), '/') +1,instr (REVERSE (name), '/')) | | "; --------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------ALTER DATABASE Rename File '/bre1/oradata/system01.dbf ' to '/BRE1/ORADATA/SYSTEM01.DBF '; Alter Database rename FILe '/bre1/oradata/sysaux01.dbf ' to '/BRE1/ORADATA/SYSAUX01.DBF '; Alter DATABASE rename file '/bre1/oradata/ Undotbs01.dbf ' to '/BRE1/ORADATA/UNDOTBS01.DBF '; Alter DATABASE rename file '/bre1/oradata/users01.dbf ' to '/bre1/ ORADATA/USERS01.DBF '; Alter DATABASE rename file '/bre1/oradata/test.dbf ' to '/BRE1/ORADATA/TEST.DBF '; ALTER DATABASE Rename file '/u01/app/oracle/oradata/bre1/temp01.dbf ' to '/BRE1/ORADATA/TEMP01.DBF '; Alter DATABASE rename file '/bre1/ Oradata/redo01.log ' to '/bre1/oradata/redo01.log '; Alter DATABASE rename file '/bre1/oradata/redo02.log ' to '/bre1/ Oradata/redo02.log '; Alter DATABASE rename file '/bre1/oradata/redo03.log ' to '/bre1/oradata/redo03.log '; alter Database rename file '/u01/app/oracle/oradata/bre1/system01.dbf ' to '/BRE1/ORADATA/SYSTEM01.DBF '; ALTER DATABASE Rename file '/u01/app/oracle/oradata/bre1/sysaux01.dbf ' to '/BRE1/ORADATA/SYSAUX01.DBF '; Alter DATABASE rename file '/ U01/app/oracle/oradata/bre1/undotbs01.dbf ' to '/BRE1/ORADATA/UNDOTBS01.DBF '; ALTER DATABASE renAme file '/u01/app/oracle/oradata/bre1/users01.dbf ' to '/BRE1/ORADATA/USERS01.DBF '; Alter DATABASE rename file '/u01/ App/oracle/oradata/bre1/test.dbf ' to '/BRE1/ORADATA/TEST.DBF '; Alter DATABASE rename file '/u01/app/oracle/oradata/ Bre1/redo01.log ' to '/bre1/oradata/redo01.log '; Alter DATABASE rename file '/u01/app/oracle/oradata/bre1/redo02.log ' To '/bre1/oradata/redo02.log ';D atabase altered. Sql> Database altered. Sql> Database altered. Sql> Database altered. Sql> Database altered. Sql> Database altered. Sql> Database altered. sql> ALTER DATABASE rename file '/u01/app/oracle/oradata/bre1/redo03.log ' to '/bre1/oradata/redo03.log ';D atabase Altered.
Rename after the data file directory in the control file has been changed to/bre1/oradata, then it can be restored.
6. Recovering a Database

I'm here to test there's no recovery archive log, if it is a formal production library, you also need to restore the archive log, you may also need to use the catalog ARCHIVELOG to register the archived backup set and use in Rman
RUN
{
SET ARCHIVELOG DESTINATION to '/home/oracle ';
RESTORE ARCHIVELOG All;
}
To restore the archive log.
Alternatively, you can modify the archive directory in Controlfile to restore it. After the archive log is restored, database recovery is possible.

[Email protected] ~]$ sqlplus/as sysdbasql*plus:release 11.2.0.4.0 Production on Thu 11:16:06 2014Copyright (c) 1982, Oracle.  All rights reserved.  Connected to:oracle Database 11g Enterprise Edition Release 11.2.0.4.0-64bit productionwith The partitioning, OLAP, Data Mining and Real application testing optionssql> recover database using Backup Controlfile until Cancel;ora-00279:chan GE 830841 generated at 08/21/2014 10:03:36 needed for thread 1ora-00289:suggestion:/arch1_42_851018056.dbfora-00280:ch Ange 830841 for thread 1 was in sequence #42Specify log: {<ret>=suggested | filename | AUTO | Cancel}cancelmedia recovery cancelled. sql> ALTER DATABASE open Resetlogs;database altered.
You may encounter ora-00392 errors during the open process,
Workaround:
Use sql> ALTER DATABASE clear logfile Group 2;
This is a successful recovery!

Summary:
The main difficulty is to be familiar with Rman, you need to use the statement to modify the file location in the control file, otherwise it will be an error to find the relevant files.
If the directory of the backup set changes, you need to register the backup set to the control file by manual catalog, and rename file.

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.