rman実験のアーカイブモードはバックアップがあり、正常なシャットダウンでデータファイルの回復が失われた.
1バックアップの作成
2構築環境
3アナログデータファイルの紛失
4 rmanによる修復とリカバリ
5クエリーデータ
データはすべて戻ってきて、回復に成功しました!
RMAN> backup database plus archivelog;
2構築環境
hr@ORCL> create table tt (name varchar2(20));
Table created.
hr@ORCL> insert into tt values('test1');
1 row created.
hr@ORCL> insert into tt values('test2');
1 row created.
hr@ORCL> insert into tt values('test3');
1 row created.
hr@ORCL> commit;
Commit complete.
hr@ORCL> select * from tt;
NAME
--------------------
test1
test2
test3
3アナログデータファイルの紛失
sys@ORCL> select default_tablespace from dba_users where username='HR';
DEFAULT_TABLESPACE
--------
users
sys@ORCL> select dt.tablespace_name,
2 file_id,
3 file_name
4 from dba_tablespaces dt, dba_data_files dd
5 where dt.tablespace_name=dd.tablespace_name;
TABLESPA FILE_ID FILE_NAME
-------- ---------- ----------------------------------------------------------------------
USERS 4 /u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_8050fkdh_.dbf
SYSAUX 3 /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_8050fk3w_.dbf
UNDOTBS1 2 /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_8050fkc6_.dbf
SYSTEM 1 /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_8050fk2z_.dbf
EXAMPLE 5 /u01/app/oracle/oradata/ORCL/datafile/o1_mf_example_8050jhm7_.dbf
UNDOTBS2 6 /u01/app/oracle/oradata/ORCL/datafile/undotbsthi.dbf
RMANTBS 7 /u01/app/oracle/flash_recovery_area/ORCL/rmantbs01.dbf
sys@ORCL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sys@ORCL> host rm -rf /u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_8050fkdh_.dbf;
:
sys@ORCL> startup
ORACLE instance started.
Total System Global Area 419430400 bytes
Fixed Size 1219760 bytes
Variable Size 121635664 bytes
Database Buffers 293601280 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_8050fkdh_.dbf'
4 rmanによる修復とリカバリ
[oracle@localhost ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Mon Aug 6 22:54:36 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1316499950, not open)
RMAN> restore datafile 4;
Starting restore at 06-AUG-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00004 to /u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_8050fkdh_.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_08_06/o1_mf_nnndf_TAG20120806T223510_81zojyz5_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2012_08_06/o1_mf_nnndf_TAG20120806T223510_81zojyz5_.bkp tag=TAG20120806T223510
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 06-AUG-12
RMAN> recover datafile 4;
Starting recover at 06-AUG-12
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished recover at 06-AUG-12
RMAN> alter database open;
database opened
5クエリーデータ
hr@ORCL> select * from tt;
NAME
--------------------
test1
test2
test3
データはすべて戻ってきて、回復に成功しました!