URL: http://hi.baidu.com/xyw636/blog/item/c55fbf3d762cf107bba167f4.html/cmtid/a2f814a8fe6c64bdca130c3d
刚由SQLPLUS进入数据时出现ORA-27034:ORACLE not available ORA-27101:shared memory realm does not exist错误,然后查看oradim.log文件,发现如下错误信息:ORA-00214: control file 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL02.CTL' version 1253 inconsistent with file 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL01.CTL' version 1228 这是由于控制文件CONTROL02.CTL'版本跟CONTROL01.CTL'版本不同导致,所以数据库Instance启动时报错。
目前状态下我的控制文件版本CONTROL02.CTL比CONTROL01.CTL版本高。
如果你只是学习ORACLE, 目前环境只是一个实验环境,此问题很好解决,因为两个控制文件版本不一致,所以你把旧版本的控制文件删除掉,然后把新版本的复制,重名名为刚删掉的文件的文件名,这样就可以了.
但如果是非实验环境,可以考虑用下面的方法,用新版本的控制文件重建数据库.
先备份控制文件,然后进入命令行下的SQLPLUS, 以非加载方式(nomoun)启动数据库(startup nomount), 指定系统控制文件为CONTROL02.CTL:
ALTER SYSTEM SET CONTROL_FILES='C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL02.CTL'
SCOPE=SPFILE
(设置数据库初始化参数,制定控制文件为CONTROL02.CTL)
停止数据库( shutdown),然后 以加载方式(moun)启动数据库(startup mount),如果不报错,说明已经成功了,因为以MOUNT方式启动数据库是,ORACLE启动实例并打开控制文件。
(读者的应该指定哪个控制文件应该根据实际情况,如果CONTROL02.CTL不行,可以试试其它的)
如果上面成功后,读者试图启动数据库,可能会发生错误 ORA-01110: data file 1: C:\oracle\product\10.2.0\oradata\orcl/xxx'
ORA-01207: file is more recent than controlfile - old controlfile
原因是现在控制文件的版本比数据文件的低,所以 还有一重要工作就是需要建立新的控制文件。在此种情况下,可以用下面方法恢复,但是将数据库恢复到目前控制文件如 CONTROL02.CTL的版本,这有可能造成你目前数据库的数据回滚
步骤如下:
1、ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
(把controlfile备份到trace文件中,执行后在udump目录下会有一个trace文件,里面就是重建controlfile的sql)
这时会在udump目录下生成trace文件。
2.SQL>startup nomount;
3.打开trace文件,里面有两部分脚本,如果你的DB运行在非归档模式下运行第一部分脚本,否则第二部分。比如我的脚本如下:
Dump file c:\oracle\product\10.2.0\admin\orcl\udump\orcl_ora_4320.trc
Fri Jun 13 18:28:07 2008
ORACLE V10.2.0.1.0 - Production vsnsta=0
vsnsql=14 vsnxtr=3
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Windows XP Version V5.1 Service Pack 2
CPU : 2 - type 586
Process Affinity : 0x00000000
Memory (Avail/Total): Ph:395M/989M, Ph+PgF:1210M/2387M, VA:1629M/2047M
Instance name: orcl
Redo thread mounted by this instance: 1
Oracle process number: 16
Windows thread id: 4320, image: ORACLE.EXE (SHAD)
*** SERVICE NAME:() 2008-06-13 18:28:07.001
*** SESSION ID:(159.3) 2008-06-13 18:28:07.001
*** 2008-06-13 18:28:07.001
-- The following are current System-scope REDO Log Archival related
-- parameters and can be included in the database initialization file.
--
-- LOG_ARCHIVE_DEST=''
-- LOG_ARCHIVE_DUPLEX_DEST=''
--
-- LOG_ARCHIVE_FORMAT=ARC%S_%R.%T
--
-- DB_UNIQUE_NAME="orcl"
--
-- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG'
-- LOG_ARCHIVE_MAX_PROCESSES=2
-- STANDBY_FILE_MANAGEMENT=MANUAL
-- STANDBY_ARCHIVE_DEST=%ORACLE_HOME%\RDBMS
-- FAL_CLIENT=''
-- FAL_SERVER=''
--
-- LOG_ARCHIVE_DEST_10='LOCATION=USE_DB_RECOVERY_FILE_DEST'
-- LOG_ARCHIVE_DEST_10='OPTIONAL REOPEN=300 NODELAY'
-- LOG_ARCHIVE_DEST_10='ARCH NOAFFIRM NOEXPEDITE NOVERIFY SYNC'
-- LOG_ARCHIVE_DEST_10='REGISTER NOALTERNATE NODEPENDENCY'
-- LOG_ARCHIVE_DEST_10='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED NODB_UNIQUE_NAME'
-- LOG_ARCHIVE_DEST_10='VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILES)'
-- LOG_ARCHIVE_DEST_STATE_10=ENABLE
--
-- 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 Recovery Manager will be lost.
-- Additional logs may be required for media recovery of offline
-- Use this only if the current versions of all online logs are
-- available.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01.LOG' SIZE 50M,
GROUP 2 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02.LOG' SIZE 50M,
GROUP 3 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03.LOG' SIZE 50M,
GROUP 4 (
'C:\ORACLELEARNING\ORACLELOGFILE\REDO01B.LOG',
'C:\ORACLELEARNING\ORACLELOGFILE\REDO02B.LOG',
'C:\ORACLELEARNING\ORACLELOGFILE\REDO03B.LOG'
) SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF',
'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF',
'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF',
'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF',
'C:\ORACLELEARNING\TABLEPACES\JINLIAN01.DBF',
'C:\ORACLELEARNING\TABLEPACES\JINLIAN02.DBF',
'C:\ORACLELEARNING\TABLEPACES\JINLIAN_INDEX.DBF',
'C:\ORACLELEARNING\TABLEPACES\JINLIAN_UNDO.DBF'
CHARACTER SET AL32UTF8
;
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE 'C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_13\O1_MF_1_1_%U_.ARC';
-- 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;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP01.DBF' REUSE;
ALTER TABLESPACE JINLIAN_TEMP ADD TEMPFILE 'C:\ORACLELEARNING\TABLEPACES\JINLIAN_TEMP.DBF' REUSE;
-- End of tempfile additions.
--
-- Set #2. RESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01.LOG' SIZE 50M,
GROUP 2 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02.LOG' SIZE 50M,
GROUP 3 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03.LOG' SIZE 50M,
GROUP 4 (
'C:\ORACLELEARNING\ORACLELOGFILE\REDO01B.LOG',
'C:\ORACLELEARNING\ORACLELOGFILE\REDO02B.LOG',
'C:\ORACLELEARNING\ORACLELOGFILE\REDO03B.LOG'
) SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF',
'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF',
'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF',
'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF',
'C:\ORACLELEARNING\TABLEPACES\JINLIAN01.DBF',
'C:\ORACLELEARNING\TABLEPACES\JINLIAN02.DBF',
'C:\ORACLELEARNING\TABLEPACES\JINLIAN_INDEX.DBF',
'C:\ORACLELEARNING\TABLEPACES\JINLIAN_UNDO.DBF'
CHARACTER SET AL32UTF8
;
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE 'C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2008_06_13\O1_MF_1_1_%U_.ARC';
-- 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;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE 'C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP01.DBF' REUSE;
ALTER TABLESPACE JINLIAN_TEMP ADD TEMPFILE 'C:\ORACLELEARNING\TABLEPACES\JINLIAN_TEMP.DBF' REUSE;
-- End of tempfile additions.
--
我的数据库运行在非归档模式下,所以运行红色部分的脚本
全部恢复以后,就可以启动数据库,