环境:
OS:Red Hat Linux As 5
DB:10.2.0.4
有些时候因为测试环境需要,我们需要使用生产库的备份集在另外一台新的机器上做恢复(前提是新机器事先安装Oracle软件,版本跟原库一致),下面是恢复过程.
1.在原库上做全备(在原库上操作)
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
backup format '/u02/rman_backup/full_backup/full_backup_%T_%s' database;
sql 'alter system archive log current';
backup format '/u02/rman_backup/full_backup/arc_backup_%T_%s' archivelog all;
release channel c1;
release channel c2;
}
2.查看原库的DBID(在原库上操作)
因为在做恢复的过程中需要设定DBID,这里需要找到原库的DBID
SQL> select dbid from v$database;
DBID
----------
1820932955
-----以下的操作没有特殊说明,全部在目的库上操作-----
3.使用ftp将原库上的备份集拷贝到目的库的目录/u02/ftp/(具体操作省略)
4.在新机器上创建如下目录
mkdir /u02/mydb
mkdir -p /u02/mydb/oracl/{adump,bdump,cdump,dpdump,udump,pfile}
mkdir -p /u02/mydb/oradata/oracl
mkdir -p /u02/mydb/flash_recovery_area
5.创建密码文件
orapwd file=/u01/app/oracle/product/10.2.0/db_1/dbs/orapworacl.ora password=oracle
6.恢复参数文件
[oracle@hxlbak ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jun 29 06:51:54 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
RMAN>set dbid 1820932955 -- 这里的dbid需要跟原库保持一致
RMAN> startup nomount
本文URL地址:http://www.bianceng.cn/database/Oracle/201410/45468.htm
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initoracl.ora'
starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
Total System Global Area 159383552 bytes
Fixed Size 1218268 bytes
Variable Size 54528292 bytes
Database Buffers 100663296 bytes
Redo Buffers 2973696 bytes
RMAN> restore spfile to pfile '/u01/app/oracle/product/10.2.0/db_1/dbs/initoracl.ora' from '/u02/ftp/full_backup_20120628_37';
Starting restore at 29-JUN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK
channel ORA_DISK_1: autobackup found: /u02/ftp/full_backup_20120628_37
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 29-JUN-12
备份集full_backup_20120628_3里7包含了参数文件,我们在备份数据的时候会默认备份参数文件,可以在原库使用list backup查看,list backup输出部分内容如下:
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
35 Full 80.00K DISK 00:00:01 28-JUN-12
BP Key: 35 Status: AVAILABLE Compressed: NO Tag: TAG20120628T184555
Piece Name: /u02/rman_backup/full_backup/full_backup_20120628_37