Oracle恢复实验一:使用添加数据文件之前的控制文件
2020-03-09 22:55:34
供稿:网友
---------------------------------------------
实验平台:windows + oracle 10.1.0.2.0
author:ningoo 2005-03-26
--------------------------------------------
在备份控制文件之后,在数据库中又添加了数据文件,然后当前控制文件损坏,需要使用之前的备份控制文件来做恢复。
1.备份控制文件
sql> alter database backup controlfile to 'e:/control.ctl';
数据库已更改。
2.使用create tablespace或者alter tablespace add datafile给数据库添加数据文件
sql> create tablespace test
2 datafile 'e:/oracle/oradata/ning/test01.dbf' size 10m,
3 'e:/oracle/oradata/ning/test02.dbf' size 10m;
表空间已创建。
3.shutdown后将现在的控制文件删除
4.startup数据库
报错:ora-00205: error in identifying controlfile, check alert log for more info
5.将备份的控制文件restore
6.使用备份控制文件做恢复
sql> recover database using backup controlfile;
ora-00283: 恢复会话因错误而取消
ora-01244: 未命名的数据文件由介质恢复添加至控制文件
ora-01110: 数据文件 5: 'e:/oracle/oradata/ning/test01.dbf'
ora-01110: 数据文件 6: 'e:/oracle/oradata/ning/test02.dbf'
此时,查看v$datafile可以看到有两个unname文件
sql> select name from v$datafile;
name
-------------------------------------------
e:/oracle/oradata/ning ystem01.dbf
e:/oracle/oradata/ning/undotbs01.dbf
e:/oracle/oradata/ning ysaux01.dbf
e:/oracle/oradata/ning/users01.dbf
c:/windows ystem32/unnamed00005
c:/windows ystem32/unnamed00006
查看alert_sid.log,可以看到如下内容
file #5 added to control file as 'unnamed00005'. originally created as:
'e:/oracle/oradata/ning/test01.dbf'
file #6 added to control file as 'unnamed00006'. originally created as:
'e:/oracle/oradata/ning/test02.dbf'
可知unnamed00005对应'e:/oracle/oradata/ning/test01.dbf'
unnamed00006对应'e:/oracle/oradata/ning/test02.dbf'
7.重命名数据文件
sql> alter database rename file 'c:/windows ystem32/unnamed00005' to
2 'e:/oracle/oradata/ning/test01.dbf';
数据库已更改。
sql> alter database rename file 'c:/windows ystem32/unnamed00006' to
2 'e:/oracle/oradata/ning/test02.dbf';
数据库已更改。
8.再使用备份控制文件恢复
sql> recover database using backup controlfile;
完成介质恢复。
9.使用resetlogs选项打开数据库
sql> alter database open;
alter database open
*
第 1 行出现错误:
ora-01589: 要打开数据库则必须使用 resetlogs 或 noresetlogs 选项
sql> alter database open noresetlogs;
alter database open noresetlogs
*
第 1 行出现错误:
ora-01588: 要打开数据库则必须使用 resetlogs 选项
sql> alter database open resetlogs;
数据库已更改。
10.添加temp文件
此时查看alert_sid.log,可以看到以下警告
***************************************************************
warning: the following temporary tablespaces contain no files.
this condition can occur when a backup controlfile has
been restored. it may be necessary to add files to these
tablespaces. that can be done using the sql statement:
alter tablespace <tablespace_name> add tempfile
alternatively, if these temporary tablespaces are no longer
needed, then they can be dropped.
empty temporary tablespace: temp
***************************************************************
使用备份控制文件恢复后,temp表空间被置空
sql> select name from v$tempfile;
未选定行
sql>alter tablespace temp add tempfile
2 'e:/oracle/oradata/ning/temp01.dbf';
表空间已更改。
,欢迎访问网页设计爱好者web开发。