你好,游客 登录 注册 搜索
背景:
阅读新闻

Oracle控制文件基本维护

[日期:2012-05-16] 来源:Linux社区  作者:gtlions [字体:大 中 小]
3. 如何恢复控制文件
针对上述2中备份方式我们来进行恢复控制文件。
3.0. trace文本文件恢复。
我们这里来将现有的4个控制文件全部改名,然后恢复。
模拟丢失控制文件:
[Oracle@ www.linuxidc.com gt9i]$ mv control01.ctl c1.ctl;mv control02.ctl c2.ctl ;mv control03.ctl c3.ctl;mv controlTEST.ctl cTEST.ctl
[oracle@ www.linuxidc.com gt9i]$ ll c*
-rw-r-----  1 oracle oinstall  2023424  4月 11 16:13 c1.ctl
-rw-r-----  1 oracle oinstall  2023424  4月 11 16:13 c2.ctl
-rw-r-----  1 oracle oinstall  2023424  4月 11 16:13 c3.ctl
-rw-r-----  1 oracle oinstall  2023424  4月 11 16:13 cTEST.ctl
ys@ www.linuxidc.com> startup
ORACLE instance started.

Total System Global Area  286752136 bytes
Fixed Size             740744 bytes
Variable Size          150994944 bytes
Database Buffers      134217728 bytes
Redo Buffers             798720 bytes
ORA-00205: error in identifying controlfile, check alert log for more info


sys@ www.linuxidc.com> shutdown immediate;
ORA-01507: database not mounted


ORACLE instance shut down.
sys@ www.linuxidc.com> startup nomount;
ORACLE instance started.

Total System Global Area  286752136 bytes
Fixed Size             740744 bytes
Variable Size          150994944 bytes
Database Buffers      134217728 bytes
Redo Buffers             798720 bytes
毫无疑问启动失败,只能nomount实例。接下来我们看下刚刚备份的trace的内容:
[oracle@ www.linuxidc.com oracle]$ cat gt9icontrol.trc
# 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 "GT9I" NORESETLOGS  NOARCHIVELOG
--  SET STANDBY TO MAXIMIZE PERFORMANCE
    MAXLOGFILES 50
    MAXLOGMEMBERS 5
    MAXDATAFILES 100
    MAXINSTANCES 1
    MAXLOGHISTORY 226
LOGFILE
  GROUP 1 '/u01/oracle/9i/oradata/gt9i/redo01.log'  SIZE 100M,
  GROUP 2 '/u01/oracle/9i/oradata/gt9i/redo02.log'  SIZE 100M,
  GROUP 3 '/u01/oracle/9i/oradata/gt9i/redo03.log'  SIZE 100M,
  GROUP 4 (
    '/u01/oracle/9i/oradata/gt9i/log4.ora',
    '/u01/oracle/9i/oradata/gt9i/log5.rdo'
  ) SIZE 30M
-- STANDBY LOGFILE

DATAFILE
  '/u01/oracle/9i/oradata/gt9i/system01.dbf',
  '/u01/oracle/9i/oradata/gt9i/undotbs01.dbf',
  '/u01/oracle/9i/oradata/gt9i/cwmlite01.dbf',
  '/u01/oracle/9i/oradata/gt9i/drsys01.dbf',
  '/u01/oracle/9i/oradata/gt9i/example01.dbf',
  '/u01/oracle/9i/oradata/gt9i/indx01.dbf',
  '/u01/oracle/9i/oradata/gt9i/odm01.dbf',
  '/u01/oracle/9i/oradata/gt9i/tools01.dbf',
  '/u01/oracle/9i/oradata/gt9i/users01.dbf',
  '/u01/oracle/9i/oradata/gt9i/xdb01.dbf',
  '/u01/oracle/9i/oradata/gt9i/oem_repository.dbf',
  '/u01/oracle/9i/oradata/gt9i/gtlions01.ora'
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;

# Commands to add tempfiles to temporary tablespaces.
# Online tempfiles have complete space information.
# Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/oracle/9i/oradata/gt9i/temp01.dbf'
     SIZE 41943040  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
ALTER TABLESPACE GTLIONSTMP ADD TEMPFILE '/u01/oracle/9i/oradata/gt9i/gtlionstmp01.ora'
     SIZE 10485760  REUSE AUTOEXTEND ON NEXT 5242880  MAXSIZE 104857600 ;
# End of tempfile additions.
#
#     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 "GT9I" RESETLOGS  NOARCHIVELOG
--  SET STANDBY TO MAXIMIZE PERFORMANCE
    MAXLOGFILES 50
    MAXLOGMEMBERS 5
    MAXDATAFILES 100
    MAXINSTANCES 1
    MAXLOGHISTORY 226
LOGFILE
  GROUP 1 '/u01/oracle/9i/oradata/gt9i/redo01.log'  SIZE 100M,
  GROUP 2 '/u01/oracle/9i/oradata/gt9i/redo02.log'  SIZE 100M,
  GROUP 3 '/u01/oracle/9i/oradata/gt9i/redo03.log'  SIZE 100M,
  GROUP 4 (
    '/u01/oracle/9i/oradata/gt9i/log4.ora',
    '/u01/oracle/9i/oradata/gt9i/log5.rdo'
  ) SIZE 30M
-- STANDBY LOGFILE

DATAFILE
  '/u01/oracle/9i/oradata/gt9i/system01.dbf',
  '/u01/oracle/9i/oradata/gt9i/undotbs01.dbf',
  '/u01/oracle/9i/oradata/gt9i/cwmlite01.dbf',
  '/u01/oracle/9i/oradata/gt9i/drsys01.dbf',
  '/u01/oracle/9i/oradata/gt9i/example01.dbf',
  '/u01/oracle/9i/oradata/gt9i/indx01.dbf',
  '/u01/oracle/9i/oradata/gt9i/odm01.dbf',
  '/u01/oracle/9i/oradata/gt9i/tools01.dbf',
  '/u01/oracle/9i/oradata/gt9i/users01.dbf',
  '/u01/oracle/9i/oradata/gt9i/xdb01.dbf',
  '/u01/oracle/9i/oradata/gt9i/oem_repository.dbf',
  '/u01/oracle/9i/oradata/gt9i/gtlions01.ora'
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;

# Commands to add tempfiles to temporary tablespaces.
# Online tempfiles have complete space information.
# Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/oracle/9i/oradata/gt9i/temp01.dbf'
     SIZE 41943040  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
ALTER TABLESPACE GTLIONSTMP ADD TEMPFILE '/u01/oracle/9i/oradata/gt9i/gtlionstmp01.ora'
     SIZE 10485760  REUSE AUTOEXTEND ON NEXT 5242880  MAXSIZE 104857600 ;
# End of tempfile additions.
#linux
相关资讯       oracle数据库教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款