控制文件重建

回复 收藏
本帖最后由 spain.yx 于 2010-3-16 02:59 编辑

重建控制文件实验

相关知识点:

控制文件是二进制文件,记录了数据库的结构、行为等重要信息。在mount状态的时候读,openu时,一直会使用。
控制文件应采用多路复用,如果丢失,会使恢复数据库增加难度,并不是致命问题。

The control file is a fairly small file (it can grow up to 64MB or so in extreme cases) that contains
a directory of the other files Oracle needs. The parameter file tells the instance where the
control files are, and the control files tell the instance where the database and online redo log
files are.
The control files also tell Oracle other things, such as information about checkpoints that
have taken place, the name of the database (which should match the DB_NAME parameter), the
timestamp of the database as it was created, an archive redo log history (this can make a control
file large in some cases), RMAN information, and so on.
Control files should be multiplexed either by hardware (RAID) or by Oracle when RAID or
mirroring is not available. More than one copy of them should exist, and they should be stored
on separate disks, to avoid losing them in the event you have a disk failure. It is not fatal to
lose your control files—it just makes recovery that much harder.
Control files are something a developer will probably never have to actually deal with.
To a DBA they are an important part of the database, but to a software developer they are not
extremely relevant.(摘自:Expert Oralce Database Architecture)


> sqlplus / as sysdba

SQL> alter database backup controlfile to trace;
      备份创建控制文件的脚本到TRC文件
SQL> !
> cd /oracle/PRD/saptrace/usertrace
      查看参数文件得到,udump为此目录
> ls -lt
total 50
-rw-r-----   1 oraprd     dba          10593 Mar  1 13:54 prd_ora_4331.trc
      生成的trc文件
> cp prd_ora_4331.trc recreatctl.sql
      复制成为SQL脚本
>vi recreatctl.sql
      可根据自己的需求来修改参数
>exit
SQL>show parameter control
    找到控制文件位置,删除控制文件

-------------------------------------------
为保证数据库能正常启动,以及本实验的成功
rman 备份控制文件

> rman target sys/sys nocatalog
  登陆RMAN
RMAN> backup current controlfile;
     只备份控制文件
--------------------------------------------

SQL> shutdown immediate;
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/oracle/PRD/origlogA/cntrl/cntrlPRD.dbf'
ORA-27041: unable to open file
HPUX-ia64 Error: 2: No such file or directory
Additional information: 3
    无法关闭数据库,
SQL> shutdown abort
ORACLE instance shut down.
    强制关闭
SQL> exit
>sqlplus / as sysdba
SQL> set echo on
     打开屏幕显示
SQL> @/dir/recreatctl.sql
    执行脚本,生成控制文件
SQL> shutdown immediate
SQL> startup
     重启数据库   
SQL> Select * from v$controlfile;
     查看控制文件

此实验成功完成。
2010-03-01 16:06 举报
已邀请:

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: