简介
在数据库人的圈子里,备份将是个永恒的话题。虽然对rman的原理知识并不陌生,但前不久为了给单位部署备份策略,还是消耗了我不少的脑细胞
。制定完备份策略后,我们当然可以在rman中验证备份集的有效性,但是万一需要异机恢复呢,不知道我们有多少人在为了应对这10000/1的可能性而努力准备着
。
--Rman 异机恢复实验
1、创建临时pfile
cd $ORACLE_HOME/dbs
cat init.ora | grep -v ^# | grep -v ^$ > initPROD.ora
[oracle@single01 dbs]$ cat inittx9ab.ora
db_name='TX9AB'
processes = 150
audit_trail ='db'
db_block_size=8192
db_domain=''
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
control_files =
(/space/oradata/tx9ab/controlfile/control01.ctl,/space/oradata/tx9ab/controlfile/control02.ctl,/space/oradata/tx9ab/controlfile/control03.ctl,)
compatible ='11.2.0'
sga_target=200m
sga_max_size=200m
--利用临时的pfile启动实例
SQL> startup nomount
ORACLE instance started.
Total System Global Area 208769024 bytes
Fixed
Size
2226936 bytes
Variable
Size
96470280 bytes
Database
Buffers
104857600 bytes
Redo
Buffers
5214208 bytes
2、还原spfile和controlfile
RMAN> restore spfile from '/space/backup/02qdob32_1_1';
Starting restore at 04-AUG-2015 09:58:12
using target database control file instead of recovery
catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
channel ORA_DISK_1: restoring spfile from AUTOBACKUP
/space/backup/02qdob32_1_1
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 04-AUG-2015 09:58:14
RMAN> shutdown immediate
using target database control file instead of recovery
catalog
Oracle instance shut down
SQL> startup nomount
ORACLE instance started.
Total System Global Area 413372416 bytes
Fixed
Size
2228904 bytes
Variable
Size
276827480 bytes
Database
Buffers
130023424 bytes
Redo
Buffers
4292608 bytes
RMAN> restore controlfile from
'/space/backup/02qdob32_1_1';
Starting restore at 04-AUG-2015 10:01:26
using target database control file instead of recovery
catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file
name=/space/oradata/tx9ab/controlfile/control01.ctl
output file
name=/space/oradata/tx9ab/controlfile/control02.ctl
output file
name=/space/oradata/tx9ab/controlfile/control03.ctl
Finished restore at 04-AUG-2015 10:01:29
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
3、注册备份及信息
RMAN> catalog start with '/space/backup/';
searching for all files that match the pattern /space/backup/
List of Files Unknown to the Database
=====================================
File Name: /space/backup/01qdoatt_1_1
File Name: /space/backup/02qdob32_1_1
Do you really want to catalog the above files (enter YES or NO)?
y
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /space/backup/01qdoatt_1_1
File Name: /space/backup/02qdob32_1_1
4、恢复数据库
--由于测试机的环境没有改变datafile的路径,可以直接还原
RMAN> run
{allocate channel t1 type disk ;
allocate channel t2 type disk ;
#set newname for database to '..../datafile/%b';
#set newname for tempfile 1 to '..../tempfile/%b';
restore database force;
switch datafile all;
release channel t1;
release channel t2;}
RMAN> recover database;
Starting recover at 31-MAR-2015 00:01:52
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
starting media recovery
unable to find archived log
archived log thread=1 sequence=1
RMAN-00571:
===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS
===============
RMAN-00571:
===========================================================
RMAN-03002: failure of recover command at 03/31/2015 00:01:52
RMAN-06054: media recovery requesting unknown archived log for
thread 1 with sequence 1 and starting SCN of 2757245
RMAN> recover database until scn=
2757245; --
指定了scn ,丢掉了redo 中的日志信息;
SYS@tx9ab>alter database open resetlogs;
Database altered.
结论:
由于异机恢复的场景里,一般是不会有联机日志的这里这里只能进行不完全恢复了!
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26727294/viewspace-1767711/
,如需转载,请注明出处,否则将追究法律责任。