这篇文章使用最简单的备份恢复的例子讨论11gR2中基于ASM磁盘组的数据库恢复内容。
[root@redhat6 ~]# su - grid
[grid@redhat6 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Sat Jul 7 15:26:33 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
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;
NAME STATE
------------------------------ ----------------------
ARC MOUNTED
DATA MOUNTED
11gR2中,通常只需要创建两个磁盘组,一个用于存放数据文件,另一个用于快速恢复区,存放归档、备份等其他文件。11gR2有一个特点是默认会将控制文件和每个日志组文件都存放到两个磁盘组中。
[oracle@redhat6 ~]$sql
SQL*Plus: Release 11.2.0.3.0 Production on Sat Jul 7 15:05:17 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
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
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
这是故障前的数据文件。
SQL> select group#,member from v$logfile;
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
6 rows selected.
这是数据库的在线Redo日志组,可以看出每个日志组在两个ASM磁盘组都有成员。
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
[grid@redhat6 ~]$ sqlplus / as sysasm
SQL*Plus: Release 11.2.0.3.0 Production on Sat Jul 7 15:06:37 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
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> drop diskgroup data including contents;
Diskgroup dropped.
DROP故障组,模拟磁盘组损坏。
SQL> create diskgroup data external redundancy
2 disk '/dev/raw/raw6' name data01;
Diskgroup created.
[root@redhat6 ~]# su - oracle
[oracle@redhat6 ~]$ sql
SQL*Plus: Release 11.2.0.3.0 Production on Sat Jul 7 15:10:13 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2235208 bytes
Variable Size 616563896 bytes
Database Buffers 444596224 bytes
Redo Buffers 5541888 bytes
ORA-00205: error in identifying control file, check alert log for more info
磁盘组丢失,磁盘组中的控制文件也就丢失了。
SQL> show parameter control_files
NAME TYPE
------------------------------------ ----------------------
VALUE
------------------------------
control_files string
+DATA/orcl/controlfile/control
01.ctl, +ARC/orcl/controlfile/
current.256.787999629
[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
由于在+ARC磁盘组中还有控制文件镜像,所以可以非常容易的拷贝一份到新建的+DATA磁盘组,注意调整参数文件中CONTROL_FILE的值。
[root@redhat6 ~]# su - oracle
[oracle@redhat6 ~]$ sql
SQL*Plus: Release 11.2.0.3.0 Production on Sat Jul 7 15:11:42 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
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
SQL> alter database mount;
Database altered.
[oracle@redhat6 ~]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Sat Jul 7 15:12:03 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1315780364, not open)
RMAN> restore database;
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
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
RMAN> recover database;
Starting recover at 2012-07-07 15:17:26
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:05
Finished recover at 2012-07-07 15:17:34
RMAN> sql 'alter database open;';
sql statement: alter database open
之所以能够如此轻松的完成数据库的完全恢复,就在于ARC磁盘组中存储了备份、归档Redo日志和在线Redo日志成员。11gR2中控制文件和在线Redo日志文件默认都会存储在两个磁盘组中,这一调整对于在只丢失一个磁盘组的情况下的恢复非常有利的。
RMAN> exit
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
SQL> select file_name from dba_data_files;
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
将恢复后的数据文件和之前的数据文件对比,不难发现,恢复前后的数据文件名称完全不同,居然不需要执行alter database file rename命令就可以顺利打开数据库,这也是11gR2的改进吧!
--end--
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29615408/viewspace-1384870/
,如需转载,请注明出处,否则将追究法律责任。