11gR2 基于ASM磁盘组的数据库恢复

这篇文章使用最简单的备份恢复的例子讨论11gR2中基于 ASM 磁盘组的数据库恢复内容。
i&eEn6e,Y}(d}0ITPUB个人空间'A4Y)s'w:rS@H+oQ#C%mC
[root@redhat6 ~]# su - grid
[grid@redhat6 ~]$ sqlplus / as sysdba
ITPUB个人空间9P$`x9i6r7[
SQL*Plus: Release 11.2.0.3.0 Production on Sat Jul 7 15:26:33 2012

7q9@K~9nC_5T'G0
Copyright (c) 1982, 2011, Oracle. All rights reserved.

0E iO.xa&v v9n A0
ITPUB个人空间:Z8|A.`'Gs{N'Tq
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options
SQL> select name,state from v$asm_diskgroup;
ITPUB个人空间-[K/g~e@ac)c(K
NAME STATE
------------------------------ ----------------------
ARC MOUNTED
DATA MOUNTED

|$X Yx:w }$Y-}(O*Zj0 11gR2中,通常只需要创建两个磁盘组,一个用于存放数据文件,另一个用于快速恢复区,存放归档、备份等其他文件。11gR2有一个特点是默认会将控制文件和每个日志组文件都存放到两个磁盘组中。ITPUB个人空间4XS U'J8xR

V+[ n_/Tg j@0
[oracle@redhat6 ~]$sql

)R`"{+f3g r&Gt0
SQL*Plus: Release 11.2.0.3.0 Production on Sat Jul 7 15:05:17 2012

p2B)mbo~2F0
Copyright (c) 1982, 2011, Oracle. All rights reserved.

9`&F"O4m*z0

*WQ.h'm:\?h(h0
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
ITPUB个人空间fEZ(TbJ9l8{
SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
+DATA/orcl/datafile/system.260.788021711
+DATA/orcl/datafile/sysaux.259.788021711
+DATA/orcl/datafile/undotbs1.257.788021525
+DATA/orcl/datafile/users.261.788021713
+DATA/orcl/datafile/test.258.788021527

T U$T^u0 这是故障前的数据文件。ITPUB个人空间Oj-klJ

Y'u+a%Ae aB y0
SQL> select group#,member from v$logfile;
ITPUB个人空间 |0j$}~$J!H
GROUP# MEMBER
---------- --------------------------------------------------
1 +DATA/orcl/onlinelog/group_1.265.787999631
1 +ARC/orcl/onlinelog/group_1.260.787999641
2 +DATA/orcl/onlinelog/group_2.264.787999651
2 +ARC/orcl/onlinelog/group_2.257.787999661
3 +DATA/orcl/onlinelog/group_3.257.787999671
3 +ARC/orcl/onlinelog/group_3.259.787999681
ITPUB个人空间~Kv9cS$Eo
6 rows selected.

,w G7[?Y D8F0 这是数据库的在线Redo日志组,可以看出每个日志组在两个ASM磁盘组都有成员。ITPUB个人空间0w:sLpk%{7B

T%Hh(|"a0
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
[grid@redhat6 ~]$ sqlplus / as sysasm
ITPUB个人空间l.c"p Vcv:f a
SQL*Plus: Release 11.2.0.3.0 Production on Sat Jul 7 15:06:37 2012

u5@'J#]P%I7U0
Copyright (c) 1982, 2011, Oracle. All rights reserved.

ZY'JFOs8nF E$xzs,o0

C0WO] X0
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options
ITPUB个人空间-A/I0vKTNKe3~
ITPUB个人空间'dE2|tM+e.{U
SQL> drop diskgroup data including contents;
ITPUB个人空间)K"m sB+{.rO:L#Of:~p
Diskgroup dropped.ITPUB个人空间4f-M$i0D W!G iC(W-d

$`:cI"E$b]5N+d1|0DROP故障组,模拟磁盘组损坏。
ITPUB个人空间h gS9O$m})`Uc
SQL> create diskgroup data external redundancy
2 disk '/dev/raw/raw6' name data01;

d*Hd_dr v0
Diskgroup created.
ITPUB个人空间M3G5reL"IF
[root@redhat6 ~]# su - oracle
[oracle@redhat6 ~]$ sql
ITPUB个人空间7Bz*hZJ.D
SQL*Plus: Release 11.2.0.3.0 Production on Sat Jul 7 15:10:13 2012

`JmdX~y C {O|#z0
Copyright (c) 1982, 2011, Oracle. All rights reserved.
ITPUB个人空间"j'q"DHv ?4q;f
Connected to an idle instance.

^Yq8Vh(o _uw0
SQL> startup mount
ORACLE instance started.

!uyJ&n+DDA)V|0
Total System Global Area 1068937216 bytes
Fixed Size 2235208 bytes
Variable Size616563896 bytes
Database Buffers444596224 bytes
Redo Buffers 5541888 bytes
ORA-00205: error in identifying control file, check alert log for more info

/y-s&Y{4k5r%r0 磁盘组丢失,磁盘组中的控制文件也就丢失了。
ITPUB个人空间UPv\&aE1g
SQL> show parameter control_files

t(t#RY6q/}0
NAME TYPE
------------------------------------ ----------------------
VALUE
------------------------------
control_files string
+DATA/orcl/controlfile/control
01.ctl, +ARC/orcl/controlfile/
current.256.787999629ITPUB个人空间 l Qt k} f$a

J*^s"A!o[ ?0
[root@redhat6 ~]# su - grid
[grid@redhat6 ~]$ asmcmd -p -v
WARNING: Tracing level not specified
Default level of tracing is enabled.
ASMCMD [+] > mkdir +DATA/orcl/
ASMCMD [+] > mkdir +DATA/orcl/controlfile/
ASMCMD [+] > cp +ARC/orcl/controlfile/current.256.787999629 +DATA/orcl/controlfile/control01.ctl
copying +ARC/orcl/controlfile/current.256.787999629 -> +DATA/orcl/controlfile/control01.ctl
^W9v3\k0ITPUB个人空间w*o&Y:SI`D
由于在+ARC磁盘组中还有控制文件镜像,所以可以非常容易的拷贝一份到新建的+DATA磁盘组,注意调整参数文件中CONTROL_FILE的值。ITPUB个人空间"d1P!~8pC1y w
ITPUB个人空间 Y,rYE g6~
[root@redhat6 ~]# su - oracle
[oracle@redhat6 ~]$ sql
ITPUB个人空间BuB1E6W"^~fy
SQL*Plus: Release 11.2.0.3.0 Production on Sat Jul 7 15:11:42 2012

n/SR[M}0
Copyright (c) 1982, 2011, Oracle. All rights reserved.

fyz0hi'p x7rj/a0

t9[ Y!s _ke't-Bp0
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

} j(le_'Y0
SQL> alter database mount;

YXz"F0^+di/v)Mo0
Database altered.
ITPUB个人空间&Za(_Tt-[4F d8|
[oracle@redhat6 ~]$ rman target /

G9yi|i z zr0
Recovery Manager: Release 11.2.0.3.0 - Production on Sat Jul 7 15:12:03 2012

3H C'B@N3zV3BE0
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
ITPUB个人空间 u"A,]3W]
connected to target database: ORCL (DBID=1315780364, not open)
ITPUB个人空间za(^(jb#H8i[1qy
RMAN> restore database;
ITPUB个人空间 _9Ld|k7`
Starting restore at 2012-07-07 15:12:12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=137 device type=DISK

;ZUJj3E0
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00003 to +DATA/orcl/datafile/undotbs1.257.788021525
channel ORA_DISK_1: restoring datafile 00005 to +DATA/orcl/datafile/test.258.788021527
channel ORA_DISK_1: reading from backup piece +ARC/orcl/backupset/2012_07_07/nnndf0_tag20120707t143500_0.261.788020503
channel ORA_DISK_1: piece handle=+ARC/orcl/backupset/2012_07_07/nnndf0_tag20120707t143500_0.261.788020503 tag=TAG20120707T143500
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:36
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to +DATA/orcl/datafile/system.260.788021711
channel ORA_DISK_1: restoring datafile 00002 to +DATA/orcl/datafile/sysaux.259.788021711
channel ORA_DISK_1: restoring datafile 00004 to +DATA/orcl/datafile/users.261.788021713
channel ORA_DISK_1: reading from backup piece +ARC/orcl/backupset/2012_07_07/nnndf0_tag20120707t143500_0.262.788020505
channel ORA_DISK_1: piece handle=+ARC/orcl/backupset/2012_07_07/nnndf0_tag20120707t143500_0.262.788020505 tag=TAG20120707T143500
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:26
Finished restore at 2012-07-07 15:17:20

M ^tV,{e)R0
RMAN> recover database;
ITPUB个人空间#cV$H9b|(\7\k
Starting recover at 2012-07-07 15:17:26
using channel ORA_DISK_1

7ci B4[+Dpv|0
starting media recovery
media recovery complete, elapsed time: 00:00:05
ITPUB个人空间7O ^ KYiL
Finished recover at 2012-07-07 15:17:34
ITPUB个人空间 rv o8a;q.?
RMAN> sql 'alter database open;';

f`!N7gw-oQ f0
sql statement: alter database open
ITPUB个人空间A [ P,egb|(v
之所以能够如此轻松的完成数据库的完全恢复,就在于用于备份的ARC中存储了备份、归档Redo日志和在线Redo日志成员,11gR2的这个调整对于在丢失一个磁盘组的情况下的恢复是非常有利的。
:e^[7_'?H3fW@0ITPUB个人空间4c P7GomV!L
RMAN> exit
ITPUB个人空间|)Ot]3S{7yg%t
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
ITPUB个人空间Y[7^]4hy
SQL> select file_name from dba_data_files;

(`P FHRl,Ey0
FILE_NAME
--------------------------------------------------------------------------------
+DATA/orcl/datafile/system.260.788022897
+DATA/orcl/datafile/sysaux.259.788022895
+DATA/orcl/datafile/undotbs1.257.788022739
+DATA/orcl/datafile/users.261.788022897
+DATA/orcl/datafile/test.258.788022741
ITPUB个人空间+O(u+t#Y\\5v[2W.G|
将恢复后的数据文件和之前的数据文件对比,不难发现,恢复前后的数据文件名称完全不同,居然不需要执行alter database file rename命令就可以顺利打开数据库,这也是11gR2的改进吧!
r&p$l-~^{6p*V}%R0
dU;fK |#jw0--end--

你可能感兴趣的:(数据库)