20121225_不完全恢复记录(rman)

来源:互联网 发布:杭州淘宝tnt摄影基地 编辑:程序博客网 时间:2024/05/22 12:15

restore controlfile from '/orabak/AutoCtl_SGERP5_20121222_c-3580899532-20121222-00';
oracle:srvctl add database -d sgerp5 -o /u01/app/product/11.2

--检查备份状态目录权限


rman:list backup;
P550:/u01/app/product/11.2/dbs$ls -l /orabak
total 0
-rwxrwxrwx    1 oracle   oinstall    8617984 Dec 19 15:34 AutoCtl_SGERP5_20121219_c-3580899532-20121219-00
-rwxrwxrwx    1 oracle   oinstall 37172420608 Dec 19 16:46 DB0_SGERP5_20121218_117_802385526
-rwxrwxrwx    1 oracle   oinstall 37908504576 Dec 19 17:00 DB0_SGERP5_20121218_118_802385526
-rwxrwxrwx    1 oracle   oinstall 38412795904 Dec 19 17:12 DB0_SGERP5_20121218_119_802385526
-rwxrwxrwx    1 oracle   oinstall 36120494080 Dec 19 17:22 DB0_SGERP5_20121218_120_802385527
-rwxrwxrwx    1 oracle   oinstall 37474779136 Dec 19 17:36 DB0_SGERP5_20121218_121_802385527
drwxrwxrwx    2 oracle   oinstall        256 Dec 19 12:11 lost+found
P550:/u01/app/product/11.2/dbs$

run{
allocate channel cha1 type disk;
allocate channel cha2 type disk;
allocate channel cha3 type disk;
allocate channel cha4 type disk;
allocate channel cha5 type disk;
set until time= "to_date('2013-05-26 02:31:21', 'yyyy-mm-dd hh24:mi:ss')";
restore database;
recover database;
sql 'alter database open resetlogs';
release channel cha1;
release channel cha2;
release channel cha3;
release channel cha4;
release channel cha5;
}

 

--修改IP后:
ALTER SYSTEM SET local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=129.100.253.70)(PORT=1521))))' SCOPE=MEMORY SID='sgerp5';


catalog start with '/orabak/INCR1_SGERP5_20121223_131_802742712';
catalog start with '/orabak/INCR1_SGERP5_20121223_132_802742712';
catalog start with '/orabak/INCR1_SGERP5_20121223_133_802742712';
catalog start with '/orabak/INCR1_SGERP5_20121223_134_802742713';
catalog start with '/orabak/INCR1_SGERP5_20121223_135_802742726';

catalog start with '/orabak/INCR1_SGERP5_20121224_137_802829116';
catalog start with '/orabak/INCR1_SGERP5_20121224_138_802829116';
catalog start with '/orabak/INCR1_SGERP5_20121224_139_802829117';
catalog start with '/orabak/INCR1_SGERP5_20121224_140_802829119';
catalog start with '/orabak/INCR1_SGERP5_20121224_141_802829136';

--检查状态


crosscheck backup;
list backup;
list incarnation;


RMAN> recover database using backup controlfile;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "using": expecting one of: "allow, archivelog, auxiliary, check, clear, delete, exclude, from, high, noparallel, noredo, parallel, preview, restore, skip readonly, skip, tablespace, test, to restore point, undo, until restore point, until, validate, ;"
RMAN-01007: at line 1 column 18 file: standard input

RMAN> recover database;
Starting recover at 2012-12-21 00:14:27
using channel ORA_DISK_1

run{
allocate channel cha1 type disk;
allocate channel cha2 type disk;
allocate channel cha3 type disk;
allocate channel cha4 type disk;
allocate channel cha5 type disk;

recover database;

release channel cha1;
release channel cha2;
release channel cha3;
release channel cha4;
release channel cha5;
}

 

--scn 必须都一至

select file#,to_char(checkpoint_change#,'999999999999999') "SCN",    to_char(last_change#,'999999999999999')"STOP_SCN" from v$datafile;

select file#,to_char(checkpoint_change#,'999999999999999') "SCN" from v$datafile_header;
  

select min(to_char(checkpoint_change#,'999999999999999')) "MIN_SCN",
max(to_char(checkpoint_change#,'999999999999999')) "MAX_SCN"
from v$datafile;

select min(to_char(checkpoint_change#,'999999999999999')) "MIN_SCN",
max(to_char(checkpoint_change#,'999999999999999')) "MAX_SCN"
from v$datafile_header;

 

select min(to_char(checkpoint_change#,'999999999999999')) "MIN_SCN",
max(to_char(checkpoint_change#,'999999999999999')) "MAX_SCN"
from v$datafile;

select min(to_char(checkpoint_change#,'999999999999999')) "MIN_SCN",
max(to_char(checkpoint_change#,'999999999999999')) "MAX_SCN"
from v$datafile_header;

 


channel cha4: reading from backup piece /orabak/INCR1_SGERP5_20121224_141_802829136
channel cha2: piece handle=/orabak/INCR1_SGERP5_20121224_137_802829116 tag=TAG20121224T000513
channel cha2: restored backup piece 1
channel cha2: restore complete, elapsed time: 00:18:37
channel cha1: piece handle=/orabak/INCR1_SGERP5_20121224_138_802829116 tag=TAG20121224T000513
channel cha1: restored backup piece 1
channel cha1: restore complete, elapsed time: 00:21:44
channel cha3: piece handle=/orabak/INCR1_SGERP5_20121224_140_802829119 tag=TAG20121224T000513
channel cha3: restored backup piece 1
channel cha3: restore complete, elapsed time: 00:20:38
channel cha4: piece handle=/orabak/INCR1_SGERP5_20121224_141_802829136 tag=TAG20121224T000513
channel cha4: restored backup piece 1
channel cha4: restore complete, elapsed time: 00:18:09

starting media recovery

unable to find archived log
archived log thread=1 sequence=36
released channel: cha1
released channel: cha2
released channel: cha3
released channel: cha4
released channel: cha5
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 12/25/2012 11:38:15
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 36 and starting SCN of 140692588

RMAN>
这里是提醒恢复到一个未知的scn号。在alter database mount之后,通过set until scn或者set until time命令设置恢复到的scn号或时间。
就可以避免这个错误。

 


--1

SQL> recover database using backup controlfile until cancel;
ORA-00279: change 140692588 generated at 12/22/2012 02:59:39 needed for thread 1
ORA-00289: suggestion : /oraarch/ARC_ERP5_36_802575121_1.log
ORA-00280: change 140692588 for thread 1 is in sequence #36

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '+DATA/sgerp5/datafile/system.403.802930817'


ORA-01112: media recovery not started


SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '+DATA/sgerp5/datafile/system.403.802930817'


SQL>

alter database backup controlfile to trace as '/orabak/ctl_34.txt';
recover database until SEQUENCE 36 thread 1;
select status, INSTANCE_ROLE from v$instance;

 

--2


sgerp:/u01/db/product/11.2/dbs$sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Tue Dec 25 12:42:00 2012

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options

SQL> create spfile from pfile;

File created.

SQL> shutdown immediate;
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.


SQL> startup nomount;
ORACLE instance started.

Total System Global Area 3.7413E+10 bytes
Fixed Size                  2229304 bytes
Variable Size            2.0401E+10 bytes
Database Buffers         1.6911E+10 bytes
Redo Buffers               98418688 bytes
SQL> alter system set "_allow_resetlogs_corruption"=true scope=spfile;

System altered.

SQL> shutdown immediate;
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 3.7413E+10 bytes
Fixed Size                  2229304 bytes
Variable Size            2.0670E+10 bytes
Database Buffers         1.6643E+10 bytes
Redo Buffers               98418688 bytes
Database mounted.
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-00704: bootstrap process failure
ORA-00604: error occurred at recursive SQL level 1
ORA-01555: snapshot too old: rollback segment number 14 with name
"_SYSSMU14_1920655645$" too small
Process ID: 16252992
Session ID: 898 Serial number: 3


SQL>

Solution:

ALTER TABLESPACE UNDOTBS1 RETENTION NOGUARANTEE;
ALTER SYSTEM SET undo_retention=60 SCOPE=BOTH;
alter tablespace undotbs1 offline imeediate;

alter system dump undo header '_SYSSMU14_1920655645$';

*.undo_management='MANUAL'
*._offline_rollback_segments=(_SYSSMU14$)

*._offline_rollback_segments=true
*._corrupted_rollback_segments=(_SYSSMU14$)

ALTER DATABASE DATAFILE '+DATA/sgerp5/datafile/undotbs1.292.802536203' OFFLINE;
ALTER DATABASE DATAFILE 3 OFFLINE drop;
ALTER DATABASE DATAFILE 3 ONLINE;

上一篇文章中尝试使用隐含参数_offline_rollback_segments来打开数据库,这里还可以选择将UNDO表空间的数据文件直接删除,
然后使用_corrupted_rollback_segments参数来打开数据库,整个过程于上一篇介绍的方法类似。
SQL> STARTUP MOUNT
ORACLE例程已经启动。
Total System Global Area   76619308 bytes
F0Fixed Size                 454188 bytes
Variable Size              50331648 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
数据库装载完毕。
SQL> ALTER DATABASE OPEN;

 

此时数据库仍然尝试去恢复57号回滚段,由于已经强制将该回滚段Offline,此时可以将损坏的回滚段删除:

SQL> drop rollback segment "_SYSSMU14$";
Rollback segment dropped.
此时继续观察alert文件,之前的错误不再出现。
SQL> DROP TABLESPACE UNDOTBS1 INCLUDING CONTENTS AND DATAFILES;
表空间已丢弃。
SQL> CREATE UNDO TABLESPACE UNDOTBS1 DATAFILE 'F:\ORACLE\ORADATA\TEST\UNDOTBS1.DBF' SIZE200M;
表空间已创建。
SQL> SELECT COUNT(*) FROM


#shutdown immediate;
#startup
##alter system  datafile 2 offline;
更改隐参
startup nomount
select ksppinm from x$ksppi where ksppinm like '%roll%'
alter system set "_offline_rollback_segments"=true scope=spfile;
alter system set undo_management=manual scope=spfile(将Undo表空间改为手动管理,好处是回滚段可以手动分配)
再启动数据库
然后将隐参改回,Undo 表空间改为自动管理,删除损坏的undo 表空间,建立新的表空间
atter system reset "_offline_rollback_segments" scope=spfile sid='*';
atter system reset "_offline_rollback_segments"=false scope=spfile ;
总结
undo 没有备份
1、设置参数Undo_management=manual
更改undo_tablespace=其他的可用undo、将隐参"_offline_rollback_segments"=true
2.启动mount
3.将损坏undo数据文件脱机
4.alter database open;
5 看dba_rollback_segs 中的status---损坏的表空间的段是否有recover字段 如果有则使用_corrupted_rollback_segments
6.删除损坏的undo,建立删除的undo
7.还原1步中参数设置,取消隐参
8.启动数据库


alter database backup controlfile to trace as '/orabak/ctl_24.txt';

 

 

--3


_minimum_giga_scn=1
select ksppinm,ksppdesc from x$ksppi where ksppinm like '%giga%'

SCN: 0x0000.0864532b

select to_number('0864532b','xxxxxxxxxxxx') scn from dual;

SQL> select checkpoint_change# from v$database;

CHECKPOINT_CHANGE#
------------------
         140792617

SQL> select to_number('0864532b','xxxxxxxxxxxx') scn from dual;

       SCN
----------
 140792619

SQL>
select 140792619/1024/1024/1024 giga from dual;

*._allow_error_simulation=TRUE
*._minimum_giga_scn=1047


alter session set events '10015 trace name ADJUST_SCN level 140792619';
 

 
 
 
 
 --4


 SQL> startup mount;
ORACLE instance started.

Total System Global Area 3.7413E+10 bytes
Fixed Size                  2229304 bytes
Variable Size            2.0401E+10 bytes
Database Buffers         1.6911E+10 bytes
Redo Buffers               98418688 bytes
Database mounted.
SQL> oradebug setmypid
Statement processed.
SQL> oradebug EVENT 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12
Statement processed.
SQL> oradebug TRACEFILE_NAME
/u01/db/diag/rdbms/sgerp5/sgerp5/trace/sgerp5_ora_16253004.trc
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01092: ORACLE instance terminated. Disconnection forced
ORA-00704: bootstrap process failure
ORA-00704: bootstrap process failure
ORA-00604: error occurred at recursive SQL level 1
ORA-01555: snapshot too old: rollback segment number 14 with name "_SYSSMU14_1920655645$" too small
Process ID: 16253004
Session ID: 937 Serial number: 3


SQL>

 

alter_log:
Tue Dec 25 21:22:11 2012
ORA-01555 caused by SQL statement below (SQL ID: 4krwuz0ctqxdt, SCN: 0x0000.08653d9a):
select ctime, mtime, stime from obj$ where obj# = :1
Errors in file /u01/db/diag/rdbms/sgerp5/sgerp5/trace/sgerp5_ora_16253004.trc:
ORA-00704: bootstrap process failure
ORA-00704: bootstrap process failure
ORA-00604: error occurred at recursive SQL level 1
ORA-01555: snapshot too old: rollback segment number 14 with name "_SYSSMU14_1920655645$" too small
Errors in file /u01/db/diag/rdbms/sgerp5/sgerp5/trace/sgerp5_ora_16253004.trc:
ORA-00704: bootstrap process failure
ORA-00704: bootstrap process failure
ORA-00604: error occurred at recursive SQL level 1
ORA-01555: snapshot too old: rollback segment number 14 with name "_SYSSMU14_1920655645$" too small
Tue Dec 25 21:22:11 2012
ARC2 started with pid=67, OS id=9175218
Error 704 happened during db open, shutting down database
USER (ospid: 16253004): terminating the instance due to error 704
Instance terminated by USER, pid = 16253004
ORA-1092 signalled during: alter database open...
opiodr aborting process unknown ospid (16253004) as a result of ORA-1092
Tue Dec 25 21:22:13 2012
ORA-1092 : opitsk aborting process

原创粉丝点击