oracle备份与恢复(3)

2019-02-21 01:14

www.imissha.com 谜尚bb霜 --------------------------------------- 1 2

SQL> alter system switch logfile; System altered. SQL>r

1* alter system switch logfile; System altered.

4、关闭数据库,模拟丢失数据文件 SQL> shutdown immediate; Database closed.

Database dismounted.

ORACLE instance shut down

C:>del D:ORACLEORADATATESTUSER01.DBF 5、启动数据库,检查错误 SQL> startup

ORACLE instance started.

Total System Global Area 102020364 bytes Fixed Size 70924 bytes

Variable Size 85487616 bytes

Database Buffers 16384000 bytes Redo Buffers 77824 bytes Database mounted.

ORA-01157: cannot identify/lock data file 3 - see DBWR trace file ORA-01110: data file 3: 'D:ORACLEORADATATESTUSER01.DBF' 6、先打开数据库

SQL> alter database datafile 3 offline drop; Database altered.

SQL> alter database open; Database altered. 7、恢复该表空间

恢复脚本可以是恢复单个数据文件 run{

allocate channel c1 type disk; restore datafile 3; recover datafile 3;

sql 'alter database datafile 3 online'; release channel c1; }

也可以是,恢复表空间 run{

allocate channel c1 type disk; restore tablespace users; recover tablespace users;

sql 'alter database datafile 3 online'; release channel c1;

www.imissha.com 谜尚bb霜 }

过程如下: C:>rman

Recovery Manager: Release 8.1.6.0.0 - Production RMAN> connect rcvcat rman/rman@back

RMAN-06008: connected to recovery catalog database RMAN> connect target internal/virpure

RMAN-06005: connected to target database: TEST (DBID=1788174720) RMAN> run{

2> allocate channel c1 type disk; 3> restore datafile 3; 4> recover datafile 3;

5> sql 'alter database datafile 3 online'; 6> release channel c1; 7> }

RMAN-03022: compiling command: allocate RMAN-03023: executing command: allocate RMAN-08030: allocated channel: c1

RMAN-08500: channel c1: sid=13 devtype=DISK RMAN-03022: compiling command: restore RMAN-03022: compiling command: IRESTORE RMAN-03023: executing command: IRESTORE

RMAN-08016: channel c1: starting datafile backupset restore RMAN-08502: set_count=5 set_stamp=494177612 creation_time=16-MAY-03

RMAN-08089: channel c1: specifying datafile(s) to restore from backup set

RMAN-08523: restoring datafile 00003 to D:ORACLEORADATATESTUSER01.DBF

RMAN-08023: channel c1: restored backup piece 1 RMAN-08511: piece handle=D:BACKUPTSUSER_05EN93AC_5_1 tag=TSUSER params=NULL

RMAN-08024: channel c1: restore complete

RMAN-03023: executing command: partial resync

RMAN-08003: starting partial resync of recovery catalog RMAN-08005: partial resync complete

RMAN-03022: compiling command: recover RMAN-03022: compiling command: recover(1) RMAN-03022: compiling command: recover(2) RMAN-03022: compiling command: recover(3) RMAN-03023: executing command: recover(3) RMAN-08054: starting media recovery

RMAN-03022: compiling command: recover(4)

RMAN-06050: archivelog thread 1 sequence 332 is already on disk as file D:ORACLEORADATATESTARCHIVETESTT001S00332.ARC

www.imissha.com 谜尚bb霜 RMAN-06050: archivelog thread 1 sequence 333 is already on disk as file D:ORACLEORADATATESTARCHIVETESTT001S00333.ARC

RMAN-06050: archivelog thread 1 sequence 334 is already on disk as file D:ORACLEORADATATESTARCHIVETESTT001S00334.ARC

RMAN-03023: executing command: recover(4) RMAN-08515: archivelog filename=D:ORACLEORADATATESTARCHIVETESTT001S00332.ARC thread=1 sequence=332

RMAN-08055: media recovery complete RMAN-03022: compiling command: sql

RMAN-06162: sql statement: alter database datafile 3 online RMAN-03023: executing command: sql

RMAN-03022: compiling command: release RMAN-03023: executing command: release RMAN-08031: released channel: c1 RMAN>

8、检查数据是否完整

SQL> alter database open; Database altered.

SQL> select * from test; A

--------------------------------------- 1 2

说明:

1、RMAN也可以实现单个表空间或数据文件的恢复,恢复过程可以在mount下或open方式下,如果在open方式下恢复,可以减少down机时间

2、如果损坏的是一个数据文件,建议offline并在open方式下恢复

3、这里可以看到,RMAN进行数据文件与表空间恢复的时候,代码都比较简单,而且能保证备份与恢复的可靠性,所以建议采用RMAN的备份与恢复

4.3丢失多个数据文件,实现整个数据库的恢复 4.3.1 OS备份方案

OS备份归档模式下损坏(丢失)多个数据文件,进行整个数据库的恢复 1、连接数据库,创建测试表并插入记录

SQL*Plus: Release 8.1.6.0.0 - Production on Tue May 6 13:46:32 2003 (c) Copyright 1999 Oracle Corporation. All rights reserved. SQL> connect internal/password as sysdba; Connected.

SQL> create table test(a int); Table created

www.imissha.com 谜尚bb霜 SQL> insert into test values(1); 1 row inserted SQL> commit; Commit complete

2、备份数据库,备份除临时数据文件后的所数据文件

SQL> @hotbak.sql 或在DOS下 svrmgrl @hotbak.sql 3、继续在测试表中插入记录

SQL> insert into test values(2); 1 row inserted SQL> commit; Commit complete

SQL> select * from test; A

--------------------------------------- 1 2

SQL> alter system switch logfile; System altered.

SQL> alter system switch logfile; System altered.

4、关闭数据库,模拟丢失数据文件 SQL> shutdown immediate; Database closed.

Database dismounted.

ORACLE instance shut down

C:>del D:ORACLEORADATATESTSYSTEM01.DBF C:>del D:ORACLEORADATATESTINDX01.DBF C:>del D:ORACLEORADATATESTTOOLS01.DBF C:>del D:ORACLEORADATATESTRBS01.DBF 模拟媒体毁坏(这里删除多个数据文件) 5、启动数据库,检查错误 SQL> STARTUP

ORACLE instance started.

Total System Global Area 102020364 bytes Fixed Size 70924 bytes

Variable Size 85487616 bytes

Database Buffers 16384000 bytes Redo Buffers 77824 bytes Database mounted.

ORA-01157: cannot identify/lock data file 1 - see DBWR trace file ORA-01110: data file 1: 'D:ORACLEORADATATESTSYSTEM01.DBF' 详细信息可以查看报警文件

ORA-1157 signalled during: ALTER DATABASE OPEN... Thu May 08 09:39:36 2003

Errors in file D:OracleadmintestbdumptestDBW0.TRC:

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

www.imissha.com 谜尚bb霜 ORA-01110: data file 1: 'D:ORACLEORADATATESTSYSTEM01.DBF' ORA-27041: unable to open file OSD-04002: unable to open file

O/S-Error: (OS 2) 系统找不到指定的文件。 Thu May 08 09:39:36 2003

Errors in file D:OracleadmintestbdumptestDBW0.TRC:

ORA-01157: cannot identify/lock data file 2 - see DBWR trace file ORA-01110: data file 2: 'D:ORACLEORADATATESTRBS01.DBF' ORA-27041: unable to open file OSD-04002: unable to open file

O/S-Error: (OS 2) 系统找不到指定的文件。 Thu May 08 09:39:36 2003

Errors in file D:OracleadmintestbdumptestDBW0.TRC:

ORA-01157: cannot identify/lock data file 5 - see DBWR trace file ORA-01110: data file 5: 'D:ORACLEORADATATESTTOOLS01.DBF' ORA-27041: unable to open file OSD-04002: unable to open file

O/S-Error: (OS 2) 系统找不到指定的文件。 Thu May 08 09:39:36 2003

Errors in file D:OracleadmintestbdumptestDBW0.TRC:

ORA-01157: cannot identify/lock data file 6 - see DBWR trace file ORA-01110: data file 6: 'D:ORACLEORADATATESTINDX01.DBF' ORA-27041: unable to open file OSD-04002: unable to open file

O/S-Error: (OS 2) 系统找不到指定的文件。 通过查询v$recover_file可以看到

SQL> select * from v$recover_file; FILE# ONLINE ERROR CHANGE# TIME

---------- ------- ------------------ ---------- ----------- 1 ONLINE FILE NOT FOUND 0 2 ONLINE FILE NOT FOUND 0 5 ONLINE FILE NOT FOUND 0 6 ONLINE FILE NOT FOUND 0 有四个数据文件需要恢复

6、拷贝备份回到原地点(restore),开始恢复数据库(recover) restore过程:

C:>copy D:DATABAKSYSTEM01.DBF D:ORACLEORADATATEST C:>copy D:DATABAKTESTINDX01.DBF D:ORACLEORADATATEST C:>copy D:DATABAKTESTTOOLS01.DBF D:ORACLEORADATATEST C:>copy D:DATABAKTESTRBS01.DBF.DBF D:ORACLEORADATATEST Recover过程:

SQL> recover database;

ORA-00279: change 1073849 generated at 05/08/2003 08:58:35 needed for thread 1 ORA-00289: suggestion : D:ORACLEORADATATESTARCHIVETESTT001S00311.ARC


oracle备份与恢复(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:2011高中数学知识点总结大全

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: