Oracle备份rman测试实例

 

一: 数据文件丢失

环境:新建表空间zhen,用户zhen,删除数据文件zhen.dbf系统报错。

错误讯息:SQL> startup;

ORACLE instance started.

 

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size              92276304 bytes

Database Buffers          188743680 bytes

Redo Buffers                2973696 bytes

Database mounted.

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

ORA-01110: data file 5: '/oracle/oradata/db3/zhen.dbf'

查看报警文件:

Errors in file /oracle/admin/db3/bdump/db3_dbw0_3293.trc:

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

ORA-01110: data file 5: '/oracle/oradata/db3/zhen.dbf'

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

 

处理方法:

1.       Startup mount

2.       rman target /

3.       查看目前数据文件

RMAN> report schema;

 

using target database control file instead of recovery catalog

Report of database schema

 

List of Permanent Datafiles

===========================

File Size(MB) Tablespace           RB segs Datafile Name

---- -------- -------------------- ------- ------------------------

1    480      SYSTEM               ***     /oracle/oradata/db3/system01.dbf

2    45       UNDOTBS1             ***     /oracle/oradata/db3/undotbs01.dbf

3    250      SYSAUX               ***     /oracle/oradata/db3/sysaux01.dbf

4    5        USERS                ***     /oracle/oradata/db3/users01.dbf

5    100      ZHEN                 ***     /oracle/oradata/db3/zhen.dbf

 

List of Temporary Files

=======================

File Size(MB) Tablespace           Maxsize(MB) Tempfile Name

---- -------- -------------------- ----------- --------------------

1    20       TEMP                 32767       /oracle/oradata/db3/temp01.dbf

 

4 sql页面将数据文件offline

 

SQL> alter database datafile 5 offline;

 

5 恢复数据文件5的数据。

 RMAN> restore datafile 5

 

    RMAN> recover datafile 5;

6 使表空间online

SQL> alter database datafile 5 online;

 

恢复ok

 

二:临时表空间错误:

 

实验环境:shell下直接删除temp数据文件

shutdown immediate

startup

成功启动,没有报错,报警文件也没有报错。

因为临时表空间是排序用的,所以查一个表

Sql>select * from a oeder by id;

还是没有报错,奇怪

3 查看shell下,临时表空间已经自己建好。晕:实验失败。

 

三: 改实验为修改默认表空间;

  新建临时表空间;

  1 SQL> create temporary tablespace temp02 tempfile '/oracle/oradata/temp02.dbf' size 50m;

  2 查看目前临时表空间

    SQL> select * from v$tempfile;

 

     FILE# CREATION_CHANGE# CREATION_        TS#     RFILE# STATUS  ENABLED

---------- ---------------- --------- ---------- ---------- ------- ----------

     BYTES     BLOCKS CREATE_BYTES BLOCK_SIZE

---------- ---------- ------------ ----------

NAME

--------------------------------------------------------------------------------

         1           446159 03-JUL-10          3          1 ONLINE  READ WRITE

  20971520       2560     20971520       8192

/oracle/oradata/db3/temp01.dbf

 

         2           634975 21-JUL-10          7          1 ONLINE  READ WRITE

  52428800       6400     52428800       8192

/oracle/oradata/temp02.dbf

 

3 修改默认临时表空间:

 SQL> alter database default temporary tablespace temp02;

4 删除原临时表空间

  SQL> drop tablespace temp;

5 查看目前临时表空间

SQL> select * from v$tempfile;

 

     FILE# CREATION_CHANGE# CREATION_        TS#     RFILE# STATUS  ENABLED

---------- ---------------- --------- ---------- ---------- ------- ----------

     BYTES     BLOCKS CREATE_BYTES BLOCK_SIZE

---------- ---------- ------------ ----------

NAME

--------------------------------------------------------------------------------

         2           634975 21-JUL-10          7          1 ONLINE  READ WRITE

  52428800       6400     52428800       8192

/oracle/oradata/temp02.dbf

 

 

实验四:undo回滚表空间坏掉:

环境:删除undo表空间数据文件,强行shutdown abort

 

问题:SQL> startup;     

ORACLE instance started.

 

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size              92276304 bytes

Database Buffers          188743680 bytes

Redo Buffers                2973696 bytes

Database mounted.

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

ORA-01110: data file 2: '/oracle/oradata/db3/undotbs01.dbf'

 

启动时报错:只能到mount状态

解决方法一:

本打算按老师方法,重建redu表空间,突然想到我有rman备份。

直接:

1 startup mount

2 rman target /

3 report schema查看序号为2;

4 {

   Restore datafile 2;

   Recover datafile 2;

   Sql”alter database open”

}

Ok测试成功。

方法二:重建redo,适用于没有人满备份情况。

1 关闭数据库shutdown abort

2 修改参数文件将下面两个参数注销:

#  *.undo_management='AUTO'

#*.undo_tablespace='UNDO01'

3 startup mount 启动到mount状态

4 SQL> alter database datafile 2 offline;

5 alter database open;

6 重建redo表空间。

  SQL> create undo tablespace undo02 datafile '/oracle/oradata/undo02.dbf' size 50m;

7 shutdown后,修改参数文件

  *.undo_management='AUTO'

*.undo_tablespace='UNDO02'

8 startup

测试ok。

 

实验五:重建控制文件

1 SQL> alter database backup controlfile to trace;

2  $ cat  db3_ora_414.trc

 

 

CREATE CONTROLFILE REUSE DATABASE "DB3" RESETLOGS  ARCHIVELOG

    MAXLOGFILES 16

    MAXLOGMEMBERS 3

    MAXDATAFILES 100

    MAXINSTANCES 8

    MAXLOGHISTORY 292

LOGFILE

  GROUP 1 '/oracle/oradata/db3/redo01.log'  SIZE 50M,

  GROUP 2 '/oracle/oradata/db3/redo02.log'  SIZE 50M,

  GROUP 3 '/oracle/oradata/db3/redo03.log'  SIZE 50M

-- STANDBY LOGFILE

DATAFILE

  '/oracle/oradata/db3/system01.dbf',

  '/oracle/oradata/db3/undotbs01.dbf',

  '/oracle/oradata/db3/sysaux01.dbf',

  '/oracle/oradata/db3/users01.dbf',

  '/oracle/oradata/db3/zhen.dbf',

  '/oracle/oradata/undo02.dbf'

CHARACTER SET ZHS16GBK

;

你可能感兴趣的:(oracle,测试)