您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

rman恢复数据库--用备份的控制文件

2025/1/20 9:13:50发布16次查看
从上面的恢复过程可以看到,应用了所有的日志,包括在线日志,归档日志到sequence9,但是恢复sequence 到10。10作为当前日志。8、
1、做全库备份
rman> run{
 allocate channel c1 type disk maxpiecesize=500m;
 backup current controlfile format '+dgasm/backup/ctl_%d_%s';
 backup full database format '+dgasm/backup/db_%d_%s_%p_%t';
 sql 'alter system archive log current';
 release channel c1;
 }2> 3> 4> 5> 6> 7>
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=37 device type=disk
starting backup at 30-jun-12
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
channel c1: starting piece 1 at 30-jun-12
channel c1: finished piece 1 at 30-jun-12
piece handle=+dgasm/backup/ctl_ora11_37 tag=tag20120630t094535 comment=none
channel c1: backup set complete, elapsed time: 00:00:04
finished backup at 30-jun-12
starting backup at 30-jun-12
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=+dgasm/ora11/datafile/system.257.785186755
input datafile file number=00002 name=+dgasm/ora11/datafile/sysaux.258.785186845
input datafile file number=00003 name=+dgasm/ora11/datafile/undotbs1.259.785186901
input datafile file number=00004 name=+dgasm/ora11/datafile/users.272.787009469
channel c1: starting piece 1 at 30-jun-12
channel c1: finished piece 1 at 30-jun-12
piece handle=+dgasm/backup/db_ora11_38_1_787311941 tag=tag20120630t094541 comment=none
channel c1: starting piece 2 at 30-jun-12
channel c1: finished piece 2 at 30-jun-12
piece handle=+dgasm/backup/db_ora11_38_2_787311941 tag=tag20120630t094541 comment=none
channel c1: backup set complete, elapsed time: 00:01:00
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
including current spfile in backup set
channel c1: starting piece 1 at 30-jun-12
channel c1: finished piece 1 at 30-jun-12
piece handle=+dgasm/backup/db_ora11_39_1_787312002 tag=tag20120630t094541 comment=none
channel c1: backup set complete, elapsed time: 00:00:01
finished backup at 30-jun-12
sql statement: alter system archive log current
released channel: c1
rman>
2、做操做
创建haozg user 然后建表
sql> create table haozg_hist as select * from v$loghist;
table created.
sql> alter system switch logfile;
system altered.
sql> /
system altered.
sql> /
system altered.
sql> /
system altered.
sql>
sql> create table test(id number,name varchar2(13));
table created.
sql>  insert into test select object_id,object_name from dba_objects where rownum=1;
1 row created.
sql> commit;
commit complete.
sql> alter system switch logfile;
system altered.
sql> /
system altered.
sql> /
system altered.
3、关闭数据库,删除控制文件,模拟控制文件顺坏
在grid 用户下操作
asmcmd> cd controlfile
asmcmd> ls
current.260.787304065
asmcmd> rm -f *
4、启动数据库到nomount状态
5、转储控制文件从备份集中
rman> restore controlfile  from '+dgasm/backup/ctl_ora11_37';
starting restore at 30-jun-12
using target database control file instead of recovery catalog
allocated channel: ora_disk_1
channel ora_disk_1: sid=26 device type=disk
channel ora_disk_1: restoring control file
channel ora_disk_1: restore complete, elapsed time: 00:00:02
output file name=+dgasm/controlfile/control01.ctl
finished restore at 30-jun-12
rman>
6、启动数据库到mount状态
7、恢复数据库
rman> recover database;
starting recover at 30-jun-12
released channel: ora_disk_1
starting implicit crosscheck backup at 30-jun-12
allocated channel: ora_disk_1
channel ora_disk_1: sid=26 device type=disk
crosschecked 19 objects
finished implicit crosscheck backup at 30-jun-12
starting implicit crosscheck copy at 30-jun-12
using channel ora_disk_1
crosschecked 8 objects
finished implicit crosscheck copy at 30-jun-12
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ora_disk_1
rman-06900: warning: unable to generate v$rman_status or v$rman_output row
rman-06901: warning: disabling update of the v$rman_status and v$rman_output rows
oracle error from target database:
ora-19922: there is no parent row with id 0 and level 1
starting media recovery
archived log for thread 1 with sequence 8 is already on disk as file +dgasm/ora11/onlinelog/group_2.264.785192615
archived log for thread 1 with sequence 9 is already on disk as file +dgasm/ora11/onlinelog/group_3.265.785192859
archived log for thread 1 with sequence 10 is already on disk as file +dgasm/ora11/onlinelog/group_1.263.785192081
archived log file name=/oracle/archivelog/1_1_787309225.dbf thread=1 sequence=1
archived log file name=/oracle/archivelog/1_2_787309225.dbf thread=1 sequence=2
archived log file name=/oracle/archivelog/1_3_787309225.dbf thread=1 sequence=3
archived log file name=/oracle/archivelog/1_4_787309225.dbf thread=1 sequence=4
archived log file name=/oracle/archivelog/1_5_787309225.dbf thread=1 sequence=5
archived log file name=/oracle/archivelog/1_6_787309225.dbf thread=1 sequence=6
archived log file name=/oracle/archivelog/1_7_787309225.dbf thread=1 sequence=7
archived log file name=+dgasm/ora11/onlinelog/group_2.264.785192615 thread=1 sequence=8
archived log file name=+dgasm/ora11/onlinelog/group_3.265.785192859 thread=1 sequence=9
archived log file name=+dgasm/ora11/onlinelog/group_1.263.785192081 thread=1 sequence=10
media recovery complete, elapsed time: 00:00:02
finished recover at 30-jun-12
rman>
从上面的恢复过程可以看到,应用了所有的日志,包括在线日志,归档日志到sequence9,但是恢复sequence 到10。
10作为当前日志。
8、以resetlogs 方式打开数据库
9、检查用户和表,数据都存在。
总结:rman 自动以datafile 为基准,应用所有归档日志文件,包括在线日志文件,完成不完全恢复。oracle 不知道恢复的终点,有多少日志,,应用多少日志,日志都存在的情况下,数据没有丢失。在这个过程中没有让dba参与。
v$log 中的内容来自控制文件。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product