Oracle Undo tablespace恢复(无备份)

Oracle Undo tablespace恢复

系统环境:

  操作系统:RedHat EL55

  Oracle:  Oracle 11gR2


  Oracle 9i后,采用了undo tablespace管理undo数据,实现undo的自动管理,本案例演示了undo表空间被破坏后如何恢复;如果有备份,通过备份恢复非常容易,但在没有备份的情况下,就需要采用非常规手段来恢复了,呵呵。

1、案例应用环境

undo表空间undo segments:

14:34:44 [email protected] prod>select segment_name,segment_type,tablespace_name from dba_segments
14:35:03   2  where tablespace_name=‘UNDOTBS1‘;
SEGMENT_NAME         SEGMENT_TYPE       TABLESPACE_NAME
-------------------- ------------------ ------------------------------
_SYSSMU10_3550978943$ TYPE2 UNDO        UNDOTBS1
_SYSSMU9_1424341975$ TYPE2 UNDO         UNDOTBS1
_SYSSMU8_2012382730$ TYPE2 UNDO         UNDOTBS1
_SYSSMU7_3286610060$ TYPE2 UNDO         UNDOTBS1
_SYSSMU6_2443381498$ TYPE2 UNDO         UNDOTBS1
_SYSSMU5_1527469038$ TYPE2 UNDO         UNDOTBS1
_SYSSMU4_1152005954$ TYPE2 UNDO         UNDOTBS1
_SYSSMU3_2097677531$ TYPE2 UNDO         UNDOTBS1
_SYSSMU2_2232571081$ TYPE2 UNDO         UNDOTBS1
_SYSSMU1_3780397527$ TYPE2 UNDO         UNDOTBS1
10 rows selected.
Elapsed: 00:00:00.19

模拟应用环境:

14:43:16 [email protected] prod>select count(*) from scott.emp1;
  COUNT(*)
----------
         1
Elapsed: 00:00:00.06
14:43:54 [email protected] prod>insert into scott.emp1 select * from scott.emp;
14 rows created.
Elapsed: 00:00:00.08
14:44:04 [email protected] prod>commit;
Commit complete.
Elapsed: 00:00:00.03
14:44:06 [email protected] prod>select count(*) from scott.emp1;                    
  COUNT(*)
----------
        15
Elapsed: 00:00:00.01
14:44:20 [email protected] prod>insert into scott.emp1 select * from scott.emp where rownum <4;
3 rows created.
Elapsed: 00:00:00.03
14:44:40 [email protected] prod>select count(*) from scott.emp1;   
  COUNT(*)
----------
        18
Elapsed: 00:00:00.01

关库前,事务未提交!

开启新的会话,模拟断电,将数据库非正常关闭:

[[email protected] dbs]$ sqlplus ‘/as sysdba‘

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 26 14:46:11 2014

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

14:46:12 [email protected] prod>shutdown abort;

ORACLE instance shut down.

Undo tablesapce datafile被破坏:

[[email protected] dbs]$ rm /u01/app/oracle/oradata/prod/undotbs01.dbf

2、Open database时数据库报错

[[email protected] prod]$ sqlplus ‘/as sysdba‘
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 26 14:47:26 2014
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to an idle instance.
14:47:26 [email protected] prod>startup
ORACLE instance started.
Total System Global Area  835104768 bytes
Fixed Size                  2217952 bytes
Variable Size             775948320 bytes
Database Buffers           54525952 bytes
Redo Buffers                2412544 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110: data file 3: ‘/u01/app/oracle/oradata/prod/undotbs01.dbf‘

告警日志:

ALTER DATABASE OPEN
Errors in file /u01/app/oracle/diag/rdbms/prod/prod/trace/prod_dbw0_7481.trc:
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110: data file 3: ‘/u01/app/oracle/oradata/prod/undotbs01.dbf‘
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/oracle/diag/rdbms/prod/prod/trace/prod_ora_7503.trc:
ORA-01157: cannot identify/lock data file 3 - see DBWR trace file
ORA-01110: data file 3: ‘/u01/app/oracle/oradata/prod/undotbs01.dbf‘
ORA-1157 signalled during: ALTER DATABASE OPEN...

14:47:37 [email protected] prod>show parameter undo
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_management                      string      AUTO
undo_retention                       integer     900
undo_tablespace                      string      UNDOTBS1
14:48:18 [email protected] prod>

3、在没有备份的情况下进行修复:


创建pfile:

14:48:18 [email protected] prod>create pfile from spfile;

File created.

Elapsed: 00:00:00.09

查看undo tablespace使用的undo segments:

[[email protected] dbs]$ cd /u01/app/oracle/oradata/prod/

[[email protected] prod]$ strings system01.dbf | grep _SYSSMU | cut -d $ -f 1 | sort -u

and substr(drs.segment_name,1,7) != ‘_SYSSMU‘

D‘              and substr(drs.segment_name,1,7) != ‘‘_SYSSMU‘‘ ‘ );

_SYSSMU10_3550978943

_SYSSMU10_3904554333

_SYSSMU11_286947212

_SYSSMU12_3068564564

_SYSSMU13_2761193625

_SYSSMU1_3780397527

_SYSSMU14_2421411996

_SYSSMU15_1683924174

_SYSSMU16_2313212396

_SYSSMU17_2041439332

_SYSSMU1_783380902

_SYSSMU18_2800789714

_SYSSMU19_53723967

_SYSSMU20_3850939844

_SYSSMU2_2232571081

_SYSSMU2_3138176977

_SYSSMU3_1645411166

_SYSSMU3_2097677531

_SYSSMU4_1152005954

_SYSSMU4_870421980

_SYSSMU5_1527469038

_SYSSMU5_2525172762

_SYSSMU6_2443381498

_SYSSMU6_3753507049

_SYSSMU7_1260614213

_SYSSMU7_3286610060

_SYSSMU8_2012382730

_SYSSMU8_2806087761

_SYSSMU9_1424341975

_SYSSMU9_973944058

注意:通过system01.dbf查出了,正在使用的undo segment,以上按使用时间做了排序,注意只选择那些排在最前面的(相同回滚段);默认每个undo tablespace 会应用10个undo segments。

编辑pfile,添加Oracle隐含参数,跳过undo segments的检测:

[[email protected] dbs]$ cat initprod.ora

*.undo_tablespace=‘SYSTEM‘

*.undo_management=‘MANUAL‘

*._corrupted_rollback_segments=(_SYSSMU10_3550978943$,_SYSSMU9_1424341975$,_SYSSMU8_2012382730$,_SYSSMU7_3286610060$,_SYSSMU6_2443381498$,_SYSSMU5_1527469038$,_SYSSMU4_1152005954$,_SYSSMU3_2097677531$,_SYSSMU2_2232571081$,_SYSSMU1_3780397527$)

*._allow_resetlogs_corruption=true


通过pfile启动instance:

14:56:33 [email protected] prod>startup force pfile=$ORACLE_HOME/dbs/initprod.ora

ORACLE instance started.

Total System Global Area  835104768 bytes

Fixed Size                  2217952 bytes

Variable Size             775948320 bytes

Database Buffers           54525952 bytes

Redo Buffers                2412544 bytes

Database mounted.

ORA-01157: cannot identify/lock data file 3 - see DBWR trace file

ORA-01110: data file 3: ‘/u01/app/oracle/oradata/prod/undotbs01.dbf‘

14:56:52 [email protected] prod>alter database datafile 3 offline drop;

Database altered.

14:57:11 [email protected] prod>alter database open;

Database altered.

Elapsed: 00:00:05.25

14:57:23 [email protected] prod>

告警日志:

alter database open
Beginning crash recovery of 1 threads
Started redo scan
Completed redo scan
 read 157 KB redo, 43 data blocks need recovery
Started redo application at
 Thread 1: logseq 3, block 451
Recovery of Online Redo Log: Thread 1 Group 3 Seq 3 Reading mem 0
  Mem# 0: /dsk1/oradata/prod/redo03a.log
  Mem# 1: /dsk2/oradata/prod/redo03b.log
Completed redo application of 0.04MB
Completed crash recovery at
 Thread 1: logseq 3, block 766, scn 1878512
 43 data blocks read, 43 data blocks written, 157 redo k-bytes read
Thu Jun 26 14:57:19 2014
LGWR: STARTING ARCH PROCESSES
Thu Jun 26 14:57:19 2014
ARC0 started with pid=20, OS id=7638 
ARC0: Archival started
LGWR: STARTING ARCH PROCESSES COMPLETE
ARC0: STARTING ARCH PROCESSES
Thread 1 advanced to log sequence 4 (thread open)
Thu Jun 26 14:57:20 2014
ARC1 started with pid=21, OS id=7641 
Thread 1 opened at log sequence 4
  Current log# 1 seq# 4 mem# 0: /dsk1/oradata/prod/redo01a.log
  Current log# 1 seq# 4 mem# 1: /dsk2/oradata/prod/redo01b.log
Successful open of redo thread 1
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Thu Jun 26 14:57:20 2014
SMON: enabling cache recovery
Thu Jun 26 14:57:21 2014
ARC2 started with pid=22, OS id=7643 
ARC1: Archival started
ARC2: Archival started
Thu Jun 26 14:57:21 2014
ARC2: Becoming the ‘no FAL‘ ARCH
ARC2: Becoming the ‘no SRL‘ ARCH
ARC1: Becoming the heartbeat ARCH
ARC3 started with pid=23, OS id=7645 
Archived Log entry 31 added for thread 1 sequence 3 ID 0xfaf1e60 dest 2:
Thu Jun 26 14:57:21 2014
Verifying file header compatibility for 11g tablespace encryption..
Verifying 11g file header compatibility for tablespace encryption completed
SMON: enabling tx recovery
Database Characterset is ZHS16GBK
No Resource Manager plan active
replication_dependency_tracking turned off (no async multimaster replication found)
ARC3: Archival started
ARC0: STARTING ARCH PROCESSES COMPLETE
Starting background process QMNC
Thu Jun 26 14:57:23 2014
QMNC started with pid=24, OS id=7647 
Completed: alter database open
Thu Jun 26 14:57:26 2014
Starting background process CJQ0
Thu Jun 26 14:57:26 2014
CJQ0 started with pid=27, OS id=7661

4、创建新的undo tablespace

14:59:27 [email protected] prod>show parameter undo
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_management                      string      MANUAL
undo_retention                       integer     900
undo_tablespace                      string      SYSTEM
14:59:34 [email protected] prod>create undo tablespace undotbs2
14:59:53   2  datafile ‘/u01/app/oracle/oradata/prod/undotbs2.dbf‘ size 100m
15:00:09   3  autoextend on;
15:01:28 [email protected] prod>create spfile from pfile;
File created.
Elapsed: 00:00:00.12
15:02:23 [email protected] prod>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
15:02:39 [email protected] prod>startup
ORACLE instance started.
Total System Global Area  835104768 bytes
Fixed Size                  2217952 bytes
Variable Size             775948320 bytes
Database Buffers           54525952 bytes
Redo Buffers                2412544 bytes
Database mounted.
Database opened.
15:03:36 [email protected] prod>alter system set undo_management=auto scope=spfile;
System altered.
Elapsed: 00:00:00.09
15:03:49 [email protected] prod>alter system set undo_tablespace=undotbs2 scope=spfile;
System altered.
Elapsed: 00:00:00.04
15:04:09 [email protected] prod>startup force;
ORACLE instance started.
Total System Global Area  835104768 bytes
Fixed Size                  2217952 bytes
Variable Size             775948320 bytes
Database Buffers           54525952 bytes
Redo Buffers                2412544 bytes
Database mounted.
Database opened.
15:04:28 [email protected] prod>show parameter undo
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
undo_management                      string      AUTO
undo_retention                       integer     900
undo_tablespace                      string      UNDOTBS2
15:04:36 [email protected] prod>select usn,name from v$rollname;
       USN NAME
---------- ------------------------------
         0 SYSTEM
        21 _SYSSMU21_2312338076$
        22 _SYSSMU22_3375463809$
        23 _SYSSMU23_4084707454$
        24 _SYSSMU24_386518199$
        25 _SYSSMU25_2810228709$
        26 _SYSSMU26_2968904537$
        27 _SYSSMU27_3269963619$
        28 _SYSSMU28_707429450$
        29 _SYSSMU29_2754652023$
        30 _SYSSMU30_1737877121$
11 rows selected.
Elapsed: 00:00:00.05

15:04:44 [email protected] prod>create pfile from spfile;
File created.

将隐含参数从pfile删除:

[[email protected] dbs]$ cat initprod.ora 
prod.__db_cache_size=16777216
prod.__oracle_base=‘/u01/app/oracle‘#ORACLE_BASE set from environment
#*._allow_resetlogs_corruption=true
#*._corrupted_rollback_segments=‘_SYSSMU10_3550978943$‘,‘_SYSSMU9_1424341975$‘,‘_SYSSMU8_2012382730$‘,‘_SYSSMU7_3286610060$‘,‘_SYSSMU6_2443381498$‘,‘_SYSSMU5_1527469038$‘,‘_SYSSMU4_1152005954$‘,‘_SYSSMU3_2097677531$‘,‘_SYSSMU2_2232571081$‘,‘_SYSSMU1_3780397527$‘
*.audit_file_dest=‘/u01/app/oracle/admin/prod/adump‘
*.audit_trail=‘db‘
*.compatible=‘11.2.0.0.0‘
*.control_files=‘/u01/app/oracle/oradata/prod/control01.ctl‘,‘/dsk1/oradata/prod/control02.ctl‘#Restore Controlfile
*.db_16k_cache_size=25165824
*.db_block_size=8192
*.db_cache_size=16777216
*.db_domain=‘‘
*.db_keep_cache_size=0
*.db_name=‘prod‘
*.db_recycle_cache_size=12582912
*.diagnostic_dest=‘/u01/app/oracle‘
*.dispatchers=‘(PROTOCOL=TCP) (SERVICE=prodXDB)‘
*.log_archive_dest_1=‘location=/dsk4/arch_prod‘
*.log_archive_dest_2=‘location=/dsk4/arch1‘
*.log_archive_dest_state_1=‘DEFER‘
*.log_archive_format=‘arch_%t_%s_%r.log‘
*.memory_target=0
*.O7_DICTIONARY_ACCESSIBILITY=TRUE
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile=‘EXCLUSIVE‘
*.sga_max_size=838860800
*.shared_pool_reserved_size=12582912
*.shared_pool_size=200886080
*.undo_management=‘AUTO‘
*.undo_tablespace=‘UNDOTBS2‘

重新创建spfile:

15:04:44 [email protected] prod>create spfile from pfile;
File created.

@至此,undo tablespace恢复完毕!

Oracle Undo tablespace恢复(无备份),布布扣,bubuko.com

时间: 2024-10-20 23:35:29

Oracle Undo tablespace恢复(无备份)的相关文章

【Oracle】undo损坏,无备份非常规恢复

客户的一个测试环境,主机异常断电,启动后发现undo文件损坏,无法启动,在open阶段报错如下: Errors in file /u01/app/oracle/diag/rdbms/cdrdb/CDRDB/trace/CDRDB_ora_4109.trc: ORA-01122: database file 3 failed verification check ORA-01110: data file 3: '/u01/app/oracle/oradata/CDRDB/undotbs01.dbf

oracle11g 数据文件误删恢复(无备份)

OS: Oracle Linux Server release 5.7 DB: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production 首先创建yoon数据库 SQL> create tablespace yoon datafile '/u01/oracle/oradata/yoon/yoon01.dbf' size 50m; Tablespace created. SQL> create use

Oracle备份恢复之无备份情况下恢复undo表空间

UNDO表空间存储着DML操作数据块的前镜像数据,在数据回滚,一致性读,闪回操作,实例恢复的时候都可能用到UNDO表空间中的数据.如果在生产过程中丢失或破坏了UNDO表空间,可能导致某些事务无法回滚,数据库无法恢复到一致性的状态,Oracle实例可能宕机,之后实例无法正常启动:如果有多个UNDO表空间数据文件,丢失其中一个数据文件数据库实例可能不会导致实例宕机,数据库无法干净的关闭(只能SHUTDOWN ABORT),数据库实例能正常的重启,但所有未回滚的数据块依然无法处理,尝试新建UNDO表空

案例:Oracle dul数据挖掘 没有数据库备份非常规恢复truncate删除的数据表

Oracle数据库在没有备份情况下在对表中的某数据表进行truncate删除后,通过oracle dul进行非常规恢复 1.准备oracle dul测试环境 SQL> select count(*) from t_xifenfei; COUNT(*) ---------- 67854 SQL> desc t_xifenfei Name Null? Type ----------------------------------------- -------- ------------------

无备份情况下回复undo表空间

UNDO表空间存储着DML操作数据块的前镜像数据,在数据回滚,一致性读,闪回操作,实例恢复的时候都可能用到UNDO表空间中的数据.如果在生产过程中丢失或破坏了UNDO表空间,可能导致某些事务无法回滚,数据库无法恢复到一致性的状态,Oracle实例可能宕机,之后实例无法正常启动:如果有多个UNDO表空间数据文件,丢失其中一个数据文件数据库实例可能不会导致实例宕机,数据库无法干净的关闭(只能SHUTDOWN ABORT),数据库实例能正常的重启,但所有未回滚的数据块依然无法处理,尝试新建UNDO表空

Oracle用户管理模式的备份恢复_超越OCP精通Oracle视频教程培训16

oracle视频教程目标 Oracle视频教程,风哥本套oracle教程培训学习oracle数据库用户管理的备份与恢复,归档模式与非归档模式,闪回恢复区,冷备份,热备份,dbverify工具的详解,如何完全恢复丢失的所有数据文件,基于时间点/取消/SCN的不完全恢复案例,归档日志的损坏,联机日志文件的损坏,数据文件无备份的恢复等日常管理与维护. 适用人群 IT相关从业人员.Oracle数据库技术人员.想加工资的.想升职的都可以. 视频在线学习地址: http://edu.51cto.com/co

无备份恢复(归档模式)

无备份恢复表空间前提是归档存在[[email protected] ~]$ rman target / Recovery Manager: Release 10.2.0.5.0 - Production on Tue Aug 5 10:02:46 2014 Copyright (c) 1982, 2007, Oracle.  All rights reserved. connected to target database: NETDATA (DBID=348346524) RMAN> list

己亥清爽恢复系列之数据文件3篇:非核心数据文件物理损坏或丢失(无备份恢复)

己亥清爽系列说明:清爽系列是作为恢复系列的基础篇,基于FS(File System)文件系统的手工还原恢复,也叫基于用户管理的还原恢复,来自于博客园AskScuti. 实验说明:物理删除非关键系统数据文件,模拟介质损坏或丢失,且在无备份的情况下,如何进行手工完全还原恢复操作.注:控制文件.在线日志和归档日志都完整的情况下. 基于版本:Oracle 11gR2 11.2.0.4 AskScuti 概念说明:请严格区分什么叫还原(Restore),什么叫恢复(Recover). 还原(Restore

20、oracle用户管理恢复

下面会一一讲解控制文件.redo文件及非归档模式.归档模式数据文件丢失的情况下,如何恢复数据? (1)控制文件(controlfile)丢失 在做恢复实验之前,先备份好数据. 案例1.模拟一个控制文件丢失 select name from v$controlfile; SQL> select name from v$controlfile; NAME -------------------------------------------------------------------------