Oracle rman中rman restore from和recover的区别

今天看啥 热点:
linux下只有rman备份集的异机不同目录恢复,linuxrman备份目录
昨天在客户那里做了一次rman异机的恢复,把生产库弄一份给测试库用,总库大概80G,总共花费了2个小时,当时客户的环境是windows 11.2.0.3,今天早晨在linux下重新测试了一下,记录下来供大家参考
所有操作都是按主机名区分
主机名 &bre1 &实例名为bre1 &数据文件目录在/u01/app/oradata下
主机名 bre2 & 数据文件准备放在/bre1/oradata下
废话不多说,下面是实际操作步骤
1.在源库创建备份集,并且拷贝到目标库
拷贝的目录可用和原来的备份的时候的目录一致,也可以不一致
备份system表空间rman会自动备份参数文件和控制文件
RMAN& backup database format '/home/oracle/%U.bak';
Starting backup at 21-AUG-:35
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/bre1/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/bre1/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/bre1/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/bre1/test.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/bre1/users01.dbf
channel ORA_DISK_1: starting piece 1 at 21-AUG-:36
channel ORA_DISK_1: finished piece 1 at 21-AUG-:51
piece handle=/home/oracle/03pggb7o_1_1.bak tag=TAG336 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 21-AUG-:52
channel ORA_DISK_1: finished piece 1 at 21-AUG-:53
piece handle=/home/oracle/04pggb87_1_1.bak tag=TAG336 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 21-AUG-:53
[oracle@bre2 ~]$ 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.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bre1,192.168.56.45' (RSA) to the list of known hosts.
oracle@bre1's password:
03pggb7o_1_1.bak
[oracle@bre2 ~]$ scp bre1:/home/oracle/04pggb87_1_1.bak .
oracle@bre1's password:
04pggb87_1_1.bak
100% 9600KB
2.还原spfile,使用nomount打开数据库
编辑一个最简单的pfile,只有db_name即可:
[oracle@bre2 dbs]$ vi initbre1.ora
[oracle@bre2 dbs]$ cat initbre1.ora
db_name=bre1
然后就可以nomount打开数据库了:
ORACLE instance started.
Total System Global Area
Fixed Size
2251936 bytes
Variable Size
Database Buffers
Redo Buffers
5132288 bytes
再使用rman来恢复spfile:
RMAN& restore spfile from '/home/oracle/backup/04pggb87_1_1.bak';
Starting restore at 21-AUG-:31
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=171 device type=DISK
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /home/oracle/backup/04pggb87_1_1.bak
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 21-AUG-:32
使用spfile来打理数据库试试
[oracle@bre2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Aug 21 10:08:01 2014
Copyright (c) , Oracle.
All rights reserved.
Connected to an idle instance.
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db_1/dbs/initbre1.ora'
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db_1/dbs/initbre1.ora'
ORA-09925: Unable to create audit trail file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 9925有很多相关目录没有创建,可以使用strings spfilebre1.ora来查看一下spfile里面的内容,建好相关的目录,并且赋予权限。。这些都搞好后nomount打开数据库不再报错。
3.恢复控制文件
登陆到rman,控制文件还原的时候将还原到参数文件指定的位置,所以参数文件指定的控制文件目录必须存在,否则报错,例如下面一开始我没有创建就报错,后来创建完成就不报错了,如果你想还原到其他地方,可以修改参数文件指定到相应地址。
RMAN& restore controlfile from '/home/oracle/04pggb87_1_1.bak';
Starting restore at 21-AUG-:14
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 08/21/:15
ORA-19870: error while restoring backup piece /home/oracle/04pggb87_1_1.bak
ORA-19504: failed to create file &/u01/app/oracle/oradata/bre1/control01.ctl&
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 1
RMAN& restore controlfile from '/home/oracle/04pggb87_1_1.bak';
Starting restore at 21-AUG-:50
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 08/21/:51
ORA-19504: failed to create file &/u01/app/oracle/fast_recovery_area/bre1/control02.ctl&
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 1
ORA-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-:24
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/bre1/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/bre1/control02.ctl
Finished restore at 21-AUG-:25
4.mount数据库,注册备份集
重启数据库,直接就可以启动到mount
ORACLE instance started.
Total System Global Area
Fixed Size
2257840 bytes
Variable Size
Database Buffers
Redo Buffers
6565888 bytes
Database mounted.
如果此时备份集所在文件目录改变,需要手工catalog注册备份集,这里我们将拷过来的备份文件复制到/home/oracle/backup下,演示一下手工catalog备份集
[oracle@bre2 ~]$ ls
03pggb7o_1_1.bak
04pggb87_1_1.bak
[oracle@bre2 ~]$ mkdir backup
[oracle@bre2 ~]$ mv *.bak backup
[oracle@bre2 ~]$ ls backup
03pggb7o_1_1.bak
04pggb87_1_1.bak
RMAN& catalog backuppiece '/home/oracle/backup/03pggb7o_1_1.bak';
Starting implicit crosscheck backup at 21-AUG-:10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 device type=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 21-AUG-:10
Starting implicit crosscheck copy at 21-AUG-:10
using channel ORA_DISK_1
Finished implicit crosscheck copy at 21-AUG-:11
searching for all files in the recovery area
cataloging files...
no files cataloged
cataloged backup piece
backup piece handle=/home/oracle/backup/03pggb7o_1_1.bak RECID=2 STAMP=
catalog backuppiece '/home/oracle/backup/04pggb87_1_1.bak';
cataloged backup piece
backup piece handle=/home/oracle/backup/04pggb87_1_1.bak RECID=3 STAMP=
5.使用set newname将数据文件还原到不同目录
原来的数据文件目录在/u01/admin/oradata下面,我们将数据文件恢复到/bre1/oradata下面,%b的意思是只获取文件名,没有目录信息
[root@bre2 ~]# mkdir -p /bre1/oradata
[root@bre2 ~]# chown -R oracle:oinstall /bre1
[oracle@bre2 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Aug 21 10:36:10 2014
Copyright (c) , Oracle and/or its affiliates.
All rights reserved.
connected to target database: BRE1 (DBID=, not open)
allocate channel ch1
set newname for database to '/bre1/oradata/%b';
release channel ch1;
using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: SID=396 device type=DISK
executing command: SET NEWNAME
Starting restore at 21-AUG-:03
channel ch1: starting datafile backup set restore
channel ch1: specifying datafile(s) to restore from backup set
channel ch1: restoring datafile 00001 to /bre1/oradata/system01.dbf
channel ch1: restoring datafile 00002 to /bre1/oradata/sysaux01.dbf
channel ch1: restoring datafile 00003 to /bre1/oradata/undotbs01.dbf
channel ch1: restoring datafile 00004 to /bre1/oradata/users01.dbf
channel ch1: restoring datafile 00005 to /bre1/oradata/test.dbf
channel ch1: reading from backup piece /home/oracle/backup/03pggb7o_1_1.bak
channel ch1: piece handle=/home/oracle/backup/03pggb7o_1_1.bak tag=TAG336
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:00:45
Finished restore at 21-AUG-:48
released channel: ch1
数据文件都在了:
[root@bre2 ~]# ls -l /bre1/oradata
total 1564468
-rw-r----- 1 oracle oinstall
Aug 21 10:38 sysaux01.dbf
-rw-r----- 1 oracle oinstall
Aug 21 10:38 system01.dbf
-rw-r----- 1 oracle oinstall
Aug 21 10:38 test.dbf
-rw-r----- 1 oracle oinstall
Aug 21 10:38 undotbs01.dbf
-rw-r----- 1 oracle oinstall
6561792 Aug 21 10:38 users01.dbf
资料上说可以使用switch datafile all来直接修改控制文件中的文件目录,但是我试了一下貌似不行,还是需要在手工rename,下面是我手工修改控制文件中的数据文件目录,先看一下当前的数据文件目录
SQL& select name from v$
--------------------------------------------------------------------------------
/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.dbf
SQL& select name from v$
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/bre1/temp01.dbf
SQL& select member from v$
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/bre1/redo01.log
/u01/app/oracle/oradata/bre1/redo02.log
/u01/app/oracle/oradata/bre1/redo03.log
我自己写了一个拼接sql来将数据文件目录做转换:
select 'alter database rename file '''||name||''' to ''/bre1/oradata'||substr(name,length(name)-INSTR(reverse(name),'/')+1,INSTR(reverse(name),'/'))||''';' from v$datafile
select 'alter database rename file '''||name||''' to ''/bre1/oradata'||substr(name,length(name)-INSTR(reverse(name),'/')+1,INSTR(reverse(name),'/'))||''';' from v$tempfile
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$datafile
select 'alter database rename file '''||name||''' to ''/bre1/oradata'||substr(name,length(name)-INSTR(reverse(name),'/')+1,INSTR(reverse(name),'/'))||''';' from v$tempfile
select 'alter database rename file '''||member||''' to ''/bre1/oradata'||substr(member,length(member)-INSTR(reverse(member),'/')+1,INSTR(reverse(member),'/'))||''';' from v$logfile
'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';
Database altered.
Database altered.
Database altered.
Database altered.
Database altered.
Database altered.
Database altered.
SQL& alter database rename file '/u01/app/oracle/oradata/bre1/redo03.log' to '/bre1/oradata/redo03.log';
Database altered.rename之后控制文件中的数据文件目录都已经改到了/bre1/oradata下,那么就可以进行恢复了。
6.恢复数据库
我这里是测试就没有恢复什么归档日志,如果是正式生产库,还需要恢复归档日志,可能还需要使用到CATALOG ARCHIVELOG 来注册归档的备份集和在RMAN中使用
& SET ARCHIVELOG DESTINATION TO '/home/oracle';
& RESTORE ARCHIVELOG & & &&
来还原出归档日志。
或者还可以在controlfile中修改归档目录来恢复。恢复出归档日志之后,就可以进行数据库恢复。
[oracle@bre2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Aug 21 11:16:06 2014
Copyright (c) , Oracle.
All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL& recover database using backup cont
ORA-00279: change 830841 generated at 08/21/:36 needed for thread 1
ORA-00289: suggestion : /arch1_42_.dbf
ORA-00280: change 830841 for thread 1 is in sequence #42
Specify log: {&RET&=suggested | filename | AUTO | CANCEL}
Media recovery cancelled.
SQL& alter dat
Database altered.open 过程中可能会遇到ora-00392错误,
解决办法:
使用SQL& alter database clear logfile group 2;
到此恢复成功!
主要的难点是需要对rman比较熟悉,需要使用语句修改控制文件中的文件位置,否则会报错找不到相关文件。
如果备份集的目录改变了,需要手工catalog注册备份集到控制文件,并且rename file。
我很负责的告诉你,AIX下的rman备份不能恢复到linux下。
1) exp无法对备份集进行备份。2)都是指定的一个目录,没什么具体区别,默认的归档以及备份集都是放在快速恢复区的。
相关搜索:
相关阅读:
相关频道:
&&&&&&&&&&&&&&&&&&&&&&&&&&&&
数据库前沿最近更新Oracle rman中restore和recover的区别_百度知道
Oracle rman中restore和recover的区别
提问者采纳
Recovery Manager(RMAN)是一种用于备份(backup)、还原(restore)和恢复(recover) 数据库的 Oracle 工具。RMAN只能用于ORACLE8或更高的版本中。它能够备份整个数据 库或数据库部件,如表空间、数据文件、控制文件、归档文件以及Spfile参数文件。RMAN 也允许您进行增量数据块级别的备份,增量RMAN备份是时间和空间有效的,因为他们只备 哗範糕既蕹焕革唯宫沥份自上次备份以来有变化的那些数据块。而且,通过RMAN提供的接口,第三方的备份与恢 复软件如veritas将提供更强大的备份与恢复的管理功能。 通过RMAN,也提供了其它更多功能,如数据库的克隆、采用RMAN建立备用数据库、 利用RMAN备份与移动裸设备(RAW)上的文件等工作将变得更方便简单。9i的RMAN通过 增强的自动配置与管理功能,以及特有的块级别的恢复,将使备份与恢复工作变得更加快捷 与完美。9i的RMAN有如下特征特性: ·自动的备份与恢复 ·方便的备份归档日志 ·自动检测新的数据文件 ·支持增量备份 ·最大限度的减少备份与恢复的错误 ·减少恢复的时间 ·在热备份中不会产生额外的redo日志 ·腐烂数据块的自动检测 ·并行的备份与恢复操作 ·在线备份时,表空间不用置于备份模式 可以看到,在以上的一些特性中,显示了RMAN强大的功能与好处,以上功能的实现, 是因为RMAN是块级别的备份与恢复,备份与恢复发生在数据库块级别,可以通过比较数据 块而获得一致性的数据块,可以避免备份没有用过的块,可以检验块是否腐烂等块级别的问题。
其他类似问题
为您推荐:
rman的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁As a Linux sysadmin, you might recover a system from backup, which may include Oracle Database.
So, it is essential for all admins to understand how to restore oracle database from backup.
Typically, DBAs will use Oracle RMAN utility to take a hot backup of the database.
This tutorial provides an introduction on how to restore an Oracle database from the RMAN backup.
If you are new to RMAN, you should first understand how to
using RMAN.
For the impatient, here is a quick snippet of one particular rman restore scenario. Change this accordingly for your scenario. Read below to understand more details about these commands.
RMAN& SET DBID 12345;
RMAN& STARTUP NOMOUNT;
RMAN& RESTORE CONTROLFILE FROM "/backup/rman/ctl_c-03-03";
RMAN& RESTORE DATABASE;
RMAN& RECOVER DATABASE;
RMAN& ALTER DATABASE OPEN RESETLOGS;
Verify Backup Location
Before the restore, verify the current RMAN configuration on the server where you’ll be performing the restore.
To connect to RMAN, execute the following rman command, which will take you to the RMAN& prompt. From here, you can execute all RMAN commands.
$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Nov 17 11:17:11 2014
Copyright (c) , Oracle and/or its affiliates.
All rights reserved.
connected to target database: DEVDB (DBID=821773)
Execute “show all”, which will display all current RMAN configuration. As you see below, the current RMAN backup is located under “/backup/rman” directory.
RMNAN& SHOW ALL;
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/backup/rman/ctl_%F';
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 4;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT
'/data/rman-backup/full_%u_%s_%p' MAXPIECESIZE 4096 M;
CONFIGURE MAXSETSIZE TO UNLIMITED;
CONFIGURE ENCRYPTION FOR DATABASE OFF;
CONFIGURE ENCRYPTION ALGORITHM 'AES128';
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/backup/rman/snapcf_med.f';
On a high-level, the following three steps are performed in recovering the database from RMAN backup.
Restore controlfile from backup
Restore the databse
Recover the database
WARNING: Execute rman restore commands only on a test instance. If you try these restore commands in a production instance, and if something goes wrong, you’ll lose your production data.
Step 1: Restore ControlFile from Backup
First, you may want to restore the control file from the backup before you start the restore.
This step is required only if you are restoring the backup on a new server where the control file doesn’t exist. Or, if the control file on the system you are restoring is corrupted or missing.
RMAN& SET DBID 12345;
RMAN& STARTUP NOMOUNT;
RMAN& RESTORE CONTROLFILE FROM "/backup/rman/ctl_c-03-03";
RMAN& ALTER DATABASE MOUNT;
Before you start the RMAN restore process, do the following:
Set the DBID. You can get the dbid from the name of the control file. This is the number that comes after “ctrl_c-” and the next hyphen. Please note that this depends on the controlfile format that was set on your system. Do a show all to view the format. For this example, the format was: “ctl_%F”
Startup the database in nomount option
Restore the controlfile form the backup. In this example, the RMAN backup is located under /backup/rman directory. Under this directory, you may have multiple control files. Based on the tiemstamp pick the appropriate one for which you have the full backup.
After restoring the control file, mount the database.
The following is an example output of the restore controlfile command:
Starting restore at 22-NOV-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=124 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output filename=/u01/oradata/devdb/control01.ctl
output filename=/u02/oradata/devdb/control02.ctl
output filename=/u03/oradata/devdb/control03.ctl
Finished restore at 22-NOV-14
When the RMAN backup was taken, if a tag was specified, you can also restore controlfile based a tag name as shown below.
RMNAN& RESTORE CONTROLFILE FROM TAG 'WEEKLY_FULL_BKUP';
You can also use the autobackup option to restore the controlfile as shown below:
RMNAN& RESTORE CONTROLFILE FROM AUTOBACKUP;
Step 2: Restore the Database
To restore from the RMAN full backup that is located under the /backup/rman directory, execute the following command.
RMAN& RESTORE DATABASE;
Apart from the above straight forward restore database, there are also few variations of this command which are explained in the examples below. Use the one that is appropriate for your situation.
The following is a sample output of the above restore database command:
Starting restore at 22-NOV-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=125 devtype=DISK
channel ORA_DISK_2: starting datafile backupset restore
channel ORA_DISK_2: specifying datafile(s) to restore from backup set
restoring datafile 00020 to /u01/oradata/devdb/dev01_1.dbf
restoring datafile 00021 to /u02/oradata/devdb/report_data.dbf
restoring datafile 00022 to /u01/oradata/devdb/analytics01.dbf
channel ORA_DISK_2: reading from backup piece /backup/rman/full_32qakgmpa_
channel ORA_DISK_4: starting datafile backupset restore
Step 3: Recover Database (and ResetLogs)
If you’ve restored the controlfile from the backup, you need to perform this step.
In the last step, recover the database, and then you should open the database with resetlogs options as show below:
RMAN& RECOVER DATABASE;
RMAN& ALTER DATABASE OPEN RESETLOGS;
Restore Specific Tablespace
Instead of restoring the full database, you can also restore only specific tablespace as shown below.
The following will restore only the dev1 tablespace
RMNAN& RESTORE TABLESPACE dev1;
You can also restore more than one tablespace by separating them with commas as shown below. This will restore both dev1 and dev2 tablespace.
RMNAN& RESTORE TABLESPACE dev1, dev2;
Restore Specific Datafiles
You can also restore only a specific datafile from the backup using the restore datafile command as shown below.
The following will restore only the dev1_01.dbf datafile.
RMNAN& RESTORE DATAFILE '/u01/oradata/devdb/dev1_01.dbf'
You can also restore more than one datafile by separating them with commas as shown below. This will restore both dev1_01 and dev1_02 datafiles
RMNAN& RESTORE DATAFILE '/u01/oradata/devdb/dev1_01.dbf', '/u01/oradata/devdb/dev1_02.dbf'
Instead of the datafile name, you can also specify the datafile number.
RMNAN& RESTORE DATAFILE 34, 35
The datafile number (file_id) can be found in the dba_data_files table:
SQL& select file_id, file_name from dba_data_files
FILE_ID FILE_NAME
---------- -------------------------------
34 /u01/oradata/devdb/dev1_01.dbf
35 /u01/oradata/devdb/dev1_02.dbf
Restore the Archived Redo Logs
The following will restore the archive logs to the default location.
RMNAN& RESTORE ARCHIVELOG ALL;
If you want to restore the archive logs to a new directory, do the following:
RMNAN& SET ARCHIVELOG DESTINATION TO '/home/arc_logs_new/';
RMNAN& RESTORE ARCHIVELOG ALL;
The following will restore only specific sequence number of the archive logs that are between 153 and 175.
RMNAN& RESTORE ARCHIVELOG FROM SEQUENCE 153 UNTIL SEQUENCE 175;
You can also restore archivelogs by specifying the starting point of the SCN number as shown below.
RMNAN& RESTORE ARCHIVELOG FROM SCN 56789;
Please note that when you issue the recover database as mentioned in the step 3 above, it will look for all required archive logs from the archive log destination and applies them to the oracle database datafiles.
Recover Specific Tablespace or Datafile
Similar to restoring specific tablespace and datafile, depending on the restore operation you did, perform the corresponding recover option. The following are few examples:
RMAN& RECOVER TABLESPACE dev1;
RMAN& RECOVER TABLESPACE dev1, dev2;
RMAN& RECOVER DATAFILE '/u01/oradata/devdb/dev1_01.dbf'
RMAN& RECOVER DATAFILE 34, 35
Note: You can also append “DELETE ARCHIVELOG” option to the recover command, which will delete the restored archive logs from the disk which are not required anymore. For example:
RMNAN& RECOVER TABLESPACE dev1 DELETE ARCHIVELOG;
Preview the Restore
Before restoring the database, if you like to view the details of all the backupsets that will be used along with the SCNs that are part of the backup file, you can append “PREVIEW” to any of the restore databse command. Please note that the preview output will be similar to the rman list summary command output.
This really doesn’t do the restore. This will only provide the report. You can use this before you restore the database.
RMAN& RESTORE DATABASE PREVIEW;
Pelase note that if the output of the above PREVIEW command is too detailed, and you need only the summary, you can execute the following PREVIEW SUMMARY.
RMAN& RESTORE DATABASE PREVIEW SUMMARY;
The following is the sample output of the above preview summary:
TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
WEEKLY_FULL_BKUP
WEEKLY_FULL_BKUP
WEEKLY_FULL_BKUP
WEEKLY_FULL_BKUP
WEEKLY_FULL_BKUP
The following are also valid preview option. You can append SUMMARY to all of the following commands:
RESTORE TABLESPACE dev1 PREVIEW;
RESTORE DATAFILE '/u01/oradata/devdb/dev1_01.dbf' PREVIEW;
RESTORE ARCHIVELOG ALL PREVIEW;
RESTORE ARCHIVELOG FROM SCN 234546 PREVIEW;
Validate the Backup Before Restore (Dry-run)
Before you perform the restore, you might want to really validate the backup to make sure that the backup itself is not corrupted, and all the file required to perform the backup is actually present in the backup directory.
RMAN& RESTORE DATABASE VALIDATE;
Depending on the size of the database this operation might take some time to complete. Technically, this is same as restoring the database except that this doesn’t do the real restore, and it performs only the Dry-run. The validate operation will really read all the blocks in the RMAN backup to make sure they are valid.
The following is a sample output of the restore validate command:
Starting restore at 22-NOV-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=123 devtype=DISK
channel ORA_DISK_1: starting validation of datafile backupset
channel ORA_DISK_2: starting validation of datafile backupset
channel ORA_DISK_1: reading from backup piece /backup/rman/full_3abcde4po_
channel ORA_DISK_2: reading from backup piece /backup/rman/full_32qakgmpa_
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_2: validation complete, elapsed time: 00:53:11
Finished restore at 22-NOV-14
RMAN Restore Common Error Messages
The following are some of the most common RMAN restore error messages:
Error 1: Start-up mount might give the following RMAN-04014 error:
RMAN& STARTUP NOMOUNT
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 10/03/:19
RMAN-04014: startup failed: ORA-09925: Unable to create audit trail file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 9925
Solution 1: Create the audit trial directory. Change the path to match your system.
mkdir -p $ORACLE_BASE/admin/devdb/adump
Error 2: Restore controlfile might give the following RMAN-00558, RMAN-01006, or RMAN-02001 error.
RMAN& RESTORE CONTROLFILE FROM /backup/rman/ctl_c-03-03
RMAN-00558: error encountered while parsing input commands
RMAN-01006: error signaled during parse
RMAN-02001: unrecognized punctuation symbol "/"
Solution 2: Make sure to include the whole controlfile patch within quotes as shown below.
RMAN& RESTORE CONTROLFILE FROM "/backup/rman/ctl_c-03-03";
Error 3: Restore controlfile (or restore database) might give the following RMAN-03002, ORA-19870, or ORA-27040 error along with “Linux-x86_64 Error: 2: No such file or directory”.
RMAN& RESTORE CONTROLFILE FROM "/backup/rman/ctl_c-03-03";
RMAN-03002: failure of restore command at 10/03/:25
ORA-19870: error while restoring backup piece /backup/rman/ctl_c-03-03
ORA-19504: failed to create file "/u01/oradata/devdb/control01.ctl"
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
Solution 3: In most cases it is missing directory. Create the appropriate directories accordingly. You might also get not found messsage for flash_recovery_area directory. So, create them both. Or, create whatever directory the above error message is complaining about.
mkdir -p $ORACLE_BASE/oradata/devdb
mkdir -p $ORACLE_BASE/flash_recovery_area/devdb/
Error 4: When you alter database open resetlogs, you might get the following ORA-01152 error message:
RMAN& ALTER DATABASE OPEN RESETLOGS;
ERROR at line 1:
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u01/oradata/devdb/system01.dbf'
Solution 4: You can try couple of things. First, try to recover database until cancel as shown below. If that doesn’t help, remove the “UNTIL CANCEL” from the following command, and specify the redo log file, when it asks for “Specify log:” during the recover database command:
RMAN& RECOVER DATABASE UNTIL CANCEL USING BACKUP CONTROLFILE;
If you enjoyed this article, you might also like..
Next post:
Previous post:
& - Practical Examples to Build a Strong Foundation in Linux
- Take Control of Your Bash Command Line and Shell Scripting
- Enhance Your UNIX / Linux Life with Sed and Awk
- Practical Examples for Becoming Fast and Productive in Vim Editor
- Monitor Everything, Be Proactive, and Sleep Well
POPULAR POSTS
CATEGORIES
Copyright &
Ramesh Natarajan. All rights reserved}

我要回帖

更多关于 restore recover区别 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信