ITPub博客

首页 > 数据库 > Oracle > 重建控制文件(一)

重建控制文件(一)

原创 Oracle 作者:cxm758521 时间:2007-11-27 19:16:54 0 删除 编辑

第一种方法:
1 创建回复控制文件的脚本
SQL> alter database backup controlfile to trace as 'd:aa.sql';

数据库已更改。


可以根据创建的脚本恢复数据库的控制文件,找到此脚本,用记事本或者编译器打开,你可以看到如下脚本

# Below are two sets of SQL statements, each of which creates a new
# control file and uses it to open the database. The first set opens
# the database with the NORESETLOGS option and should be used only if
# the current versions of all online logs are available. The second
# set opens the database with the RESETLOGS option and should be used
# if online logs are unavailable.
# The appropriate set of statements can be copied from the trace into
# a script file, edited as necessary, and executed when there is a
# need to re-create the control file.
#
# Set #1. NORESETLOGS case
#
# The following commands will create a new control file and use it
# to open the database.
# Data used by the recovery manager will be lost. Additional logs may
# be required for media recovery of offline data files. Use this
# only if the current version of all online logs are available.
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS NOARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 50
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 226
LOGFILE
GROUP 1 'D:ORACLEORADATAORCLREDO01.LOG' SIZE 100M,
GROUP 2 'D:ORACLEORADATAORCLREDO02.LOG' SIZE 100M,
GROUP 3 'D:ORACLEORADATAORCLREDO03.LOG' SIZE 100M
-- STANDBY LOGFILE

DATAFILE
'D:ORACLEORADATAORCLSYSTEM01.DBF',
'D:ORACLEORADATAORCLUNDOTBS01.DBF',
'D:ORACLEORADATAORCLCWMLITE01.DBF',
'D:ORACLEORADATAORCLDRSYS01.DBF',
'D:ORACLEORADATAORCLEXAMPLE01.DBF',
'D:ORACLEORADATAORCLINDX01.DBF',
'D:ORACLEORADATAORCLODM01.DBF',
'D:ORACLEORADATAORCLTOOLS01.DBF',
'D:ORACLEORADATAORCLUSERS01.DBF',
'D:ORACLEORADATAORCLXDB01.DBF',
'D:ORACLEORADATAORCLRMAN_TS.DBF'
CHARACTER SET ZHS16GBK
;

# Recovery is required if any of the datafiles are restored backups,
# or if the last shutdown was not normal or immediate.
RECOVER DATABASE

# Database can now be opened normally.
ALTER DATABASE OPEN;

# No tempfile entries found to add.
#
# Set #2. RESETLOGS case
#
# The following commands will create a new control file and use it
# to open the database.
# The contents of online logs will be lost and all backups will
# be invalidated. Use this only if online logs are damaged.
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS NOARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 50
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 226
LOGFILE
GROUP 1 'D:ORACLEORADATAORCLREDO01.LOG' SIZE 100M,
GROUP 2 'D:ORACLEORADATAORCLREDO02.LOG' SIZE 100M,
GROUP 3 'D:ORACLEORADATAORCLREDO03.LOG' SIZE 100M
-- STANDBY LOGFILE

DATAFILE
'D:ORACLEORADATAORCLSYSTEM01.DBF',
'D:ORACLEORADATAORCLUNDOTBS01.DBF',
'D:ORACLEORADATAORCLCWMLITE01.DBF',
'D:ORACLEORADATAORCLDRSYS01.DBF',
'D:ORACLEORADATAORCLEXAMPLE01.DBF',
'D:ORACLEORADATAORCLINDX01.DBF',
'D:ORACLEORADATAORCLODM01.DBF',
'D:ORACLEORADATAORCLTOOLS01.DBF',
'D:ORACLEORADATAORCLUSERS01.DBF',
'D:ORACLEORADATAORCLXDB01.DBF',
'D:ORACLEORADATAORCLRMAN_TS.DBF'
CHARACTER SET ZHS16GBK
;

# Recovery is required if any of the datafiles are restored backups,
# or if the last shutdown was not normal or immediate.
RECOVER DATABASE USING BACKUP CONTROLFILE

# Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;

# No tempfile entries found to add.
#

脚本中给了我们创建控制文件的两种方式:

一, 在NORESETLOGS状态下,我们不用根据日志再恢复日志文件,只要执行下面的脚本就可

1 CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS NOARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 50
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 226
LOGFILE
GROUP 1 'D:ORACLEORADATAORCLREDO01.LOG' SIZE 100M,
GROUP 2 'D:ORACLEORADATAORCLREDO02.LOG' SIZE 100M,
GROUP 3 'D:ORACLEORADATAORCLREDO03.LOG' SIZE 100M

DATAFILE
'D:ORACLEORADATAORCLSYSTEM01.DBF',
'D:ORACLEORADATAORCLUNDOTBS01.DBF',
'D:ORACLEORADATAORCLCWMLITE01.DBF',
'D:ORACLEORADATAORCLDRSYS01.DBF',
'D:ORACLEORADATAORCLEXAMPLE01.DBF',
'D:ORACLEORADATAORCLINDX01.DBF',
'D:ORACLEORADATAORCLODM01.DBF',
'D:ORACLEORADATAORCLTOOLS01.DBF',
'D:ORACLEORADATAORCLUSERS01.DBF',
'D:ORACLEORADATAORCLXDB01.DBF',
'D:ORACLEORADATAORCLRMAN_TS.DBF'
CHARACTER SET ZHS16GBK
;

数据文件就可以创建了

2 执行RECOVER DATABASE命令即可

3打开数据库

ALTER DATABASE OPEN;

二 在RESETLOGS状态下创建,要比上面麻烦一些,也是先执行以下脚本

CREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS NOARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 50
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 226
LOGFILE
GROUP 1 'D:ORACLEORADATAORCLREDO01.LOG' SIZE 100M,
GROUP 2 'D:ORACLEORADATAORCLREDO02.LOG' SIZE 100M,
GROUP 3 'D:ORACLEORADATAORCLREDO03.LOG' SIZE 100M
-- STANDBY LOGFILE

DATAFILE
'D:ORACLEORADATAORCLSYSTEM01.DBF',
'D:ORACLEORADATAORCLUNDOTBS01.DBF',
'D:ORACLEORADATAORCLCWMLITE01.DBF',
'D:ORACLEORADATAORCLDRSYS01.DBF',
'D:ORACLEORADATAORCLEXAMPLE01.DBF',
'D:ORACLEORADATAORCLINDX01.DBF',
'D:ORACLEORADATAORCLODM01.DBF',
'D:ORACLEORADATAORCLTOOLS01.DBF',
'D:ORACLEORADATAORCLUSERS01.DBF',
'D:ORACLEORADATAORCLXDB01.DBF',
'D:ORACLEORADATAORCLRMAN_TS.DBF'
CHARACTER SET ZHS16GBK
;

然后执行命令

RECOVER DATABASE USING BACKUP CONTROLFILE

该命令会寻找日志文件,将日志文件拖入命令窗口执行成功即可

SQL> recover database using backup controlfile;
ORA-00279: change 3772053 generated at 11/27/2007 16:45:02 needed for thread 1
ORA-00289: suggestion : D:ORACLEORA92RDBMSARC00022.001
ORA-00280: change 3772053 for thread 1 is in sequence #22


Specify log: {=suggested | filename | AUTO | CANCEL}
D:oracleoradataorclREDO03.LOG
Log applied.
Media recovery complete.

打开数据库,必须在RESETLOGS下打开

SQL> alter database open resetlogs;

Database altered.

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9845526/viewspace-985450/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: 没有了~
请登录后发表评论 登录
全部评论
  • 博文量
    1
  • 访问量
    916