恢复备份后创建的数据文件

来源:互联网 发布:php视频直播实现 编辑:程序博客网 时间:2024/05/08 02:55
第一种情况:控制文件是最新的,并且备份文件存在

$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Nov 25 17:22:32 2008

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  205520896 bytes
Fixed Size                  1218532 bytes
Variable Size              79693852 bytes
Database Buffers          121634816 bytes
Redo Buffers                2973696 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/u01/app/oradata/randy10g/test01.dbf'

SQL> alter database create datafile '/u01/app/oradata/randy10g/test01.dbf';

Database altered.

SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01113: file 7 needs media recovery
ORA-01110: data file 7: '/u01/app/oradata/randy10g/test01.dbf'

SQL> recover datafile 7;
Media recovery complete.
SQL> alter database open;

Database altered.

SQL>

第二种情况:旧的控制文件,数据文件没有备份

$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Nov 25 17:29:24 2008

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

connected to target database: RANDY10G (DBID=3413520730)

RMAN> backup database;

Starting backup at 25-NOV-08
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oradata/randy10g/system01.dbf
input datafile fno=00003 name=/u01/app/oradata/randy10g/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oradata/randy10g/example01.dbf
input datafile fno=00002 name=/u01/app/oradata/randy10g/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oradata/randy10g/users01.dbf
input datafile fno=00006 name=/u01/app/oradata/randy10g/outlines01.dbf
channel ORA_DISK_1: starting piece 1 at 25-NOV-08
channel ORA_DISK_1: finished piece 1 at 25-NOV-08
piece handle=/u01/app/flash_recovery_area/RANDY10G/backupset/2008_11_25/o1_mf_nnndf_TAG20081125T181711_4lqn57jr_.bkp tag=TAG20081125T181711 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
Finished backup at 25-NOV-08

Starting Control File and SPFILE Autobackup at 25-NOV-08
piece handle=/u01/app/flash_recovery_area/RANDY10G/autobackup/2008_11_25/o1_mf_s_671739660_4lqnddr0_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 25-NOV-08

SQL> create tablespace test datafile '/u01/app/oradata/randy10g/test01.dbf' size 2m;

Tablespace created.

$ mv test01.dbf test01.dbf.bak
$ mv control01.ctl control01.ctl.bak
$ mv control02.ctl control02.ctl.bak
$ mv control03.ctl control03.ctl.bak

SQL> shutdown abort
ORACLE instance shut down.

$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Nov 25 17:58:44 2008

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

connected to target database (not started)

RMAN> set dbid=3413520730

executing command: SET DBID

RMAN> startup nomount;

Oracle instance started

Total System Global Area     205520896 bytes

Fixed Size                     1218532 bytes
Variable Size                 79693852 bytes
Database Buffers             121634816 bytes
Redo Buffers                   2973696 bytes

RMAN> restore controlfile from autobackup;

Starting restore at 25-NOV-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

recovery area destination: /u01/app/flash_recovery_area
database name (or database unique name) used for search: RANDY10G
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found: /u01/app/flash_recovery_area/RANDY10G/autobackup/2008_11_25/o1_mf_s_671737741_4lqljfjy_.bkp
channel ORA_DISK_1: control file restore from autobackup complete
output filename=/u01/app/oradata/randy10g/control01.ctl
output filename=/u01/app/oradata/randy10g/control02.ctl
output filename=/u01/app/oradata/randy10g/control03.ctl
Finished restore at 25-NOV-08

SQL> alter database create datafile '/u01/app/oradata/randy10g/test01.dbf';

Database altered.

SQL> recover database using backup controlfile;
ORA-00279: change 999804 generated at 11/25/2008 18:39:15 needed for thread 1
ORA-00289: suggestion :
/u01/app/flash_recovery_area/RANDY10G/archivelog/2008_11_25/o1_mf_1_1_%u_.arc
ORA-00280: change 999804 for thread 1 is in sequence #1

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00308: cannot open archived log
'/u01/app/flash_recovery_area/RANDY10G/archivelog/2008_11_25/o1_mf_1_1_%u_.arc'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

ORA-00308: cannot open archived log
'/u01/app/flash_recovery_area/RANDY10G/archivelog/2008_11_25/o1_mf_1_1_%u_.arc'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

SQL> recover database using backup controlfile;
ORA-00279: change 999804 generated at 11/25/2008 18:39:15 needed for thread 1
ORA-00289: suggestion :
/u01/app/flash_recovery_area/RANDY10G/archivelog/2008_11_25/o1_mf_1_1_%u_.arc
ORA-00280: change 999804 for thread 1 is in sequence #1

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/u01/app/oradata/randy10g/redo01.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 resetlogs;

Database altered.

原创粉丝点击