本文共 3947 字,大约阅读时间需要 13 分钟。
一:注意事项:
1 指定reuse
表明被初始化参数CONTROL_FILES 识别的控制文件能够被覆盖使用。如果忽略该参数,任何已经存在的控制文件被数据库检测到,则返回一个报错。
2 指定SET DATABASE
表明要更改数据库的名字,名字长度能达到8个字节。除此之外,你必须指定resetlogs语句,如果你想重新命名数据库的名字,并保留已经存在的日志文件,则创建控制文件语句执行后
使用alter database recover using bakcup controlfile 语句执行一个完全数据库恢复。
3 指定resetlogs
indicate 忽略日志文件内容,或者日志文件不存在。
指定datafile
除了只读表空间的文件(可以之后添加)和临时表空间的数据文件,列出所有数据文件,就算这些文件需要进行恢复。
4 ARCHIVELOG | NOARCHIVELOG
如果忽略了ARCHIVELOG | NOARCHIVELOG oracle默认采用非归档模式。
二实验步骤:
1 以noresetlogs方式创建控制文件,控制文件内容
[oracle@oracle backup]$ cat control.sql
STARTUP NOMOUNT CREATE CONTROLFILE REUSE DATABASE "CRM" NORESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 '/oracle/CRM/redo01.log' SIZE 200M BLOCKSIZE 512, GROUP 2 '/oracle/CRM/redo02.log' SIZE 200M BLOCKSIZE 512, GROUP 3 '/oracle/CRM/redo03.log' SIZE 200M BLOCKSIZE 512, GROUP 4 '/oracle/CRM/redo02.dbf' SIZE 200M BLOCKSIZE 512 DATAFILE '/oracle/CRM/system01.dbf', '/oracle/CRM/sysaux01.dbf', '/oracle/CRM/undotbs01.dbf', '/backup/users01.dbf', '/oracle/CRM/pos.dbf', '/oracle/CRM/erp.dbf', '/oracle/CRM/user01.dbf', '/oracle/CRM/undotbs02.dbf' CHARACTER SET ZHS16GBK ;2 以resetlogs方式创建控制文件,控制文件内容
cat control.sql
STARTUP NOMOUNT CREATE CONTROLFILE REUSE DATABASE "CRM" RESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 '/oracle/CRM/redo01.log' SIZE 200M BLOCKSIZE 512, GROUP 2 '/oracle/CRM/redo02.log' SIZE 200M BLOCKSIZE 512, GROUP 3 '/oracle/CRM/redo03.log' SIZE 200M BLOCKSIZE 512, GROUP 4 '/oracle/CRM/redo02.dbf' SIZE 200M BLOCKSIZE 512 DATAFILE '/oracle/CRM/system01.dbf', '/oracle/CRM/sysaux01.dbf', '/oracle/CRM/undotbs01.dbf', '/backup/users01.dbf', '/oracle/CRM/pos.dbf', '/oracle/CRM/erp.dbf', '/oracle/CRM/user01.dbf', '/oracle/CRM/undotbs02.dbf' CHARACTER SET ZHS16GBK ;3 恢复过程
noresetlogs方式
SQL> @/backup/control.sql
ORACLE instance started.Total System Global Area 1252663296 bytes
Fixed Size 2226072 bytes Variable Size 1006635112 bytes Database Buffers 234881024 bytes Redo Buffers 8921088 bytesControl file created.
SQL> select open_mode from v$database;
OPEN_MODE
-------------------- MOUNTEDSQL> recover database;
ORA-00283: recovery session canceled due to errors ORA-00264: no recovery required SQL> alter database open;Database altered.
resetlogs方式
SQL> @/backup/control.sql
ORACLE instance started.Total System Global Area 1252663296 bytes
Fixed Size 2226072 bytes Variable Size 1006635112 bytes Database Buffers 234881024 bytes Redo Buffers 8921088 bytesControl file created.
SQL> recover database;
ORA-00283: recovery session canceled due to errors ORA-01610: recovery using the BACKUP CONTROLFILE option must be done SQL> recover database using backup controlfile; ORA-00279: change 2526007 generated at 08/26/2012 01:13:10 needed for thread 1 ORA-00289: suggestion : /oracle/archive/1_8_791790817.dbf ORA-00280: change 2526007 for thread 1 is in sequence #8 Specify log: {<RET>=suggested | filename | AUTO | CANCEL} auto ORA-00308: cannot open archived log '/oracle/archive/1_8_791790817.dbf' ORA-27037: unable to obtain file status Linux-x86_64 Error: 2: No such file or directory Additional information: 3 ORA-00308: cannot open archived log '/oracle/archive/1_8_791790817.dbf' ORA-27037: unable to obtain file status Linux-x86_64 Error: 2: No such file or directory Additional information: 3SQL> recover database using backup controlfile until cancel;
ORA-00279: change 2526007 generated at 08/26/2012 01:13:10 needed for thread 1 ORA-00289: suggestion : /oracle/archive/1_8_791790817.dbf ORA-00280: change 2526007 for thread 1 is in sequence #8 Specify log: {<RET>=suggested | filename | AUTO | CANCEL} cancel Media recovery cancelled. SQL> alter database open resetlogs;Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
-------------------- READ WRITE