1.建立一个目录,把从另外SERVER上RMAN的备份文件拷入这个目录;
(本例/home/oracle/orclbk/b)
2.在$ORACLE_HOME/admin/$ORACLE_SID里建立adump/bdump/cdump/udump目录
3.export ORACLE_SID=orcl;(我们假定SID是ORCL)
4.在$ORACLE_HOME/dbs目录中复制一下临时的PFILE,仅仅用来启动系统,以后我们会用备份里的SPFILE覆盖它:
cp init.ora initorcl.ora
5.用编辑器把initorcl.ora的db_name改为$ORACLE_SID,这里我们改为ORCL;shared_pool_size改为62198988,模板里的数值太小了。保存一下,然后启动系统到nomount;
6.用编辑好的pfile启动到NOMOUNT:
oracle@apekr61i:~/orclbk$sqlplus /nolog
SQL>conn / as sysdba;
SQL>startup nomount pfile='/opt/ora10/dbs/initorcl.ora';
Total System Global Area 100663296 bytes7.登录RMAN,恢复controlfiles:
Fixed Size 1217884 bytes
Variable Size 88083108 bytes
Database Buffers 8388608 bytes
Redo Buffers 2973696 bytes
$rman target /
RMAN>restore controlfile from '/home/oracle/orclbkbackctl_c-1192426545-20080910-02/';
Starting restore at 14-SEP-088.恢复SPFILE。
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=46 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
output filename=/opt/ora10/dbs/ora_control1
output filename=/opt/ora10/dbs/ora_control2
Finished restore at 14-SEP-08
RMAN> restore spfile from '/home/oracle/orclbk/backctl_c-1192426545-20080910-02';
Starting restore at 14-SEP-08
using channel ORA_DISK_1
channel ORA_DISK_1: autobackup found: /home/oracle/orclbk/backctl_c-1192426545-20080910-02
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 14-SEP-08
9.切换到SQLPLUS,把SPFILE保存到PFILE,便于以后再编辑:
SQL>create pfile ='/home/oracle/orclbk/pfileorcl.ora' from spfile;
10.查看,并编辑一下备份出来的PFILE,看看control文件是否指向新恢复出来的CONTROL FILE,然后用新的PFILE重启一下数据库。
SQL>shutdown immediate;
SQL>startup nompunt pfile='/home/oracle/orckbk/pfileorcl.ora';
SQL>alter database mount;
11.进入RMAN,让ORACLE搜索指定目录的备份文件:(CATALOG START WITH命令)
RMAN>catalog start with '/home/oracle/orclbk/b';
这时候输入YES。
Starting implicit crosscheck backup at 14-SEP-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
Crosschecked 5 objects
Finished implicit crosscheck backup at 14-SEP-08
Starting implicit crosscheck copy at 14-SEP-08
using channel ORA_DISK_1
Finished implicit crosscheck copy at 14-SEP-08
searching for all files in the recovery area
cataloging files...
no files cataloged
searching for all files that match the pattern /home/oracle/orclbk/b
List of Files Unknown to the Database
=====================================
File Name: /home/oracle/orclbk/b/bk_0bjq8ub1_1_1.dbf
File Name: /home/oracle/orclbk/b/backctl_c-1192426545-20080910-02
Do you really want to catalog the above files (enter YES or NO)?
系统显示:
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /home/oracle/orclbk/b/bk_0bjq8ub1_1_1.dbf
File Name: /home/oracle/orclbk/b/backctl_c-1192426545-20080910-02
12.键入report schema命令,查看一下备份中的文件:
RMAN>report schema;
RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 0 SYSTEM *** /opt/ora10/oradata/orcl/system01.dbf
2 0 UNDOTBS1 *** /opt/ora10/oradata/orcl/undotbs01.dbf
3 0 SYSAUX *** /opt/ora10/oradata/orcl/sysaux01.dbf
4 0 USERS *** /opt/ora10/oradata/orcl/users01.dbf
5 0 EXAMPLE *** /opt/ora10/oradata/orcl/example01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 0 TEMP 32767 /opt/ora10/oradata/orcl/temp01.dbf
13.这时,我们可以根据上面的报告,编写脚本,把数据恢复到新的目录中,比如这次我们要把数据文件放到/opt/ora10/oradata/orclbk目录中。
RMAN> run{
2> set newname for datafile 1 to '/opt/ora10/oradata/orclbk/system01.dbf';
3> set newname for datafile 2 to '/opt/ora10/oradata/orclbk/undotbs01.dbf';
4> set newname for datafile 3 to '/opt/ora10/oradata/orclbk/sysaux01.dbf';
5> set newname for datafile 4 to '/opt/ora10/oradata/orclbk/users01.dbf';
6> set newname for datafile 5 to '/opt/ora10/oradata/orclbk/example01.dbf'
7> ;
8> restore database;
9> switch datafile all;
10> }
系统显示:
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 14-SEP-08
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /opt/ora10/oradata/orclbk/system01.dbf
restoring datafile 00002 to /opt/ora10/oradata/orclbk/undotbs01.dbf
restoring datafile 00003 to /opt/ora10/oradata/orclbk/sysaux01.dbf
restoring datafile 00004 to /opt/ora10/oradata/orclbk/users01.dbf
restoring datafile 00005 to /opt/ora10/oradata/orclbk/example01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/orclbk/b/bk_0bjq8ub1_1_1.dbf
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/orclbk/b/bk_0bjq8ub1_1_1.dbf tag=FOURTH ALL
channel ORA_DISK_1: restore complete, elapsed time: 00:00:46
Finished restore at 14-SEP-08
datafile 1 switched to datafile copy
input datafile copy recid=37 stamp=665416880 filename=/opt/ora10/oradata/orclbk/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=38 stamp=665416880 filename=/opt/ora10/oradata/orclbk/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=39 stamp=665416880 filename=/opt/ora10/oradata/orclbk/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=40 stamp=665416880 filename=/opt/ora10/oradata/orclbk/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=41 stamp=665416880 filename=/opt/ora10/oradata/orclbk/example01.dbf
14.嘿嘿,差不多大功告成了,做一下recover:
RMAN>recover database;
15.然后,以resetlogs方式,打开数据库:
RMAN>alter database open resetlogs;
database opened
16.完成了,然后可能要用pfile 变成SPFILE:
create spfile from pfile='/home/oracle/orclbk/spfileorcl.ora';
然后重启一下系统,被恢复的数据库就完全可用了。

No comments:
Post a Comment