关于 数据文件 恢复的四种 情况 (必要的时候 可以练练)
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.
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.
相关文章推荐
- 在mysql 安装后可以启动 bin-log 功能,以记录数据库的数据操作的记录,必要时候恢复数据,
- 无备份情况下数据文件恢复
- 新建数据文件丢失,其他文件全部都在的情况恢复
- 没有数据恢复深层复杂的知识也可以轻松恢复出丢失的文件数据
- numpy关于文件中数据为混合类型的时候的读取
- 数组和字典的writeToFile方法——在项目开发中处理网络数据的时候,可以把请求获得的网络数据保存为plist文件,这样更方便开发
- 使用文件和文件组备份可以恢复表数据吗?
- 在有全库备份的情况下恢复数据文件
- 关于postgis导入导出shp文件数据的一点心得,可以复制正文到记事本并保存成bat文件
- shutdown abort的情况,恢复全部数据文件(不包括control和redo)
- 删除数据文件 归档都在 这个数据文件是在控制文件之后创建的可以进行恢复
- 没备份的情况下,误删除数据文件的恢复
- 无ldf文件情况下恢复数据库数据纪实
- 什么是数据恢复?什么情况下可以恢复数据?
- shutdown abort的情况,恢复全部控制文件(不包括数据文件和redo)
- 数据文件在无备份情况的恢复
- 仅仅只有数据文件情况的恢复
- 仅仅只有数据文件情况的恢复
- ARCHIVELOG模式下用户管理的完全恢复(4)——在没有数据文件备份的情况下恢复数据文件!
- 拥有所有归档文件,但没有备份情况下的数据文件恢复