Sie sind auf Seite 1von 16

Global IT Standard Operating Procedures

Procedure Author Procedure Create Date Procedure Modify Date


Sanjay Gonsalves 10-Feb-10 10-Feb-10

Procedure Version Procedure Name Procedure Aliases


1.0 Database Recovery Hot Backup, crash, backup, pfile,
logminer, rollback, redo logs, control
files, database

Procedure Category
Troubleshooting

Procedure Goal or Function


Recovering the Database in Different Scenarios

Procedure Trigger
- Instance Crash During Hot Backup; loss of datafile, non-system rollback segments, and online redo logs; finding
timestamp when a table was dropped.

Procedure Resource(s) Needed


1 DBA. 1 hour each

Procedural Steps

Recovering the Database

CONTENTS

1. Instance Crash During Hot Backup


2. Loss of Datafile without Backup
3. Loss of all non-system rollback segments and database recovery
4. Loss of online redo logs and database recovery
5. Backup control files, online redo logs, and database recovery
6. Using Logminer to find timestamp when a table was dropped

1. INSTANCE CRASH DURING HOT BACKUP

Connect as Server manager

SVRMGR> alter tablespace user_data begin backup;


Statement processed.

SVRMGR> select * from v$backup;


FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- ---------
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 ACTIVE 33285 28-APR-98
4 NOT ACTIVE 0

1
Global IT Standard Operating Procedures

5 NOT ACTIVE 0
5 rows selected.

SVRMGR> shutdown abort –- Instance crashed!


ORACLE instance shut down.

SVRMGR> startup pfile=$HOME/initDB14.ora


ORACLE instance started.
Total System Global Area 7083684 bytes
Fixed Size 44924 bytes
Variable Size 5900072 bytes
Database Buffers 614400 bytes
Redo Buffers 524288 bytes
Database mounted.
ORA-01113: file 3 needs media recovery
ORA-01110: data file 3: '/dbaclass7/dba14/DATA/DISK2/user01.dbf'

SVRMGR> select * from v$backup; -- Note that file 3 is in hot backup mode
FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- ---------
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 ACTIVE 33285 28-APR-98
4 NOT ACTIVE 0
5 NOT ACTIVE 0
5 rows selected.

SVRMGR> alter database datafile '$HOME/DATA/DISK2/user01.dbf' end backup;


Statement processed.

SVRMGR> alter database open;


Statement processed.

SVRMGR> select status, instance_name from v$instance; -Verify database is open


STATUS INSTANCE_NAME
------- ----------------
OPEN DBA14
1 row selected.

SVRMGR> select * from v$backup; -- “Hot backup” fuzzy bit reset for file 3
FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- ---------
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 NOT ACTIVE 33285 28-APR-98
4 NOT ACTIVE 0
5 NOT ACTIVE 0
5 rows selected.

2
Global IT Standard Operating Procedures

SVRMGR>

2. LOSS OF DATAFILE WITHOUT BACKUP

SVRMGR> archive log list


Database log mode Archive Mode
Automatic archival Enabled
Archive destination /dbaclass1/teach2/ARCHIVE
Oldest online log sequence 10
Next log sequence to archive 11
Current log sequence 11

SVRMGR> create tablespace junk99 datafile –- New tablespace created…


2> '/dbaclass1/teach2/DATA/DISK1/junk99.dbf' size 5m;
Statement processed.

SVRMGR> create table test (id number)


2> tablespace junk99;
Statement processed.

SVRMGR> insert into test values (100);


1 row processed.

SVRMGR> insert into test values (200);


1 row processed.

SVRMGR> insert into test values (300);


1 row processed.

SVRMGR> commit; -- Recovery should get these 3 rows back


Statement processed.

SVRMGR> alter system switch logfile;


Statement processed.

SVRMGR> alter system switch logfile;


Statement processed.

SVRMGR> alter system switch logfile;


Statement processed.

SVRMGR> alter system switch logfile;


Statement processed.

SVRMGR> shutdown abort


ORACLE instance shut down.

SVRMGR> !rm $HOME/DATA/DISK1/junk99.dbf –- Loss of datafile (no backup)

3
Global IT Standard Operating Procedures

SVRMGR> startup
ORACLE instance started.
Total System Global Area 43233440 bytes
Fixed Size 73888 bytes
Variable Size 41431040 bytes
Database Buffers 1638400 bytes
Redo Buffers 90112 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 8 - see DBWR trace file
ORA-01110: data file 8: '/dbaclass1/teach2/DATA/DISK1/junk99.dbf'

SVRMGR> alter database create datafile


2> '/dbaclass1/teach2/DATA/DISK1/junk99.dbf';
Statement processed.

SVRMGR> recover datafile 8 –- Oracle retains original file#


ORA-00279: change 123148 generated at 10/23/2001 07:55:38 needed for thread 1
ORA-00289: suggestion : /dbaclass1/teach2/ARCHIVE/arch_T2_11.arc
ORA-00280: change 123148 for thread 1 is in sequence #11
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
Log applied.
ORA-00279: change 123169 generated at 10/23/2001 07:58:48 needed for thread 1
ORA-00289: suggestion : /dbaclass1/teach2/ARCHIVE/arch_T2_12.arc
ORA-00280: change 123169 for thread 1 is in sequence #12
ORA-00278: log file '/dbaclass1/teach2/ARCHIVE/arch_T2_11.arc' no longer needed
Log applied.
ORA-00279: change 123170 generated at 10/23/2001 07:58:58 needed for thread 1
ORA-00289: suggestion : /dbaclass1/teach2/ARCHIVE/arch_T2_13.arc
ORA-00280: change 123170 for thread 1 is in sequence #13
ORA-00278: log file '/dbaclass1/teach2/ARCHIVE/arch_T2_12.arc' no longer needed
Log applied.
Media recovery complete.

SVRMGR> alter database open;


Statement processed.

SVRMGR> select * from test; -- Recovery worked!


ID
----------
100
200
300
3 rows selected.

4
Global IT Standard Operating Procedures

3. LOSS OF ALL NON-SYSTEM ROLLBACK SEGMENTS AND DATABASE RECOVERY

SVRMGR> startup pfile=$HOME/data/initDB15.ora


ORACLE instance started.
Total System Global Area 4436296 bytes
Fixed Size 39732 bytes
Variable Size 3876372 bytes
Database Buffers 512000 bytes
Redo Buffers 8192 bytes
Database mounted.
Database opened.

SVRMGR> create table test01 (col1 number) tablespace user_data;


Statement processed.

SVRMGR> insert into test01 values (1);


1 row processed.

SVRMGR> insert into test01 values (2);


1 row processed.

SVRMGR> commit; -- two rows committed in test01 table


Statement processed.

SVRMGR> set transaction use rollback segment r01; -- r01 used for next txn
Statement processed.

SVRMGR> insert into test01 values (3); -- Note this row is not committed
1 row processed.

SVRMGR> shutdown abort -- Note one uncommitted row when instance crashed
ORACLE instance shut down.
SVRMGR> rem Removing datafile comprising rbs tablespace...

SVRMGR> host
$ rm $HOME/data/rbs01.dbf -- All database files in rbs tablespace removed
$ exit

SVRMGR> startup pfile=$HOME/data/initDB15.ora


ORACLE instance started.
Total System Global Area 4436296 bytes
Fixed Size 39732 bytes
Variable Size 3876372 bytes
Database Buffers 512000 bytes
Redo Buffers 8192 bytes
Database mounted.
ORA-01157: cannot identify data file 2 - file not found

5
Global IT Standard Operating Procedures

ORA-01110: data file 2: '/dbaclass7/dba15/data/rbs01.dbf'


SVRMGR> rem Taking the missing datafile offline...

SVRMGR> alter database datafile '$HOME/data/rbs01.dbf' offline;


Statement processed.
SVRMGR> alter database open;
alter database open
*
ORA-01545: rollback segment 'R01' specified not available
SVRMGR> rem We did not comment-out rollback_segments in init.ora

SVRMGR> shutdown abort


ORACLE instance shut down.

(Commented-out rollback_segments parameter in init.ora)

SVRMGR> startup mount pfile=$HOME/data/initDB15.ora


ORACLE instance started.
Total System Global Area 4436296 bytes
Fixed Size 39732 bytes
Variable Size 3876372 bytes
Database Buffers 512000 bytes
Redo Buffers 8192 bytes
Database mounted.

SVRMGR> alter database datafile '$HOME/data/rbs01.dbf' offline;


Statement processed.

SVRMGR> alter database open;


Statement processed.

SVRMGR> select * from test01;


COL1
----------
ORA-00376: file 2 cannot be read at this time
ORA-01110: data file 2: '/dbaclass7/dba15/data/rbs01.dbf'
SVRMGR> rem Cannot read test01 table, since Oracle does know if the last
SVRMGR> rem transaction was committed or rolled back...

SVRMGR> select segment_name,status from dba_rollback_segs;


SEGMENT_NAME STATUS
------------------------------ ----------------
SYSTEM ONLINE
R01 NEEDS RECOVERY
2 rows selected.

6
Global IT Standard Operating Procedures

SVRMGR> host
$ cp $HOME/backup/rbs01.dbf $HOME/data -- Restoring backup rbs01.dbf
$ exit

SVRMGR> recover tablespace rbs;


ORA-00279: Change 7292 generated at 04/25/97 17:43:26 needed for thread 1
ORA-00289: Suggestion : /dbaclass7/dba15/log/arch_348.arc
ORA-00280: Change 7292 for thread 1 is in sequence #348
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
Log applied.
ORA-00279: Change 7317 generated at 04/25/97 18:32:28 needed for thread 1
ORA-00289: Suggestion: /dbaclass7/dba15/log/arch_349.arc
ORA-00280: Change 7317 for thread 1 is in sequence #349
ORA-00278: Logfile '/dbaclass7/dba15/log/arch_348.arc' no longer needed
Log applied.
Media recovery complete.

SVRMGR> alter tablespace rbs online;


Statement processed.

SVRMGR> select * from test01; -- recovery worked (uncommitted txn not found)
COL1
----------
1
2
2 rows selected.

SVRMGR> select segment_name,status from dba_rollback_segs;


SEGMENT_NAME STATUS
------------------------------ ----------------
SYSTEM ONLINE
R01 NEEDS RECOVERY
2 rows selected.

SVRMGR> alter rollback segment r01 online; -- Must bring rollback segs online
Statement processed.

SVRMGR> select segment_name,status from dba_rollback_segs;


SEGMENT_NAME STATUS
------------------------------ ----------------
SYSTEM ONLINE
R01 ONLINE
2 rows selected.

7
Global IT Standard Operating Procedures

4. LOSS OF ONLINE REDO LOGS AND DATABASE RECOVERY

SVRMGR> alter system switch logfile;


Statement processed.

SVRMGR> archive log list


Database log mode Archive Mode
Automatic archival Enabled
Archive destination /dbaclass7/dba15/log/arch
Oldest online log sequence 366
Next log sequence to archive 367
Current log sequence 367

SVRMGR> shutdown abort -- Crashing instance and removing all online redo logs…
ORACLE instance shut down.

SVRMGR> host
$ rm *.rdo
$ exit

SVRMGR> startup pfile=$HOME/data/initDB15.ora


ORACLE instance started.
Total System Global Area 4436296 bytes
Fixed Size 39732 bytes
Variable Size 3876372 bytes
Database Buffers 512000 bytes
Redo Buffers 8192 bytes
Database mounted.
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/dbaclass7/dba15/data/log1a.rdo'
ORA-07360: sfifi: stat error, unable to obtain information about file.
SVR4 Error: 2: No such file or directory

SVRMGR> shutdown abort


ORACLE instance shut down.

SVRMGR> host
$ cp ../backup/*.dbf . -- Restoring all datafiles (but not old redo logs)
$ exit

SVRMGR> startup mount pfile=$HOME/data/initDB15.ora


ORACLE instance started.
Total System Global Area 4436296 bytes
Fixed Size 39732 bytes
Variable Size 3876372 bytes
Database Buffers 512000 bytes

8
Global IT Standard Operating Procedures

Redo Buffers 8192 bytes


Database mounted.

SVRMGR> recover database until cancel;


ORA-00279: Change 7340 generated at 04/25/97 18:51:14 needed for thread 1
ORA-00289: Suggestion : /dbaclass7/dba15/log/arch_351.arc
ORA-00280: Change 7340 for thread 1 is in sequence #351
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
Log applied.
ORA-00279: Change 7395 generated at 04/25/97 19:25:40 needed for thread 1
ORA-00289: Suggestion : /dbaclass7/dba15/log/arch_352.arc
ORA-00280: Change 7395 for thread 1 is in sequence #352
ORA-00278: Logfile '/dbaclass7/dba15/log/arch_351.arc' no longer needed
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
Log applied.
ORA-00279: Change 7399 generated at 04/25/97 19:25:47 needed for thread 1
ORA-00289: Suggestion : /dbaclass7/dba15/log/arch_353.arc
ORA-00280: Change 7399 for thread 1 is in sequence #353
ORA-00278: Logfile '/dbaclass7/dba15/log/arch_352.arc' no longer needed
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
Log applied.
.
.
.
ORA-00279: Change 7447 generated at 04/25/97 19:30:23 needed for thread 1
ORA-00289: Suggestion : /dbaclass7/dba15/log/arch_367.arc
ORA-00280: Change 7447 for thread 1 is in sequence #367
ORA-00278: Logfile '/dbaclass7/dba15/log/arch_366.arc' no longer needed
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.

SVRMGR> alter database open resetlogs;


Statement processed.
Server Manager complete.

$ ls -- Note that Oracle automatically rebuilt the *.rdo files!


appl01.dbf initDB15_0.ora log2a.rdo system01.dbf
cntrlDBA15.ctl initDBA15.ora query01.dbf temp01.dbf
initDB15.ora log1a.rdo rbs01.dbf user01.dbf

9
Global IT Standard Operating Procedures

5. BACKUP CONTROL FILES, ONLINE REDO LOGS, AND DATABASE RECOVERY

SVRMGR> archive log list


Database log mode Archive Mode
Automatic archival Enabled
Archive destination /dbaclass7/dba15/log/arch
Oldest online log sequence 7
Next log sequence to archive 8
Current log sequence 8

SVRMGR> create table system.test01 (col number) tablespace appl_data;


Statement processed.
SVRMGR> insert into system.test01 values (11);
1 row processed.
SVRMGR> insert into system.test01 values (12);
1 row processed.
SVRMGR> commit; -- This ensures that the two rows should be recovered.
Statement processed.

SVRMGR> select a.group# "Grp",a.status "Mmbr Status",


substr(b.status,1,8) "Grp Status",
substr(a.member,1,50) "Redo Logfile Member" from v$logfile a,v$log b
where a.group#=b.group#; -- Note that Group 1 is the current redo log
Grp Mmbr St Grp Stat Redo Logfile Member
---------- ------- -------- --------------------------------------------------
1 CURRENT /dbaclass7/dba15/data/log1a.rdo
2 INACTIVE /dbaclass7/dba15/data/log2a.rdo
2 rows selected.

SVRMGR> shutdown abort -- We crashed the instance


ORACLE instance shut down.

SVRMGR> !rm /dbaclass7/dba15/data/cntrlDBA15.ctl

SVRMGR> !cp $HOME/backup/cntrlDBA15.ctl $HOME/data -- Backup controlfile

SVRMGR> startup mount pfile=initDB15.ora


ORACLE instance started.
Total System Global Area 4436772 bytes
Fixed Size 39696 bytes
Variable Size 3876884 bytes
Database Buffers 512000 bytes
Redo Buffers 8192 bytes
Database mounted.

10
Global IT Standard Operating Procedures

SVRMGR> alter database open; -- Fails since we’re using an old controlfile
alter database open
*
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/dbaclass7/dba15/data/system01.dbf'
ORA-01207: file is more recent than control file - old control file

SVRMGR> recover database -- Wrong syntax used when using a backup controlfile
ORA-00283: Recovery session canceled due to errors
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/dbaclass7/dba15/data/system01.dbf'
ORA-01207: file is more recent than control file - old control file

SVRMGR> recover database using backup controlfile;


ORA-00279: Change 7204 generated at 05/27/97 16:22:43 needed for thread 1
ORA-00289: Suggestion : /dbaclass7/dba15/log/arch_6.arc
ORA-00280: Change 7204 for thread 1 is in sequence #6
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
Log applied.
ORA-00279: Change 7229 generated at 05/27/97 22:07:31 needed for thread 1
ORA-00289: Suggestion : /dbaclass7/dba15/log/arch_7.arc
ORA-00280: Change 7229 for thread 1 is in sequence #7
ORA-00278: Logfile '/dbaclass7/dba15/log/arch_6.arc' no longer needed for this y
Log applied.
ORA-00279: Change 7231 generated at 05/27/97 22:07:38 needed for thread 1
ORA-00289: Suggestion : /dbaclass7/dba15/log/arch_8.arc
ORA-00280: Change 7231 for thread 1 is in sequence #8
ORA-00278: Logfile '/dbaclass7/dba15/log/arch_7.arc' no longer needed for this y
ORA-00308: cannot open archived log '/dbaclass7/dba15/log/arch_8.arc'
ORA-07360: sfifi: stat error, unable to obtain information about file.
SVR4 Error: 2: No such file or directory

SVRMGR> recover database using backup controlfile;


ORA-00279: Change 7231 generated at 05/27/97 22:07:38 needed for thread 1
ORA-00289: Suggestion : /dbaclass7/dba15/log/arch_8.arc
ORA-00280: Change 7231 for thread 1 is in sequence #8
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/dbaclass7/dba15/data/log1a.rdo -- We specify the current logfile to apply
Log applied.
Media recovery complete.

SVRMGR> alter database open; -- Wrong syntax, must use RESETLOGS


alter database open
*
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

SVRMGR> alter database open resetlogs;


Statement processed.

11
Global IT Standard Operating Procedures

SVRMGR> archive log list


Database log mode Archive Mode
Automatic archival Enabled
Archive destination /dbaclass7/dba15/log/arch
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1

SVRMGR> select * from system.test01; -- As expected, we recover both rows!


COL
----------
11
12
2 rows selected.

SVRMGR> select file#,status,enabled, substr(name,1,40) "FILE" from


2> v$datafile;
FILE# STATUS ENABLED FILE
---------- ------- ---------- ----------------------------------------
1 SYSTEM READ WRITE /dbaclass7/dba15/data/system01.dbf
2 ONLINE READ WRITE /dbaclass7/dba15/data/rbs01.dbf
3 ONLINE READ WRITE /dbaclass7/dba15/data/appl01.dbf
4 ONLINE READ WRITE /dbaclass7/dba15/data/user01.dbf
5 ONLINE READ WRITE /dbaclass7/dba15/data/temp01.dbf
6 ONLINE READ ONLY /dbaclass7/dba15/data/query01.dbf
6 rows selected.

6. USING LOGMINER TO FIND TIMESTAMP THAT A TABLE WAS DROPPED

Note: The scenario below shows how we can use LogMiner to identify the exact time that a table was dropped. The
timestamp can then be used for doing a point-in-time recovery.

Check Metalink Note 93370.1 for additional details regarding this process. Since LogMiner can only be run against
Oracle8 and Oracle8i redo logs, this scenario does not apply to Oracle7 databases.

SQL> drop table kurt.testtbl; -- Tragedy! We dropped table TESTTBL by mistake…


Statement processed.

SQL> alter system switch logfile;


Statement processed.

SQL> alter system switch logfile;


Statement processed.
.
.
.

12
Global IT Standard Operating Procedures

SQL> show parameter utl_file_dir –- Location where we will build the dictionary file
NAME TYPE VALUE
----------------------------------- ------- --------------------------
utl_file_dir string /dbaclass2/teach7

SQL> !date –- Here’s the time that we started our LogMiner analysis…
Wed May 2 08:56:04 PDT 2001

SQL> execute dbms_logmnr_d.build('logdict','/dbaclass2/teach7');


Statement processed.

SQL> !ls -l $HOME/ARCHIVE –- We’ll analyze the logs since 12:00pm…


total 7408
-rw-rw---- 1 ora815 user7 1590784 May 1 13:13 arch_T7_10.arc
-rw-rw---- 1 ora815 user7 1024 May 1 13:13 arch_T7_11.arc
-rw-rw---- 1 ora815 user7 1024 May 1 13:13 arch_T7_12.arc
-rw-rw---- 1 ora815 user7 1024 May 1 13:14 arch_T7_13.arc
-rw-rw---- 1 ora815 user7 14336 Apr 30 09:06 arch_T7_3.arc
-rw-rw---- 1 ora815 user7 2048 Apr 30 09:06 arch_T7_4.arc
-rw-rw---- 1 ora815 user7 1024 Apr 30 09:06 arch_T7_5.arc
-rw-rw---- 1 ora815 user7 3072 Apr 30 11:27 arch_T7_6.arc
-rw-rw---- 1 ora815 user7 1024 Apr 30 13:50 arch_T7_7.arc
-rw-rw---- 1 ora815 user7 14848 Apr 30 16:05 arch_T7_8.arc
-rw-rw---- 1 ora815 user7 2097664 May 1 12:03 arch_T7_9.arc

SQL> execute dbms_logmnr.add_logfile -


> ('/dbaclass2/teach7/ARCHIVE/arch_T7_9.arc',dbms_logmnr.NEW);

PL/SQL procedure successfully completed.

SQL> execute dbms_logmnr.add_logfile -


> ('/dbaclass2/teach7/ARCHIVE/arch_T7_10.arc',dbms_logmnr.addfile);

PL/SQL procedure successfully completed.

SQL> execute dbms_logmnr.add_logfile -


> ('/dbaclass2/teach7/ARCHIVE/arch_T7_11.arc',dbms_logmnr.addfile);

PL/SQL procedure successfully completed.

SQL> execute dbms_logmnr.add_logfile -


> ('/dbaclass2/teach7/ARCHIVE/arch_T7_12.arc',dbms_logmnr.addfile);

PL/SQL procedure successfully completed.

SQL> execute dbms_logmnr.add_logfile -


> ('/dbaclass2/teach7/ARCHIVE/arch_T7_13.arc',dbms_logmnr.addfile);

PL/SQL procedure successfully completed.

SQL> execute dbms_logmnr.start_logmnr(-

13
Global IT Standard Operating Procedures

> dictfilename=>'/dbaclass2/teach7/logdict');

PL/SQL procedure successfully completed.

SQL> create table logmnr_tbl –- An interim table to store LogMiner analysis results…
2 as select * from v$logmnr_contents
3 where operation='DELETE'
4 and seg_name in ('COL$','OBJ$','TAB$');

Table created.

SQL> select substr(seg_name,1,15) "SEG", -- Same SCN shows up for OBJ$,TAB$, and COL$
2 substr(operation,1,10) "OP",
3 scn,count(*)
4 from logmnr_tbl
5 where operation != 'INTERNAL'
6 group by seg_name,operation,scn
7 order by scn;

SEG OP SCN COUNT(*)


--------------- ---------- ---------- ----------
COL$ DELETE 147015 8
OBJ$ DELETE 147015 1
TAB$ DELETE 147015 1

SQL> select sql_redo from logmnr_tbl –- Note that ‘TESTTBL’ shows up for this SCN!
2 where scn=147015
3 and seg_name='OBJ$';

SQL_REDO
-----------------------------------------------------------------------
delete from SYS.OBJ$ where OBJ# = 4891 and DATAOBJ# = 4891 and OWNER# = 52 and NAME = 'TESTTBL'
and NAMESPACE = 1 and SUBNAME IS NULL and TYPE# = 2 and CTIME =TO_DATE('01-MAY-2001
12:04:25', 'DD-MON-YYYY HH24:MI:SS') and MTIME = TO_DATE('01-MAY-2001 12:04:25', 'DD-MON-
YYYY HH24:MI:SS') and STIME = TO_DATE('01-MAY-2001 12:04:25', 'DD-MON-YYYY HH24:MI:SS') and
STATUS = 1 and REMOTEOWNER IS NULL and LINKNAME IS NULL and FLAGS = 0 and ROWID =
'AAAAASAABAAAEYYAAn';

SQL> select distinct –- Here it is: the time that TESTTBL was dropped (1:13pm)!
2 to_char(timestamp,'DD-MON-YYYY HH24:MI:SS') "TIME"
3 from logmnr_tbl
4 where scn=147015;

TIME
--------------------
01-MAY-2001 13:13:16

SQL> shutdown immediate


Database closed.
Database dismounted.
ORACLE instance shut down.

14
Global IT Standard Operating Procedures

SQL> host –- We restore all datafiles for doing the PITR

teach7 ksh > cp -rp $HOME/BACKUP/DISK1/*.dbf $HOME/DATA/DISK1


teach7 ksh > cp -rp $HOME/BACKUP/DISK2/*.dbf $HOME/DATA/DISK2
teach7 ksh > cp -rp $HOME/BACKUP/DISK3/*.dbf $HOME/DATA/DISK3
teach7 ksh > cp -rp $HOME/BACKUP/DISK4/*.dbf $HOME/DATA/DISK4
teach7 ksh > cp -rp $HOME/BACKUP/DISK5/*.dbf $HOME/DATA/DISK5
teach7 ksh > cp -rp $HOME/BACKUP/DISK6/*.dbf $HOME/DATA/DISK6
teach7 ksh > exit

SQL> startup mount –- We’re ready to do the PITR using our timestamp from LogMiner
ORACLE instance started.

Total System Global Area 23182736 bytes


Fixed Size 64912 bytes
Variable Size 21397504 bytes
Database Buffers 1638400 bytes
Redo Buffers 81920 bytes
Database mounted.

SQL> recover database until time '2001-05-01:13:12:00';


ORA-00279: change 147005 generated at 05/01/01 12:04:48 needed for thread 1
ORA-00289: suggestion : /dbaclass2/teach7/ARCHIVE/arch_T7_06.arc
ORA-00280: change 147005 for thread 1 is in sequence #10

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}


auto
Log applied.
.
.
.
Media recovery complete.

SQL> alter database open resetlogs; -- RESETLOGS required after PITR

Database altered.

SQL> desc kurt.testtbl –- Victory! TESTTBL and its 5600 rows are back!
Name Null? Type
----------------------------------------- -------- ----------------------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)

15
Global IT Standard Operating Procedures

DEPTNO NOT NULL NUMBER(2)

SQL> select count(*) from kurt.testtbl;

COUNT(*)
----------
5600

16

Das könnte Ihnen auch gefallen