Oracle恢復實驗一:使用添加數據文件之前的控制文件
2024-08-29 13:28:50
供稿:網友
 
---------------------------------------------
實驗平臺: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開發。