注意,这里强调的是存在有效可用的备份介质。
这里演示的是最常见的使用RMAN恢复SYSTEM表空间丢失的数据方法。
1.连接到catalog数据库完成对数据库的备份
[oracle@secdb oradata]$ rman target / catalog rman_catalog/rman_catalog@catalog
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Jul 15 22:14:24 2010
Copyright (c) 1982, 2005,Oracle. All rights reserved.
connected to target database: ORA10G (DBID=4067316777)
connected to recovery catalog database
RMAN> run{
backup full database
format '/u01/app/oracle/rmanbak/full_bk1_%u%p%s.rmn'
include current controlfile;
backup archivelog all
format '/u01/app/oracle/rmanbak/arch_bk1_%u%p%s.rmn'
delete all input;
}
…… 省略输出结果 ……
2.模拟SYSTEM表空间数据文件丢失
sys@ora10g> col name for a60
sys@ora10g> select file#,name from v$datafile;
FILE# NAME
---------- -----------------------------
1 /u01/app/oracle/oradata/ora10g/system01.dbf
2 /u01/app/oracle/oradata/ora10g/undotbs01.dbf
3 /u01/app/oracle/oradata/ora10g/sysaux01.dbf
4 /u01/app/oracle/oradata/ora10g/users01.dbf
5 /u01/app/oracle/oradata/ora10g/example01.dbf
6 /u01/app/oracle/oradata/ora10g/user_08.dbf
sys@ora10g> ! rm -f /u01/app/oracle/oradata/ora10g/system01.dbf
故障现象举例:
sys@ora10g> select * from cat;
select * from cat
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQLlevel 1
ORA-01116: error in opening database file 1
ORA-01110: datafile 1: '/u01/app/oracle/oradata/ora10g/system01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
sys@ora10g> shutdown immediate;
ORA-01116: error in opening database file 1
ORA-01110: data file 1: '/u01/app/oracle/oradata/ora10g/system01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
sys@ora10g> shutdown abort;
ORACLE instance shut down.
NotConnected@> startup;
ORACLE instance started.
Total System Global Area 314572800 bytes
Fixed Size 1219136 bytes
Variable Size 125830592 bytes
Database Buffers 180355072 bytes
Redo Buffers 7168000 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/app/oracle/oradata/ora10g/system01.dbf'
NotConnected@> select status from v$instance;
STATUS
------------
MOUNTED
3.使用RMAN完成数据文件恢复
1)连接到catalog数据库
[oracle@secdb oradata]$ rman target / catalog rman_catalog/rman_catalog@catalog
Recovery Manager: Release 10.2.0.1.0 - Production on Thu Jul 15 22:16:51 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORA10G (DBID=4067316777, not open)
connected to recovery catalog database
2)还原1号数据文件,此文件即为SYSTEM表空间丢失的数据文件
RMAN> restore datafile 1;
Starting restore at 15-JUL-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/ora10g/system01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/rmanbak/full_bk1_0flis4k9115.rmn
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/rmanbak/full_bk1_0flis4k9115.rmn tag=TAG20100715T171449
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 15-JUL-10
3)对1号数据文件进行恢复
RMAN> recover datafile 1;
Starting recover at 15-JUL-10
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished recover at 15-JUL-10
4)将数据库启动到OPEN状态
RMAN> alter database open;
database opened
5)验证数据库的可用性
[oracle@secdb oradata]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jul 15 22:24:14 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10gEnterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
sys@ora10g> select status from v$instance;
STATUS
------------
OPEN
4.小结
恢复丢失的数据文件的过程是非常简便的。真正要重视的备份策略的科学性和备份介质的有效性,前者需要需要对备份策略做深入的策划,后者可以通过定期的备份介质有效性验证来保证。
--转自