Sunteți pe pagina 1din 10

Home

About

Contact Us

Categories
Oracle Database (76)
Backup and Recovery (20)
Troubleshooting (21)
Errors (11)
Administration (14)
Database Control (3)
Network (6)
High Availability (13)
Data Guard (13)
Performance (2)
SecureFiles and Large Objects
(1)
Security (1)
Utilities (1)
OCI/OCCI (1)
Internals (1)
Grid Control (19)
TimesTen (14)
Linux (9)
Java (13)
JDBC (8)
JavaFX (4)
Windows (5)
VirtualBox (4)
Grid Infrastructure (4)
NetBeans (2)
Berkeley DB (2)
JDeveloper (2)
Golden Gate (2)
Oracle Fusion Middleware (1)
Weblogic (1)
Video (1)
MySQL (1)
Cloud Control (1)
announcements (1)

Terms of Use

Search

Restore database to another host using RMAN


by Eric Jenkinson on April 28, 2010
Categories: Backup and Recovery,Oracle Database
Tagged: host, recover, restore, rman
This document will detail the steps to restore a database on a new host using RMAN. For this demonstration we will be
using Oracle Database 11gR2 on Linux and disk based backup.
One of the first things we want to do is get the Database ID (DBID) from the database in which we will be restoring its
backup. You can find the DBID by connecting to the database with RMAN as shown below.
1
2
3
4
5
6
7
8
9
10
11

[oracle@ora1 ~]$ rman


Recovery Manager: Release 11.2.0.1.0 - Production on Tue Apr 27 09:40:34 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates.

All rights reserved.

RMAN> connect target /


connected to target database: ORCL (DBID=1239150297)
RMAN>

If you are unable to connect to the database you can also find the DBID by inspecting the file name of the control file
autobackup. For example, c-1239150297-20100427-00, is a control file autobackup. The first group of numbers
appearing after the c-, 123915029, is the DBID.
When we restore the database we are not going to have the active redo logs from the original database so we want to stop
the recovery at the last SCN in the archive logs. We can find the last SCN by querying V$ARCHIVED_LOG.
1
2
3
4
5
6
7
8
9
10

SQL>
2
3
4

select max(next_change#)
from v$archived_log
where archived = 'YES'
group by thread#;

MAX(NEXT_CHANGE#)
----------------1375117
SQL>

Here we see that the archive logs contain log information up to SCN 1375117. That is our stopping SCN. We can also find
the last SCN in our archive logs through RMAN using LIST BACKUP OF ARCHIVELOG ALL.

Generated with www.html-to-pdf.net

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

RMAN> list backup of archivelog all;


List of Backup Sets
===================
BS Key Size
Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ --------------54
2.09M
DISK
00:00:01
27-APR-10
BP Key: 54
Status: AVAILABLE Compressed: NO Tag: TAG20100427T094350
Piece Name: /u03/app/oracle/oradata/orcl/backup/1vlc5nqn_1_1
List
Thrd
---1
1
1

of Archived Logs in backup set 54


Seq
Low SCN
Low Time Next SCN
------- ---------- --------- ---------12
1359005
26-APR-10 1359528
13
1359528
26-APR-10 1359609
14
1359609
26-APR-10 1362018

Next Time
--------26-APR-10
26-APR-10
26-APR-10

BS Key Size
Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ --------------55
13.82M
DISK
00:00:02
27-APR-10
BP Key: 55
Status: AVAILABLE Compressed: NO Tag: TAG20100427T094350
Piece Name: /u03/app/oracle/oradata/orcl/backup/20lc5nqr_1_1
List
Thrd
---1

of Archived Logs in backup set 55


Seq
Low SCN
Low Time Next SCN
Next Time
------- ---------- --------- ---------- --------1
1362019
26-APR-10 1374991
27-APR-10

BS Key Size
Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ --------------60
136.00K
DISK
00:00:00
27-APR-10
BP Key: 60
Status: AVAILABLE Compressed: NO Tag: TAG20100427T094652
Piece Name: /u03/app/oracle/oradata/orcl/backup/24lc5o0c_1_1
List
Thrd
---1
RMAN>

of Archived Logs in backup set 60


Seq
Low SCN
Low Time Next SCN
Next Time
------- ---------- --------- ---------- --------2
1374991
27-APR-10 1375117
27-APR-10

Page 1 / 10

38
39
40
41
42
43

List
Thrd
---1

of Archived Logs in backup set 60


Seq
Low SCN
Low Time Next SCN
Next Time
------- ---------- --------- ---------- --------2
1374991
27-APR-10 1375117
27-APR-10

RMAN>

Looking through the output above we see that highest Next SCN is 1375117 which is part of backup set 60.
Next we need to make the backup available to the new host. If the backups reside on a shared file system that the new host
has access to then there is nothing more to do. If the backups are on local storage we will need to transfer the backups to
the new host.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

[oracle@ora1 backup]$ sftp oracle@ora2


Connecting to ora2...
oracle@ora2's password:
sftp> cd /u01/app/oracle/oradata/orcl/backup
sftp> mput *
Uploading 1vlc5nqn_1_1 to /u01/app/oracle/oradata/orcl/backup/1vlc5nqn_1_1
1vlc5nqn_1_1
100% 2142KB
2.1MB/s
Uploading 20lc5nqr_1_1 to /u01/app/oracle/oradata/orcl/backup/20lc5nqr_1_1
20lc5nqr_1_1
100%
14MB 13.8MB/s
Uploading 21lc5nqv_1_1 to /u01/app/oracle/oradata/orcl/backup/21lc5nqv_1_1
21lc5nqv_1_1
100% 1009MB 13.3MB/s
Uploading 22lc5nqv_1_1 to /u01/app/oracle/oradata/orcl/backup/22lc5nqv_1_1
22lc5nqv_1_1
100%
80MB 13.4MB/s
Uploading 23lc5ns4_1_1 to /u01/app/oracle/oradata/orcl/backup/23lc5ns4_1_1
23lc5ns4_1_1
100%
33MB 16.6MB/s
Uploading 24lc5o0c_1_1 to /u01/app/oracle/oradata/orcl/backup/24lc5o0c_1_1
24lc5o0c_1_1
100% 137KB 136.5KB/s
Uploading c-1239150297-20100426-00 to /u01/app/oracle/oradata/orcl/backup/c-1239150297-20
c-1239150297-20100426-00
100% 9600KB
9.4MB/s
Uploading c-1239150297-20100427-00 to /u01/app/oracle/oradata/orcl/backup/c-1239150297-20
c-1239150297-20100427-00
100% 9632KB
9.4MB/s
sftp> exit
[oracle@ora1 backup]$

All of the rest of the steps will take place on the new host.
Set the ORACLE_SID to the SID of the database that made the backup and start up RMAN and connect to the target.
1
2
3
4
5
6
7
8
9
10
11
12

[oracle@ora2 backup]$ export ORACLE_SID=orcl


[oracle@ora2 backup]$ rman
Recovery Manager: Release 11.2.0.1.0 - Production on Tue Apr 27 11:27:23 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates.

All rights reserved.

RMAN> connect target /


connected to target database (not started)
RMAN>

We now need to set the DBID and bring the database in mount mode. When we bring the database up in mount mode we
will receive errors because the parameter file is not found. This is to be expected as we are restoring to a new host. Oracle
willuseadummyparameterfileforthetimebeing.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

RMAN> set dbid 1239150297


executing command: SET DBID
RMAN> startup nomount
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/ini
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers

159019008 bytes
1335192
75497576
79691776
2494464

bytes
bytes
bytes
bytes

RMAN>

Now with the database in mount mode we need to restore the SPFILE. We are going to need to make some changes to the
SPFILE so we will restore SPFILE to a PFILE. The SPFILE is stored in the control file autobackup. All of the RMAN
configuration parameters values are at their defaults so we will need to set the location for the control file autobackup.
1
2
3
4
5
6

RMAN> show controlfile autobackup format;


RMAN configuration parameters for database with db_unique_name DUMMY are:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
RMAN>

Below we will set the location for the control file autobackup and restore the SPFILE to a PFILE and then we shutdown the
database.

Generated with www.html-to-pdf.net

1
2
3
4
5
6
7
8
9
10

RMAN> set controlfile autobackup format for device type disk to '/u01/app/oracle/oradata/
executing command: SET CONTROLFILE AUTOBACKUP FORMAT
RMAN> restore spfile
2>
to pfile '/u01/app/oracle/oradata/orcl/initorcl.ora'
3>
from autobackup;
Starting restore at 27-APR-10
allocated channel: ORA_DISK_1

Page 2 / 10

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

RMAN> restore spfile


2>
to pfile '/u01/app/oracle/oradata/orcl/initorcl.ora'
3>
from autobackup;
Starting restore at 27-APR-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1:
channel ORA_DISK_1:
channel ORA_DISK_1:
channel ORA_DISK_1:
Finished restore at

looking for AUTOBACKUP on day: 20100427


AUTOBACKUP found: /u01/app/oracle/oradata/orcl/backup/c-1239150297-20
restoring spfile from AUTOBACKUP /u01/app/oracle/oradata/orcl/backup/
SPFILE restore from AUTOBACKUP complete
27-APR-10

RMAN> shutdown abort;


Oracle instance shut down
RMAN>

Now that we have the SPFILE weneedtoeditthesomeoftheparametertoreflectthenewhostsfilesystemwere


appropriate. Below is a list of the some of the parameter you might need to change in your environment. These directories
must exist on the new host.
1
2
3
4
5
6
7

*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.control_files='/u02/app/oracle/oradata/orcl/ctl/control01.ctl','/u01/app/oracle/flash_re
*.db_recovery_file_dest_size=4039114752
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.diagnostic_dest='/u01/app/oracle'
*.log_archive_dest_1='LOCATION=/u02/app/oracle/oradata/orcl/arch'
*.local_listener='LISTENER_ORCL'

Note: If you are using 11g you to ensure your kernel parameters are set appropriately to avoid a possible ORA-00845.
1
2
3
4
5

[oracle@ora2 orcl]$ oerr ora 00845


00845, 00000, "MEMORY_TARGET not supported on this system"
// *Cause: The MEMORY_TARGET parameter was not supported on this operating system or /dev/
// *Action: Refer to documentation for a list of supported operating systems. Or, size /de
[oracle@ora2 orcl]$

After making the necessary changes to the PFILE we now will bring the database back up in NOMOUNT mode so we can
restore the control files. When bringing the database up in NOMOUNT mode we will use the PFILE we edited earlier.
1
2
3
4
5
6
7
8
9
10
11
12
13

RMAN> startup nomount pfile='/u01/app/oracle/oradata/orcl/initorcl.ora';


connected to target database (not started)
Oracle instance started
Total System Global Area

849530880 bytes

Fixed Size
Variable Size
Database Buffers
Redo Buffers

1339824
528485968
314572800
5132288

bytes
bytes
bytes
bytes

RMAN>

Just like the SPFILE we will use the autobackup to restore the control file after setting the control file autobackup format.
After restoring the control files we mount the database.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

RMAN> set controlfile autobackup format for device type disk to '/u01/app/oracle/oradata/
executing command: SET CONTROLFILE AUTOBACKUP FORMAT
RMAN> restore controlfile from autobackup;
Starting restore at 27-APR-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
recovery area destination: /u01/app/oracle/flash_recovery_area
database name (or database unique name) used for search: ORCL
channel ORA_DISK_1: no AUTOBACKUPS found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20100427
channel ORA_DISK_1: AUTOBACKUP found: /u01/app/oracle/oradata/orcl/backup/c-1239150297-20
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/oradata/orcl/b
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u02/oradata/orcl/ctl/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/orcl/control02.ctl
output file name=/u03/app/oracle/oradata/orcl/ctl/control03.ctl
Finished restore at 27-APR-10
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN>

Now that the control files have been restored and mounted, all of the RMAN configuration parameters have been set. You
should verify the paths to make sure they are appropriate for this host.

Generated with www.html-to-pdf.net

1
2
3
4
5
6
7
8
9
10

RMAN> show all;


RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
Page 3 / 10
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u03/app/oracle/oradata/
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

RMAN configuration parameters for database with db_unique_name ORCL are:


CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u03/app/oracle/oradata/
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT
'/u03/app/oracle/oradata/orcl/backup/%U' MAXP
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ;
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO 'SBT_TAPE';
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapc
RMAN>

Given the current settings RMAN is going to look in /u03/app/oracle/oradata/orcl/backup for both the control file
autobackups and database/archive log backups. The backup we copied over is located in
/u01/app/oracle/oradata/orcl/backup. There are two ways to resolve this issue. Either move the backup to the
location were RMAN is configured or change the configuration. It may be that moving the backups may not be an option so
we document what needs to be done next.
RMAN has record of a backup in /u03/app/oracle/oradata/orcl/backup but has no record of the backup we have in
/u01/app/oracle/oradata/orcl/backup/. We need remove the record of the old location and the backup of the new
location.
In order to let RMAN know about the backup in /u01/app/oracle/oradata/orcl/backup we use the CATALOG
command.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

RMAN> catalog start with '/u01/app/oracle/oradata/orcl/backup';


Starting implicit crosscheck backup at 27-APR-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=20 device type=DISK
Crosschecked 32 objects
Finished implicit crosscheck backup at 27-APR-10
Starting implicit crosscheck copy at 27-APR-10
using channel ORA_DISK_1
using channel ORA_DISK_2
Finished implicit crosscheck copy at 27-APR-10
searching for all files in the recovery area
cataloging files...
no files cataloged
searching for all files that match the pattern /u01/app/oracle/oradata/orcl/backup
List of Files Unknown to the Database
=====================================
File Name: /u01/app/oracle/oradata/orcl/backup/20lc5nqr_1_1
File Name: /u01/app/oracle/oradata/orcl/backup/23lc5ns4_1_1
File Name: /u01/app/oracle/oradata/orcl/backup/c-1239150297-20100427-00
File Name: /u01/app/oracle/oradata/orcl/backup/c-1239150297-20100426-00
File Name: /u01/app/oracle/oradata/orcl/backup/21lc5nqv_1_1
File Name: /u01/app/oracle/oradata/orcl/backup/1vlc5nqn_1_1
File Name: /u01/app/oracle/oradata/orcl/backup/24lc5o0c_1_1
File Name: /u01/app/oracle/oradata/orcl/backup/22lc5nqv_1_1
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/app/oracle/oradata/orcl/backup/20lc5nqr_1_1
File Name: /u01/app/oracle/oradata/orcl/backup/23lc5ns4_1_1
File Name: /u01/app/oracle/oradata/orcl/backup/c-1239150297-20100427-00
File Name: /u01/app/oracle/oradata/orcl/backup/c-1239150297-20100426-00
File Name: /u01/app/oracle/oradata/orcl/backup/21lc5nqv_1_1
File Name: /u01/app/oracle/oradata/orcl/backup/1vlc5nqn_1_1
File Name: /u01/app/oracle/oradata/orcl/backup/24lc5o0c_1_1
File Name: /u01/app/oracle/oradata/orcl/backup/22lc5nqv_1_1
RMAN>

As a result of the CATALOG command RMAN performed a CROSSCHECK. The backup registered at
/u03/app/oracle/oradata/orcl/backup/ was marked expired as a result of the CROSSCHECK because they were not
present.
We are almost ready to restore the database the last thing to be done is to build the restore script. During the restore we
can change the location of the data files by using SET NEWNAME FOR DATAFILE. The data files in the backup are on
various locations but we would like to restore them to only one.
Also we would like to change the location of the redo logs as well. In order to change the redo log locations the ALTER
DATABASE RENAME FILE command has to be issued. Below are examples of both.

Generated with www.html-to-pdf.net

1
2
3
4
5
6
7
8
9
10

SET
SET
SET
SET
SET
SET
SET

NEWNAME
NEWNAME
NEWNAME
NEWNAME
NEWNAME
NEWNAME
NEWNAME

FOR
FOR
FOR
FOR
FOR
FOR
FOR

DATAFILE
DATAFILE
DATAFILE
DATAFILE
DATAFILE
DATAFILE
DATAFILE

1
2
3
4
5
6
7

TO
TO
TO
TO
TO
TO
TO

'/u01/app/oracle/oradata/orcl/system01.dbf';
'/u01/app/oracle/oradata/orcl/sysaux01.dbf';
'/u01/app/oracle/oradata/orcl/undotbs01.dbf';
'/u01/app/oracle/oradata/orcl/users01.dbf';
'/u01/app/oracle/oradata/orcl/example01.dbf';
'/u01/app/oracle/oradata/orcl/test.dbf';
'/u01/app/oracle/oradata/orcl/dbfs01.dbf';

SQL "ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo01.log''


TO ''/u01/app/oracle/oradata/orcl/redo/redo01.log'' ";

Page 4 / 10

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

SET
SET
SET
SET

NEWNAME
NEWNAME
NEWNAME
NEWNAME

FOR
FOR
FOR
FOR

DATAFILE
DATAFILE
DATAFILE
DATAFILE

4
5
6
7

TO
TO
TO
TO

'/u01/app/oracle/oradata/orcl/users01.dbf';
'/u01/app/oracle/oradata/orcl/example01.dbf';
'/u01/app/oracle/oradata/orcl/test.dbf';
'/u01/app/oracle/oradata/orcl/dbfs01.dbf';

SQL "ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo01.log''


TO ''/u01/app/oracle/oradata/orcl/redo/redo01.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/red01_b.log''
TO ''/u02/app/oracle/oradata/orcl/redo/red01_b.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo02.log''
TO ''/u01/app/oracle/oradata/orcl/redo/redo02.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo02_b.log''
TO ''/u02/app/oracle/oradata/orcl/redo/redo02_b.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo03.log''
TO ''/u01/app/oracle/oradata/orcl/redo/redo03.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo03_b.log''
TO ''/u02/app/oracle/oradata/orcl/redo/redo03_b.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo04.log''
TO ''/u01/app/oracle/oradata/orcl/redo/redo04.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo04_b.log''
TO ''/u02/app/oracle/oradata/orcl/redo/redo04_b.log'' ";

If you remember we stated that we wanted the restore to stop at SCN 1375117 because that was the latest SCN in which
we have archive logs. In order to stop at a specific SCN we will use the SET UNTIL SCN 1375117.
After all of that we just need to restore the database, switch the data files so the control files have the new path and recover
the database. Not much at all.
Below is the entire script to do just that.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

RUN {
SET
SET
SET
SET
SET
SET
SET

NEWNAME
NEWNAME
NEWNAME
NEWNAME
NEWNAME
NEWNAME
NEWNAME

FOR
FOR
FOR
FOR
FOR
FOR
FOR

DATAFILE
DATAFILE
DATAFILE
DATAFILE
DATAFILE
DATAFILE
DATAFILE

1
2
3
4
5
6
7

TO
TO
TO
TO
TO
TO
TO

'/u01/app/oracle/oradata/orcl/system01.dbf';
'/u01/app/oracle/oradata/orcl/sysaux01.dbf';
'/u01/app/oracle/oradata/orcl/undotbs01.dbf';
'/u01/app/oracle/oradata/orcl/users01.dbf';
'/u01/app/oracle/oradata/orcl/example01.dbf';
'/u01/app/oracle/oradata/orcl/test.dbf';
'/u01/app/oracle/oradata/orcl/dbfs01.dbf';

SQL "ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo01.log''


TO ''/u01/app/oracle/oradata/orcl/redo/redo01.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/red01_b.log''
TO ''/u02/app/oracle/oradata/orcl/redo/red01_b.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo02.log''
TO ''/u01/app/oracle/oradata/orcl/redo/redo02.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo02_b.log''
TO ''/u02/app/oracle/oradata/orcl/redo/redo02_b.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo03.log''
TO ''/u01/app/oracle/oradata/orcl/redo/redo03.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo03_b.log''
TO ''/u02/app/oracle/oradata/orcl/redo/redo03_b.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo04.log''
TO ''/u01/app/oracle/oradata/orcl/redo/redo04.log'' ";
SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo04_b.log''
TO ''/u02/app/oracle/oradata/orcl/redo/redo04_b.log'' ";
SET UNTIL SCN 1375117;
RESTORE DATABASE;
SWITCH DATAFILE ALL;
RECOVER DATABASE;
}

The script above was saved to the file restore.rman. Below is the output.

Generated with www.html-to-pdf.net

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

RMAN> @restore.rman
RMAN> RUN {
2>
SET NEWNAME FOR DATAFILE 1 TO '/u01/app/oracle/oradata/orcl/system01.dbf';
3>
SET NEWNAME FOR DATAFILE 2 TO '/u01/app/oracle/oradata/orcl/sysaux01.dbf';
4>
SET NEWNAME FOR DATAFILE 3 TO '/u01/app/oracle/oradata/orcl/undotbs01.dbf';
5>
SET NEWNAME FOR DATAFILE 4 TO '/u01/app/oracle/oradata/orcl/users01.dbf';
6>
SET NEWNAME FOR DATAFILE 5 TO '/u01/app/oracle/oradata/orcl/example01.dbf';
7>
SET NEWNAME FOR DATAFILE 6 TO '/u01/app/oracle/oradata/orcl/test.dbf';
8>
SET NEWNAME FOR DATAFILE 7 TO '/u01/app/oracle/oradata/orcl/dbfs01.dbf';
9>
10>
11>
SQL "ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo01.log''
12>
TO ''/u01/app/oracle/oradata/orcl/redo/redo01.log'' ";
13>
SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/red01_b.log''
14>
TO ''/u02/app/oracle/oradata/orcl/redo/red01_b.log'' ";
15>
SQL "ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo02.log''
16>
TO ''/u01/app/oracle/oradata/orcl/redo/redo02.log'' ";
17>
SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo02_b.log''
18>
TO ''/u02/app/oracle/oradata/orcl/redo/redo02_b.log'' ";
19>
SQL "ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo03.log''
20>
TO ''/u01/app/oracle/oradata/orcl/redo/redo03.log'' ";
21>
SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo03_b.log''
22>
TO ''/u02/app/oracle/oradata/orcl/redo/redo03_b.log'' ";
23>
SQL "ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo04.log''
24>
TO ''/u01/app/oracle/oradata/orcl/redo/redo04.log'' ";
25>
SQL "ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo04_b.log''
26>
TO ''/u02/app/oracle/oradata/orcl/redo/redo04_b.log'' ";
27>
28>
SET UNTIL SCN 1375117;
29>
30>
RESTORE DATABASE;
31>
SWITCH DATAFILE ALL;
32>
33>
RECOVER DATABASE;
34> }
executing command: SET NEWNAME
Page 5 / 10
executing command: SET NEWNAME

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138

32>
33>
RECOVER DATABASE;
34> }
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
using target database control file instead of recovery catalog
sql statement: ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo01.log
sql statement: ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/red01_b.lo
sql statement: ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo02.log
sql statement: ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo02_b.l
sql statement: ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo03.log
sql statement: ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo03_b.l
sql statement: ALTER DATABASE RENAME FILE ''/u02/app/oracle/oradata/orcl/redo/redo04.log
sql statement: ALTER DATABASE RENAME FILE ''/u03/app/oracle/oradata/orcl/redo/redo04_b.l
executing command: SET until clause
Starting restore at 27-APR-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=1 device type=DISK
channel ORA_DISK_1:
channel ORA_DISK_1:
channel ORA_DISK_1:
channel ORA_DISK_1:
channel ORA_DISK_1:
channel ORA_DISK_1:
channel ORA_DISK_2:
channel ORA_DISK_2:
channel ORA_DISK_2:
channel ORA_DISK_2:
channel ORA_DISK_2:
channel ORA_DISK_2:
channel ORA_DISK_2:
channel ORA_DISK_2:
channel ORA_DISK_2:
channel ORA_DISK_2:
channel ORA_DISK_2:
channel ORA_DISK_2:
channel ORA_DISK_2:
channel ORA_DISK_1:
channel ORA_DISK_1:
channel ORA_DISK_1:
channel ORA_DISK_2:
channel ORA_DISK_2:
channel ORA_DISK_2:
Finished restore at

starting datafile backup set restore


specifying datafile(s) to restore from backup set
restoring datafile 00003 to /u01/app/oracle/oradata/orcl/undotbs01.d
restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.d
restoring datafile 00006 to /u01/app/oracle/oradata/orcl/test.dbf
reading from backup piece /u01/app/oracle/oradata/orcl/backup/22lc5n
starting datafile backup set restore
specifying datafile(s) to restore from backup set
restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf
reading from backup piece /u01/app/oracle/oradata/orcl/backup/23lc5n
piece handle=/u01/app/oracle/oradata/orcl/backup/23lc5ns4_1_1 tag=TA
restored backup piece 1
restore complete, elapsed time: 00:00:07
starting datafile backup set restore
specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system01.db
restoring datafile 00002 to /u01/app/oracle/oradata/orcl/sysaux01.db
restoring datafile 00007 to /u01/app/oracle/oradata/orcl/dbfs01.dbf
reading from backup piece /u01/app/oracle/oradata/orcl/backup/21lc5n
piece handle=/u01/app/oracle/oradata/orcl/backup/22lc5nqv_1_1 tag=TA
restored backup piece 1
restore complete, elapsed time: 00:00:23
piece handle=/u01/app/oracle/oradata/orcl/backup/21lc5nqv_1_1 tag=TA
restored backup piece 1
restore complete, elapsed time: 00:00:56
27-APR-10

datafile 1 switched
input datafile copy
datafile 2 switched
input datafile copy
datafile 3 switched
input datafile copy
datafile 4 switched
input datafile copy
datafile 5 switched
input datafile copy
datafile 6 switched
input datafile copy
datafile 7 switched
input datafile copy

to datafile copy
RECID=9 STAMP=717436375 file name=/u01/app/oracle/oradata/orcl/syste
to datafile copy
RECID=10 STAMP=717436375 file name=/u01/app/oracle/oradata/orcl/sysa
to datafile copy
RECID=11 STAMP=717436375 file name=/u01/app/oracle/oradata/orcl/undo
to datafile copy
RECID=12 STAMP=717436375 file name=/u01/app/oracle/oradata/orcl/user
to datafile copy
RECID=13 STAMP=717436375 file name=/u01/app/oracle/oradata/orcl/exam
to datafile copy
RECID=14 STAMP=717436375 file name=/u01/app/oracle/oradata/orcl/test
to datafile copy
RECID=15 STAMP=717436375 file name=/u01/app/oracle/oradata/orcl/dbfs

Starting recover at 27-APR-10


using channel ORA_DISK_1
using channel ORA_DISK_2
starting media recovery
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=2
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/oradata/orcl/backup/24lc5o
channel ORA_DISK_1: piece handle=/u01/app/oracle/oradata/orcl/backup/24lc5o0c_1_1 tag=TA
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u02/oradata/orcl/arch/1_2_717335393.dbf thread=1 sequence=2
media recovery complete, elapsed time: 00:00:01
Finished recover at 27-APR-10
RMAN>
RMAN> **end-of-file**
RMAN>

All that is left is to open the database with the RESETLOGS option.

Generated with www.html-to-pdf.net

1
2
3

RMAN> alter database open resetlogs;


database opened

Page 6 / 10

All that is left is to open the database with the RESETLOGS option.
1
2
3
4
5

RMAN> alter database open resetlogs;


database opened
RMAN>

Share this:

Facebook

Twitter

Reddit

Tumblr

Print

Email

Comments
eshant (November 25, 2010 11:09 pm)
* how
* to
* restore
* complete
* database
* on
* another
* system
* (in
* oracle)

Morad (December 20, 2012 7:35 am)


Excellentdocumentation
Many Many Thanks

sunil (February 4, 2013 5:14 am)


Can we use multiple channels to do the RESTORE ? We have 4tb db and around 800gb of RMAN backup size. We
need 5 channels to be configured.

fazlarabbi (March 12, 2013 8:23 am)


its a good documents
but do u have any idea that when i use (/data/app/oracle/rman_backup/ its my BK dirictory
RMAN>catalogstartwith/data/app/oracle/rman_backup/'
Starting implicit crosscheck backup at 12-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 device type=DISK
ORA-03113: end-of-file on communication channel
ORA-01403: no data found
ORA-01403: no data found
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of catalog command at 03/12/2013 19:01:48
ORA-03113: end-of-file on communication channel
ORA-01403: no data found
ORA-01403: no data found
****
i copy this files from rac database using backup database plus archivelog delete input and then backup backupset
1,2,3,4format/data/app/oracle/rman_backup/%U'
and i also try backup as copy command but this message is appear

MTDBA (July 17, 2013 5:34 pm)


BestcomprehensivedisasterrecoveryinstructionsIveeverfound.Thanksforsavingmybacon.Systemsadmins
thanks you too

enrique ortiz (January 9, 2014 7:24 am)


nice post
i think i sone of the mos comprensive documentation in order to recover a database in another host
tanks

Generated with www.html-to-pdf.net

Elayaraja (April 1, 2014 3:23 pm)


Hi,
please give doc for rman restore script from local server database to production standby database.

Page 7 / 10

Elayaraja (April 1, 2014 3:23 pm)


Hi,
please give doc for rman restore script from local server database to production standby database.
Thanks
Elayaraja

Elayaraja (April 1, 2014 3:25 pm)


Hi,
please give me doc rman restore script from test to production standby database.
Thanks
Elayaraja

Benny (May 8, 2014 6:59 am)


good doccumentation

Rooster (July 4, 2014 1:23 am)


This is an excellent doc.
What about when I have to restore/duplicate to a different SID. At what point and how to change the name from PROD
to DEV2?
Rooster

arab (November 17, 2014 3:51 am)


Thisthegreatestdocumentationiveeverseen.
Thank you very much!

Dale Brooks (January 2, 2015 12:05 pm)


Superb documentation of a complex matter! Thank you very much!

Amar (February 4, 2015 4:40 am)


Nice post!!

Ganesh@ (February 17, 2015 2:08 am)


Very Nice Arcticle !!!
Many Many Thanks

Mridul Gupta (April 27, 2015 12:23 am)


Thanks for this wonderful document which is really helpful.

Post A Comment
Name (required)

Email (will not be published) (required)

Page 8 / 10

Generated with www.html-to-pdf.net


Submit Comment

Submit Comment

Notify me of follow-up comments by email.


Notify me of new posts by email.

Generated with www.html-to-pdf.net

Page 9 / 10

Generated with www.html-to-pdf.net

Page 10 / 10

S-ar putea să vă placă și