重建控制文件

实验:重建控制文件
1、open状态下执行脚本
SQL> alter database backup controlfile to trace noresetlogs;

Database altered.
2、udump目录,查看最新的跟踪文件(ls -trl)
$ cd $ORACLE_BASE/admin/$ORACLE_SID/udump下,找出最后的重建脚本如下:

STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ZWB" NORESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/oracle/oradata/zwb/redo01.log'  SIZE 50M,
  GROUP 2 '/oracle/oradata/zwb/redo02.log'  SIZE 50M,
  GROUP 3 '/oracle/oradata/zwb/redo03.log'  SIZE 50M
-- STANDBY LOGFILE
DATAFILE
  '/oracle/oradata/zwb/system01.dbf',
  '/oracle/oradata/zwb/undotbs01.dbf',
  '/oracle/oradata/zwb/sysaux01.dbf',
  '/oracle/oradata/zwb/users01.dbf',
  '/oracle/oradata/zwb/example01.dbf'
CHARACTER SET ZHS16GBK
;

ALTER DATABASE OPEN;
ALTER TABLESPACE TEMP ADD TEMPFILE '/oracle/oradata/zwb/temp01.dbf' SIZE 20971520  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;

注意:要截取3个部分,去掉空格

 


3、关闭数据库(最好用这个命令关)
SQL> shutdown immediate;


4、备份控制文件(用操作系统命令cp)

5、利用生成的脚本重新创建控制文件(要到nomount状态)

SQL> CREATE CONTROLFILE REUSE DATABASE "ZWB" NORESETLOGS  ARCHIVELOG
  2      MAXLOGFILES 16
  3      MAXLOGMEMBERS 3
  4      MAXDATAFILES 100
  5      MAXINSTANCES 8
  6      MAXLOGHISTORY 292
  7  LOGFILE
  8    GROUP 1 '/oracle/oradata/zwb/redo01.log'  SIZE 50M,
  9    GROUP 2 '/oracle/oradata/zwb/redo02.log'  SIZE 50M,
 10    GROUP 3 '/oracle/oradata/zwb/redo03.log'  SIZE 50M
 11  -- STANDBY LOGFILE
 12  DATAFILE
 13    '/oracle/oradata/zwb/system01.dbf',
 14    '/oracle/oradata/zwb/undotbs01.dbf',
 15    '/oracle/oradata/zwb/sysaux01.dbf',
 16    '/oracle/oradata/zwb/users01.dbf',
 17    '/oracle/oradata/zwb/example01.dbf'
 18  CHARACTER SET ZHS16GBK
 19  ;


6.打开数据库,并添加temp文件
ALTER DATABASE OPEN;
ALTER TABLESPACE TEMP ADD TEMPFILE '/oracle/oradata/zwb/temp01.dbf' SIZE 20971520  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;

 


注意点:如果之前是强制写模式
1)如果之前是强制写模式,重建后数据库是为非强制写模式:
select force_logging from v$database;

alter database force logging;

2)如果之前是闪回模式,重建后数据库是为非闪回模式:
select flashback_on  from v$database;
startup mount;
alter database flashback on;
 

你可能感兴趣的:(职场,休闲,重建控制文件)