|
|
手痒痒,循着大师的脚步,再走一遍, archive模式下,最新版本10.2.0, 
SQL> host cat /etc/redhat-release
Red Hat Enterprise Linux ES release 3 (Taroon Update 5)
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 0
Next log sequence to archive 1
Current log sequence 1
打开了两个窗口,Session A, Session B
--Session A
SQL> conn / as sysdba
Connected.
SQL> ls
SP2-0042: unknown command "ls" - rest of line ignored.
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 4
Next log sequence to archive 6
Current log sequence 6
SQL> alter database backup controlfile to trace as '/tmp/ctl.trc';
Database altered.
SQL> conn hr/hr
Connected.
SQL> create table t (c1 number);
Table created.
SQL> insert into t values (1);
1 row created.
SQL> commit;
Commit complete.
SQL> insert into t values(2);
1 row created.
--Session B
SQL> conn / as sysdba
Connected.
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 281018368 bytes
Fixed Size 1218944 bytes
Variable Size 83887744 bytes
Database Buffers 188743680 bytes
Redo Buffers 7168000 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS ARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '/opt/oracle10g/oradata/orcl/redo01.log' SIZE 50M,
9 GROUP 2 '/opt/oracle10g/oradata/orcl/redo02.log' SIZE 50M,
10 GROUP 3 '/opt/oracle10g/oradata/orcl/redo03.log' SIZE 50M
11 DATAFILE
12 '/opt/oracle10g/oradata/orcl/system01.dbf',
13 '/opt/oracle10g/oradata/orcl/undotbs01.dbf',
14 '/opt/oracle10g/oradata/orcl/sysaux01.dbf',
15 '/opt/oracle10g/oradata/orcl/users01.dbf',
16 '/opt/oracle10g/oradata/orcl/example01.dbf'
17 CHARACTER SET WE8ISO8859P1
18 ;
Control file created.
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 509286 generated at 01/17/2006 00:00:47 needed for thread 1
ORA-00289: suggestion :
/opt/oracle10g/flash_recovery_area/ORCL/archivelog/2006_01_17/o1_mf_1_6_%u_.arc
ORA-00280: change 509286 for thread 1 is in sequence #6
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
ORA-00283: recovery session canceled due to errors
ORA-19906: recovery target incarnation changed during recovery
ORA-01112: media recovery not started
--检查一下archive log 日志, 发现没有需要用来恢复的archive log
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 281018368 bytes
Fixed Size 1218944 bytes
Variable Size 83887744 bytes
Database Buffers 188743680 bytes
Redo Buffers 7168000 bytes
Database mounted.
--重启启动,再恢复的时候发现Oracle搞不清楚数据文件时哪个incarnation了,这大概时10.2.0的特性吧, 
SQL> recover database using backup controlfile until cancel;
ORA-00283: recovery session canceled due to errors
ORA-19909: datafile 1 belongs to an orphan incarnation
ORA-01110: data file 1: '/opt/oracle10g/oradata/orcl/system01.dbf'
SQL> recover database using backup controlfile until cancel;
ORA-00283: recovery session canceled due to errors
ORA-19909: datafile 1 belongs to an orphan incarnation
ORA-01110: data file 1: '/opt/oracle10g/oradata/orcl/system01.dbf'
--再从来一次,这次先找到正确的redolog,告诉oracle去恢复
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 281018368 bytes
Fixed Size 1218944 bytes
Variable Size 83887744 bytes
Database Buffers 188743680 bytes
Redo Buffers 7168000 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS ARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '/opt/oracle10g/oradata/orcl/redo01.log' SIZE 50M,
9 GROUP 2 '/opt/oracle10g/oradata/orcl/redo02.log' SIZE 50M,
10 GROUP 3 '/opt/oracle10g/oradata/orcl/redo03.log' SIZE 50M
11 DATAFILE
12 '/opt/oracle10g/oradata/orcl/system01.dbf',
13 '/opt/oracle10g/oradata/orcl/undotbs01.dbf',
14 '/opt/oracle10g/oradata/orcl/sysaux01.dbf',
15 '/opt/oracle10g/oradata/orcl/users01.dbf',
16 '/opt/oracle10g/oradata/orcl/example01.dbf'
17 CHARACTER SET WE8ISO8859P1
18 ;
Control file created.
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIM
------------- ---------
1 1 5 52428800 1 NO INACTIVE
483602 16-JAN-06
3 1 4 52428800 1 NO INACTIVE
483593 16-JAN-06
2 1 6 52428800 1 NO CURRENT
509286 17-JAN-06
--发现第二组log是current的状态
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 509286 generated at 01/17/2006 00:00:47 needed for thread 1
ORA-00289: suggestion :
/opt/oracle10g/flash_recovery_area/ORCL/archivelog/2006_01_17/o1_mf_1_6_%u_.arc
ORA-00280: change 509286 for thread 1 is in sequence #6
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/opt/oracle10g/oradata/orcl/redo02.log --告诉oracle用第二组的log恢复
Log applied.
Media recovery complete.
--成功! 恢复完成, 下面打开数据库
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open noresetlogs;
alter database open noresetlogs
*
ERROR at line 1:
ORA-01588: must use RESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.
--发现只能用resetlog来打开,因为当前控制文件是新建的。除非与控制文件匹配的redo log没有损坏,才可以用noresetlogs打开。
关键:1.要有创建控制文件的trace, 如果没有也可以模仿相同环境下的DB写出。 2. Redo log 没有损坏。如果Redo 损坏就没有办法恢复了 |
|