日期:2014-05-16  浏览次数:20378 次

Oracle 数据库恢复

--

############ 日志文件损坏时恢复数据库 ############

1. 查询日志文件及状态(mount)
select group#,sequence#,status from v$log;

2. 允许日志崩溃时重置日志(mount)
alter system set "_allow_resetlogs_corruption"=true scope=spfile;

3. 重启数据库 -> 查询 _allow_resetlogs_corruption (nomount)
startup mount force;
show parameter allow;

4. 打开数据库并重置日志(mount)
alter database open resetlogs;
# 执行出错,提示需要 database recovery

5. 做一个假恢复(mount)
recover database until cancel;
# 在执行过程中选择 cancel

6. 重新打开数据库并重置日志(mount)
alter database open resetlogs;
# 执行出错,提示实例挂掉了

7. 重新启动数据库, Ok
startup

########## 数据文件损坏时根据日志恢复 ##########

1. 查找崩溃的数据文件(mount)
select file#,name,status from v$datafile;

2. 根据控制文件建立一个空的数据文件,大小和原来的相同,同时更改文件名称(mount)
alter database create datafile 'old_datafile_path' as 'new_datafile_path';

3. 根据第1步查找到的 file# 从日志中恢复数据(mount)
recover datafile file#;
# 执行过程中选择 auto

4. 打开数据库(mount)
alter database open;

5. 查看表空间状态(open)
select tablespace_name,status from dba_tablespaces;
# 如果表空间 offline, 则使用下面的命令使表空间 online
alter tablespace tablespaceName online;

???

?

?