oracle手工创建控制文件启动数据库
oracle手工创建控制文件
sql>shutdown immediate;
sql>startup
nomount;
sql>alter databse database mount;
sql>alter database backup
controlfile to trace;
注意:sql>alter database backup controlfile to
trace这条SQL必须在数据库mount的情况下才能执行,不如会报ora-01507错误
此时你的控制文件以及转存储到${oracle_home}\admin\orcl\udump\??
本人电脑的路径是:D:\oracle\product\10.2.0\db_1\admin\orcl\udump\orcl_ora_7992.trc(这个文件是最新的,windows下按照时间排序找出最新的那个),
用记事本或者UE打开,内容如下:
Dump
file d:\oracle\product\10.2.0\db_1\admin\orcl\udump\orcl_ora_1108.trc
Mon Jan
13 22:58:22 2014
ORACLE V10.2.0.3.0 - Production vsnsta=0
vsnsql=14
vsnxtr=3
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 -
Production
With the Partitioning, OLAP and Data Mining options
Windows NT
Version V6.1 Service Pack
1
CPU
: 2 - type 586, 2 Physical Cores
Process Affinity :
0x00000000
Memory (Avail/Total): Ph:2038M/3981M, Ph+PgF:5027M/7961M,
VA:3647M/4095M
Instance name: orcl
Redo thread mounted by this instance: 0 <none>
Oracle process number: 15
Windows thread id: 1108, image: ORACLE.EXE (SHAD)
*** 2014-01-13 22:58:22.372
*** SERVICE NAME:() 2014-01-13
22:58:22.366
*** SESSION ID:(159.1) 2014-01-13
22:58:22.366
kccsga_update_ckpt: num_1 = 8, num_2 = 0, num_3 = 0, lbn_2 = 0,
lbn_3 = 0
*** 2014-01-13 22:59:33.557
-- 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
CONTRrOLFILE REUSE DATABASE "ORCL" NORESETLOGS
NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01.LOG‘ SIZE
50M,
GROUP 2 ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02.LOG‘
SIZE 50M,
GROUP 3
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03.LOG‘ SIZE 50M
-- STANDBY
LOGFILE
DATAFILE
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF‘,
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF‘,
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF‘,
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF‘,
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF‘,
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USR_DATA.DBF‘
CHARACTER SET
ZHS16GBK
;
-- 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
‘D:\ORACLE\PRODUCT\10.2.0\DB_1\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2014_01_13\O1_MF_1_1_%U_.ARC‘;
--
ALTER DATABASE REGISTER LOGFILE
‘D:\ORACLE\PRODUCT\10.2.0\DB_1\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2014_01_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 ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP01.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 ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01.LOG‘ SIZE
50M,
GROUP 2 ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02.LOG‘
SIZE 50M,
GROUP 3
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03.LOG‘ SIZE 50M
-- STANDBY
LOGFILE
DATAFILE
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF‘,
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF‘,
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF‘,
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF‘,
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF‘,
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USR_DATA.DBF‘
CHARACTER SET
ZHS16GBK
;
-- 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
‘D:\ORACLE\PRODUCT\10.2.0\DB_1\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2014_01_13\O1_MF_1_1_%U_.ARC‘;
--
ALTER DATABASE REGISTER LOGFILE
‘D:\ORACLE\PRODUCT\10.2.0\DB_1\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2014_01_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
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP01.DBF‘ REUSE;
-- End of tempfile
additions.
--
蓝色部分的SQL就是用来创建控制文件的,下面让我们模拟一下数据库控制文件损坏的情况
SQL>shutdown
immediate;
然后把数据库的控制文件剪切到其他文件夹,此时oracle无法找到控制文件
SQL>startup
nomount;
SQL>alter database
mount;
ora-00205:??????????????
*因为此时oracle找不到控制文件,报0ra-00205错误,当然此时你可以通过修改spfile参数文件,把控制文件的路径修改为你最新的控制文件路径,这个以后再介绍。
此时提供了两种不同SQL创建控制文件,我选了第一种:
SQL>CREATE
CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS NOARCHIVELOG
MAXLOGFILES
16
MAXLOGMEMBERS
3
MAXDATAFILES
100
MAXINSTANCES
8
MAXLOGHISTORY
292
LOGFILE
GROUP 1 ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01.LOG‘ SIZE
50M,
GROUP
2 ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02.LOG‘ SIZE
50M,
GROUP
3 ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03.LOG‘ SIZE
50M
-- STANDBY
LOGFILE
DATAFILE
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF‘,
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF‘,
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF‘,
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF‘,
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF‘,
‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USR_DATA.DBF‘
CHARACTER
SET ZHS16GBK
;
--控制文件已创建
SQL>RECOVER DATABASE;
SQL> ALTER DATABASE
OPEN;
--数据库已更改,此时数据库可以正常open了
--修改临时表空间,*因为刚才的创建控制文件的SQL中没有指定临时表空间,所以要从新设定临时表空间
SQL> ALTER TABLESPACE
TEMP ADD TEMPFILE ‘D:\oracle\product\10.2.0\oradata\orcl\temp01.dbf‘
2 SIZE 41943040 REUSE AUTOEXTEND ON
NEXT 655360 MAXSIZE 32767M;
--数据库可以正常使用,成功!此时再查看D:\oracle\product\10.2.0\oradata\orcl文件夹,同时存在CONTROL01.CTL,CONTROL02.CTL,CONTROL03.CTL,
这表明oracle创建控制文件会自动生成3个。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。