您的位置:首页 > 其它

关于 数据文件 恢复的四种 情况 (必要的时候 可以练练)

2012-03-28 15:10 330 查看
Below workshop, I will perform some workshops about the database recovery:

Step1:

when the database in not open status:

1: when the database open, remove all the datafile.

2: shutdown the database abort. (shutdown immdiate will cause error).

3: startup mount

4: copy the cold backup datafile into the defination direction.

5: Because the current control file is latest, but the datafile is old,

if open the database, database will not open.

6: using v$recover_file the check which datafile should br recovery.

7: set autorecovery off

(if you "set autorecovery on", the archived logs will be recovered automatic )

so suggestion is : set autorecovery on

8: recover database (you can use recover datafile 1,2).

9:select * from v$recover_file

(you will see no records)

10: alter database open;

Step2:

When the database is current open:

Use this method when:

1: The database is current open

2: The database will remain open during the recovery.

3: The media failure dose not affect the SYSTEM tablespace.

Below is the recovery steps:

1: I will simulate the tablespace file missing.

2: insert into table ( write the data into memory)--- commit (writer the data into redo file).

3: alter system checkpoint

(This action is to write the data from memory to tablespace file).

4: select * from v$recover_file;

(You will see one record about the tablespace line)

5: alter database datafile 6 offline

(you can also use below command:)

alter tablespace tablespace_name offline;

6: copy the bakcup datafile : tbs01.dbf into the defination direction.

7: recover datafile 6;

(because this time the control file , redo file do not corresponding to datafile 6 )

8: select file#,status,name from v$datafile

(you will find the datafile 6 is offline)

9: select * from v$recover_file

(you will not see any records in the view)

10:select * from v$datafile;

You wil see datafile 6 is offline.

alter database datafile 6 online.

11: alter database open;

12 :Check the data is available.

Step3:

Recovery when the DB is init closed:

Use this method when:

1: The database is currently closed.

2: The database will be opened during recovery.

3: The media failure dose not affect the SYSTEM tablespace.

The recovery steps:

1: Mount the database

2: Take datafile 2 offline.

3: Open the database.

4: Restore datafile 2.

5: recovery datafile 2.

6: Take datafile 2 online.

Step4:

Recovery File without a backup:

Condition:

1: Datafile is lost that was never backed up.

2: Can not used when it is a file from SYSTEM tablespace.

3: Can not used if control file has been related.

Notice:

If datafile is damaged and no backup of the file is available, then you still

can recovery the datafile if:

1: All archived log files written after the creation of the original datafile are available

2: The control file contains the name of the damaged file (that is, the control file is current,

or it oss a backup taken after the damaged datafil was added to the database).

Notice:

You can not re-create any of the datafiles for SYSTEM tablespace by using any

COMMAND: create datafile... ,because the necessary redo is not available.

Re-create Lost Datafiles:

1: Used when missing datafile cannot be restored

because it had never been backed up.

2: Description of missing datafile is still in data dictionary and control file.

3: Re-create the datafile:

SQL>Alter database create datafile 'filename';

Re-create the datafile with a different filename:

SQL> Alter database create datafile 'filename' as 'new file name';

Restore this case steps:

1: take the datafile offline.

2: create new datafile

3: recovery datafile.

4: take the datafile online.

5: Open the database.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐