Oracle 控制文件的备份

        Oracle 的控制文件是Oracle数据库运行的核心文件,如果控制文件丢失并且不能恢复,那后果是很严重的,可使数据库不能启动。 

        Oracle提供的控制文件备份的方法有以下两种:

第一、生成备份文件

    这是最常用的方法:

SQL> alter database backup controlfile to 'c:/controlfile.bak';

数据库已更改。

最终控制文件被备份到 c:/controlfile.bak, 文件的扩展名可以自已定义,不会对备份有影响。

第二、生成控制文件创建脚本

SQL> alter database backup controlfile to trace;

数据库已更改。

脚本内容如下:

文件存放在:D:/oracle/admin/ora92/udump:

Dump file d:/oracle/admin/ora92/udump/ora92_ora_3500.trc
Tue Nov 21 16:06:04 2006
ORACLE V9.2.0.1.0 - Production vsnsta=0
vsnsql=12 vsnxtr=3
Windows 2000 Version 5.2 Service Pack 1, CPU type 586
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
Windows 2000 Version 5.2 Service Pack 1, CPU type 586
Instance name: ora92

Redo thread mounted by this instance: 1

Oracle process number: 12

Windows thread id: 3500, image: ORACLE.EXE


*** SESSION ID:(11.283) 2006-11-21 16:06:04.000
*** 2006-11-21 16:06:04.000
# 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.%T
# REMOTE_ARCHIVE_ENABLE=TRUE
# LOG_ARCHIVE_START=TRUE
# LOG_ARCHIVE_MAX_PROCESSES=2
# STANDBY_FILE_MANAGEMENT=MANUAL
# STANDBY_ARCHIVE_DEST=%ORACLE_HOME%/RDBMS
# FAL_CLIENT=''
# FAL_SERVER=''
#
# LOG_ARCHIVE_DEST_1='LOCATION=d:/oracle/ora92/RDBMS'
# LOG_ARCHIVE_DEST_1='MANDATORY NOREOPEN NODELAY'
# LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM SYNC'
# LOG_ARCHIVE_DEST_1='NOREGISTER NOALTERNATE NODEPENDENCY'
# LOG_ARCHIVE_DEST_1='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED'
# LOG_ARCHIVE_DEST_STATE_1=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 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 "ORA92" NORESETLOGS  ARCHIVELOG
--  SET STANDBY TO MAXIMIZE PERFORMANCE
    MAXLOGFILES 5
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 1
    MAXLOGHISTORY 454
LOGFILE
  GROUP 1 'D:/ORACLE/ORADATA/ORA92/REDO01.LOG'  SIZE 10M,
  GROUP 2 'D:/ORACLE/ORADATA/ORA92/REDO02.LOG'  SIZE 10M,
  GROUP 3 'D:/ORACLE/ORADATA/ORA92/REDO03.LOG'  SIZE 10M
-- STANDBY LOGFILE
DATAFILE
  'D:/ORACLE/ORADATA/ORA92/SYSTEM01.DBF',
  'D:/ORACLE/ORADATA/ORA92/UNDOTBS01.DBF',
  'D:/ORACLE/ORADATA/ORA92/INDX01.DBF',
  'D:/ORACLE/ORADATA/ORA92/TOOLS01.DBF',
  'D:/ORACLE/ORADATA/ORA92/USERS01.DBF',
  'D:/ORACLE/ORADATA/ORA92/SP01.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
# All logs need archiving and a log switch is needed.
ALTER SYSTEM ARCHIVE LOG ALL;
# 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/ORADATA/ORA92/TEMP01.DBF'
     SIZE 41943040  REUSE AUTOEXTEND OFF;
# 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 "ORA92" RESETLOGS  ARCHIVELOG
--  SET STANDBY TO MAXIMIZE PERFORMANCE
    MAXLOGFILES 5
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 1
    MAXLOGHISTORY 454
LOGFILE
  GROUP 1 'D:/ORACLE/ORADATA/ORA92/REDO01.LOG'  SIZE 10M,
  GROUP 2 'D:/ORACLE/ORADATA/ORA92/REDO02.LOG'  SIZE 10M,
  GROUP 3 'D:/ORACLE/ORADATA/ORA92/REDO03.LOG'  SIZE 10M
-- STANDBY LOGFILE
DATAFILE
  'D:/ORACLE/ORADATA/ORA92/SYSTEM01.DBF',
  'D:/ORACLE/ORADATA/ORA92/UNDOTBS01.DBF',
  'D:/ORACLE/ORADATA/ORA92/INDX01.DBF',
  'D:/ORACLE/ORADATA/ORA92/TOOLS01.DBF',
  'D:/ORACLE/ORADATA/ORA92/USERS01.DBF',
  'D:/ORACLE/ORADATA/ORA92/SP01.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;
# 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/ORADATA/ORA92/TEMP01.DBF'
     SIZE 41943040  REUSE AUTOEXTEND OFF;
# End of tempfile additions.
#

如果控制文件丢失,就可以用上面的脚本创建一个新的控制文件。

当然,也可以直接复制文件来备份,但是如果复制的时候有变化的话,控制文件是会出错的,以上两种方法首先ORACLE 会把文件读到内存,再从内存备份,保证控制文件的一致性。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值