Pages

31 Aralık 2010 Cuma

Tüm kontrol dosyalarının silinmesinden sonra RMAN ile geri kurtarma

Bu senaryoda uygulamak amacıyla TESTTBL adlı bir tablo oluşturacağım ve içini kayıtlarla dolduracağım. En son kontrol dosyalarından veritabanını geri kurtarıp ardından felaket anından tamamlanmamış(incomplete) geri kurtarma uygulaması yapacağım. Linux platformunda Oracle 10g veritabanı kullanmaktayım.

SQL> insert into TESTTBL select * from TESTTBL;
21244 rows created.

SQL> commit;
Commit complete.

SQL> select count(*) from testtbl;

  COUNT(*)
----------
   182659   à Geri kurtarma sonrası bu kaydı kontrol etmemiz gerekecek

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     7
Next log sequence to archive   9
Current log sequence           9

Not: Mevcut log sırası 9 dur ve henüz arşivlenmemiştir, ancak en son COMMIT işleminden sonraki bilgiler bu log dosyası içindedir.

Felaket senaryosuna başlama

SQL> select name from v$controlfile;

NAME
--------------------------------------------------
/u01/app/ORACLE/testdb/control01.ctl
/u01/app/ORACLE/testdb/control02.ctl
/u01/app/ORACLE/testdb/control03.ctl

SQL> !rm /u01/app/ORACLE/testdb/*.ctl

SQL> alter tablespace users online;
alter tablespace users online
*
ERROR at line 1:
ORA-00603: ORACLE server session terminated by fatal error

SQL> shutdown abort
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area  893386752 bytes
Fixed Size                  2076816 bytes
Variable Size             432017264 bytes
Database Buffers          452984832 bytes
Redo Buffers                6307840 bytes

*** RMAN kataloğu kullanmadığımızdan dolayı DBID’yi atamamız gerekmektedir. ***

RMAN> set dbid=2415549446;
executing command: SET DBID

Kontrol dosyasını geri yükleme


RMAN> run {
2> restore controlfile from autobackup;
3> }
Starting restore at 22-DEC-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
recovery area destination: /u01/app/ORACLE/flash_recovery_area
database name (or database unique name) used for search: TESTDB
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found: /u01/app/ORACLE/flash_recovery_area/TESTDB/autobackup/
2010_12_22/o1_mf_s_633601094_3gynd74g_.bkp
channel ORA_DISK_1: control file restore from autobackup complete
output filename=/u01/app/ORACLE/testdb/control01.ctl
output filename=/u01/app/ORACLE/testdb/control02.ctl
output filename=/u01/app/ORACLE/testdb/control03.ctl
Finished restore at 22-DEC-10

Veritabanını mount modda açma ve veritabanını geri yükleme

RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1

RMAN> recover database;
Starting recover at 22-DEC-10
Starting implicit crosscheck backup at 22-DEC-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 1 objects
Finished implicit crosscheck backup at 22-DEC-10
Starting implicit crosscheck copy at 22-DEC-10
using channel ORA_DISK_1
Finished implicit crosscheck copy at 22-DEC-10
searching for all files in the recovery area
cataloging files...
cataloging done.
List of Cataloged Files
=======================
File Name: /u01/app/ORACLE/flash_recovery_area/TESTDB/autobackup/
2010_12_22/o1_mf_s_633601094_3gynd74g_.bkp
using channel ORA_DISK_1
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: sid=155 devtype=SBT_TAPE
channel ORA_SBT_TAPE_1: Data Protection for Oracle: version 5.2.2.0
datafile 4 not processed because file is offline
starting media recovery
archive log thread 1 sequence 8 is already on disk as file /u01/app/ORACLE/flash_recovery_area/TESTDB/
archivelog/2010_12_22/o1_mf_1_6_3gyn7vnk_.arc
archive log thread 1 sequence 9 is already on disk as file /u01/app/ORACLE/testdb/redo03.log
archive log filename=/u01/ORACLE/flash_recovery_area/TESTDB/archivelog/2010_12_22/
o1_mf_1_6_3gyn7vnk_.arc thread=1 sequence=8
archive log filename=/u01/ORACLE/testdb/redo03.log thread=1 sequence=9  media recovery complete, elapsed time: 00:00:09
Finished recover at 22-DEC-10

SQL> alter database open resetlogs;
Database altered.

conn scott/tiger
Connected.
SQL> select count(*) from testtbl;

  COUNT(*)
----------
   182659

0 yorum:

Yorum Gönder