探索ORACLE之RMAN_07 数据库所有文件全部丢失恢复

简介: 探索ORACLE之RMAN_07 数据库所有文件全部丢失恢复 作者:吴伟龙   Name:Prodence Woo QQ:286507175  msn:hapy-wuweilong@hotmail.com            介于Rman恢复的自动性,我们刚才对数据库的全库,单表空间,数据文件控制文件和参数文件都做了备份,这些备份的内容是数据库运行不可缺少的必要元素,通常情况下我们在生产库中只需要备份这些内容即可。

探索ORACLERMAN_07 数据库所有文件全部丢失恢复

作者:吴伟龙   NameProdence Woo

QQ286507175  msn:hapy-wuweilong@hotmail.com

 

 

 

     介于Rman恢复的自动性,我们刚才对数据库的全库,单表空间,数据文件控制文件和参数文件都做了备份,这些备份的内容是数据库运行不可缺少的必要元素,通常情况下我们在生产库中只需要备份这些内容即可。有了这些备份,即使数据库的的任何信息丢失,我们都可以得以恢复使得数据库的正常运行,当然如果我们将archivelog 也备份,当然就会更好了,一般情况下这个可以不用备份,备份archivelog占用空间非常大。如果有海量的储存,当然备份也无妨咯。

Egg:

删除数据库的所有文件,仅保留redo日志和archivelog文件

 

删除控制文件:

[oracle@wwldb WWL]$ pwd

/DBData/oradata/WWL

[oracle@wwldb WWL]$ ls

control02.ctl control03.ctl

[oracle@wwldb WWL]$ rm -rf *.ctl

[oracle@wwldbWWL]$

[oracle@wwldb WWL]$ pwd

/DBSoft/oradata/WWL

[oracle@wwldb WWL]$ ls

control01.ctl

[oracle@wwldb WWL]$ rm -rfcontrol01.ctl

[oracle@wwldbWWL]$

 

删除数据文件:

[oracle@wwldb WWL]$ ls

redo01.log redo02.log redo03.logsysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf users01.dbf

[oracle@wwldb WWL]$ rm -rf *.dbf

[oracle@wwldb WWL]$ ls

redo01.log redo02.log redo03.log

[oracle@wwldbWWL]$

 

删除参数文件:

[oracle@wwldb dbs]$ cd$ORACLE_HOME/dbs

[oracle@wwldb dbs]$ rm -rfspfileWWL.ora

[oracle@wwldbdbs]$

 

执行大恢复:

1、现在数据库是关闭状态

[oracle@wwldb dbs]$ ps -ef|grep ora

root 2910 2888 0 10:02 ? 00:00:15hald-addon-storage: polling/dev/hdc

root 28954 3478 0 11:38 pts/100:00:00 su - oracle

oracle 28955 28954 0 11:38 pts/100:00:00 -bash

root 29361 3438 0 13:41 pts/200:00:00 su - oracle

oracle 29362 29361 0 13:41 pts/200:00:01 -bash

oracle 29988 29362 0 16:06 pts/200:00:00sqlplus as sysdba

oracle 30102 28955 0 17:03 pts/100:00:00 ps -ef

oracle 30103 28955 0 17:03 pts/100:00:00 grep ora

[oracle@wwldbdbs]$

 

2、要恢复首先要将数据库启动到mount状态才能恢复

[oracle@wwldb dbs]$ sqlplus / assysdba

SQL*Plus:Release 10.2.0.1.0 -Production on Wed May 23 17:03:42 2012

Copyright (c)1982, 2005, Oracle. Allrights reserved.

Connected to anidle instance.

SQL> startup

ORA-01078:failure in processingsystem parameters

LRM-00109: couldnot open parameterfile '/DBSoft/product/10.2.0/db_1/dbs/initWWL.ora'

SQL>

 

3、因为数据库没有参数文件,起不来,只能能启动到nomount状态

[oracle@wwldb dbs]$ rman target /

RecoveryManager: Release 10.2.0.1.0- Production on Wed May 23 17:06:32 2012

Copyright (c)1982, 2005, Oracle. Allrights reserved.

connected totarget database (notstarted)

RMAN> startup force nomount;

startup failed:ORA-01078: failure inprocessing system parameters

LRM-00109: couldnot open parameterfile '/DBSoft/product/10.2.0/db_1/dbs/initWWL.ora'

starting Oracleinstance withoutparameter file for retrival of spfile

Oracle instancestarted

Total System GlobalArea 159383552bytes

Fixed Size 1218244 bytes

VariableSize 58722620 bytes

DatabaseBuffers 92274688 bytes

RedoBuffers 7168000 bytes

RMAN>

 

4、开始恢复参数文件,只有恢复了参数文件和控制文件数据库才能到mount状态来恢复数据文件:

RMAN> restorespfile fromautobackup;

Starting restoreat 23-MAY-12

using targetdatabase control fileinstead of recovery catalog

allocatedchannel: ORA_DISK_1

channelORA_DISK_1: sid=36devtype=DISK

RMAN-00571:===========================================================

RMAN-00569:=============== ERRORMESSAGE STACK FOLLOWS ===============

RMAN-00571:===========================================================

RMAN-03002:failure of restorecommand at 05/23/2012 17:08:42

RMAN-06495: mustexplicitly specifyDBID with SET DBID command

RMAN>

注意:这里有问题了,spfile无法恢复,必须指定DBID。我记得在每次登录到rman的时候都会显示一个数据库的DBID,但是为什么这里要我们指定DBID呢???原因很简单,因为我们登录RMAN的时候,数据库已经宕机了,而且参数文件,控制文件,数据文件都没有了,它到哪里去找DBID;所以需要我们手动来指定,问题是现在既然登录的时候不显示,我们也不知道在哪里呀,如下:

[oracle@wwldb dbs]$ rman target /

Recovery Manager: Release 10.2.0.1.0- Production on WedMay 23 17:06:32 2012

Copyright (c) 1982, 2005, Oracle. All rightsreserved.

connected to targetdatabase (not started)

没关系的因为我们的控制文件做了自动备份,在自动备份的控制文件里面已经存在了DBID,我们现在去找找吧,默认就备份在如下位置:

[oracle@wwldb dbs]$ pwd

/DBSoft/product/10.2.0/db_1/dbs

[oracle@wwldb dbs]$ ls

c-5520179-20120518-01c-5520179-20120523-01 hc_WWL.dat lkWWL

其中5520179就是DBID了,我们只需要通过指定这个DBID,就可以将spfile恢复并将数据库启动到mount状态。

RMAN> set DBID=5520179

executingcommand: SET DBID

RMAN> restore spfile fromautobackup;

Starting restoreat 23-MAY-12

using targetdatabase control fileinstead of recovery catalog

allocatedchannel: ORA_DISK_1

channelORA_DISK_1: sid=39devtype=DISK

channelORA_DISK_1: looking forautobackup on day: 20120523

channelORA_DISK_1: autobackup found:c-5520179-20120523-04

channelORA_DISK_1: SPFILE restorefrom autobackup complete

Finished restoreat 23-MAY-12

RMAN>

 

5、恢复控制文件

RMAN> restore controlfile fromautobackup;

Starting restoreat 23-MAY-12

using channelORA_DISK_1

channelORA_DISK_1: looking forautobackup on day: 20120523

channelORA_DISK_1: autobackup found:c-5520179-20120523-04

channelORA_DISK_1: control filerestore from autobackup complete

outputfilename=/DBSoft/product/10.2.0/db_1/dbs/cntrlWWL.dbf

Finished restoreat 23-MAY-12

RMAN>

 

重启数据库到mount状态---很重要

SQL> startup mount;

ORACLE instancestarted.

Total SystemGlobal Area 285212672bytes

Fixed Size 1218968 bytes

VariableSize 79693416 bytes

DatabaseBuffers 197132288 bytes

RedoBuffers 7168000 bytes

Databasemounted.

SQL> exit

Disconnectedfrom Oracle Database 10gEnterprise Edition Release 10.2.0.1.0 - Production

With thePartitioning, OLAP and DataMining options

[oracle@wwldb dbs]$ rman target /

RecoveryManager: Release 10.2.0.1.0- Production on Wed May 23 19:04:15 2012

Copyright (c)1982, 2005, Oracle. Allrights reserved.

connected totarget database: WWL(DBID=5520179, not open)

注意:详细参考如下:

http://blog.csdn.net/wuweilong/article/details/7596056

http://space.itpub.net/?uid-20674423-action-viewspace-itemid-730717

 

6、恢复数据库其它的数据文件:

RMAN> restore database;

Starting restoreat 23-MAY-12

using targetdatabase control fileinstead of recovery catalog

allocatedchannel: ORA_DISK_1

channelORA_DISK_1: sid=156devtype=DISK

channelORA_DISK_1: starting datafilebackupset restore

channelORA_DISK_1: specifying datafile(s)to restore from backup set

restoringdatafile 00004 to/DBData/WWL/users01.dbf

channelORA_DISK_1: reading frombackup piece /DBBak/bak_WWL_05_23_0cnbn2a3_1_1

channelORA_DISK_1: restored backuppiece 1

piecehandle=/DBBak/bak_WWL_05_23_0cnbn2a3_1_1tag=TAG20120523T133147

channelORA_DISK_1: restore complete,elapsed time: 00:00:02

channelORA_DISK_1: starting datafilebackupset restore

channelORA_DISK_1: specifyingdatafile(s) to restore from backup set

restoringdatafile 00001 to/DBData/WWL/system01.dbf

restoringdatafile 00002 to/DBData/WWL/undotbs01.dbf

restoringdatafile 00003 to/DBData/WWL/sysaux01.dbf

channelORA_DISK_1: reading frombackup piece /DBBak/bak_WWL_05_23_0enbn2bk_1_1

channelORA_DISK_1: restored backuppiece 1

piecehandle=/DBBak/bak_WWL_05_23_0enbn2bk_1_1tag=TAG20120523T133235

channelORA_DISK_1: restore complete,elapsed time: 00:01:05

Finished restoreat 23-MAY-12

RMAN>

RMAN> recover database;

Starting recoverat 23-MAY-12

using channel ORA_DISK_1

starting mediarecovery

media recovery complete,elapsedtime: 00:00:05

Finished recoverat 23-MAY-12

RMAN> alter database open; ---------我们看到数据库已经打开了处于open状态

database opened

SQL> select instance_name,statusfrom v$instance;

INSTANCE_NAME STATUS

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

WWL OPEN

SQL>

 

目录
相关文章
|
14天前
|
SQL Oracle 关系型数据库
【Oracle】玩转Oracle数据库(一):装上去,飞起来!
【Oracle】玩转Oracle数据库(一):装上去,飞起来!
56 7
|
14天前
|
SQL Oracle 关系型数据库
【Oracle】玩转Oracle数据库(七):RMAN恢复管理器
【Oracle】玩转Oracle数据库(七):RMAN恢复管理器
41 5
|
2天前
|
NoSQL MongoDB 数据库
MongoDB数据恢复—MongoDB数据库文件被破坏的数据恢复案例
服务器数据恢复环境: 一台Windows Server操作系统服务器,服务器上部署MongoDB数据库。 MongoDB数据库故障&检测: 工作人员在未关闭MongoDB数据库服务的情况下,将数据库文件拷贝到其他分区。拷贝完成后将原MongoDB数据库所在分区进行了格式化操作,然后将数据库文件拷回原分区,重新启动MongoDB服务,服务无法启动。
|
6天前
|
存储 Oracle 关系型数据库
Oracle的模式与模式对象:数据库的“城市规划师”
【4月更文挑战第19天】在Oracle数据库中,模式是用户对象的集合,相当于数据库的城市规划,包含表、视图、索引等模式对象。模式对象是数据存储结构,如表用于存储数据,视图提供不同查看角度,索引加速数据定位。良好的模式与模式对象设计关乎数据效率、安全和稳定性。规划时需考虑业务需求、性能、安全和可扩展性,以构建高效数据库环境,支持企业业务发展。
|
6天前
|
运维 Oracle 安全
Oracle的三重奏:密码文件、警告文件与跟踪文件
【4月更文挑战第19天】Oracle数据库的三大守护者:密码文件保护系统免受未经授权访问,如同宝藏的“密码锁”;警告文件似“哨兵”,记录错误信息,助于及时解决问题;跟踪文件扮演“侦探”角色,详尽记录操作,便于性能优化和故障排查。这三份文件共同确保数据王国的安全与稳定。作为管理员,重视并善用它们是关键。
|
6天前
|
运维 Oracle 关系型数据库
Oracle日志文件:数据王国的“记事本”
【4月更文挑战第19天】Oracle日志文件是数据库稳定运行的关键,记录数据变更历史,用于恢复和故障处理。它们协调并发操作,确保数据一致性和完整性。日志文件实时写入操作信息并定期刷新到磁盘,便于数据恢复。然而,日志文件需备份和归档以保证安全性,防止数据丢失。日志文件,数据王国的“记事本”,默默守护数据安全。
|
7天前
|
存储 关系型数据库 MySQL
如何处理爬取到的数据,例如存储到数据库或文件中?
处理爬取的数据,可存储为txt、csv(适合表格数据)或json(适合结构化数据)文件。若需存储大量数据并执行复杂查询,可选择关系型(如MySQL)或非关系型(如MongoDB)数据库。以MySQL为例,需安装数据库和Python的pymysql库,创建数据库和表,然后编写Python代码进行数据操作。选择存储方式应考虑数据类型、数量及后续处理需求。
16 1
|
14天前
|
存储 SQL Oracle
【Oracle】玩转Oracle数据库(二):体系结构、存储结构与各类参数
【Oracle】玩转Oracle数据库(二):体系结构、存储结构与各类参数
35 7
|
6天前
|
关系型数据库 MySQL 分布式数据库
《MySQL 简易速速上手小册》第6章:MySQL 复制和分布式数据库(2024 最新版)
《MySQL 简易速速上手小册》第6章:MySQL 复制和分布式数据库(2024 最新版)
37 2
|
22天前
|
SQL 数据可视化 关系型数据库
轻松入门MySQL:深入探究MySQL的ER模型,数据库设计的利器与挑战(22)
轻松入门MySQL:深入探究MySQL的ER模型,数据库设计的利器与挑战(22)
105 0

推荐镜像

更多