若系统中缺少联机日志,以resetlogs方式重建控制文件,那么当我们以alter database open resetlogs方式打开数据库时,新生成的联机日志会位于何处?
推荐阅读:
Oracle恢复内部原理(重置日志resetlogs)
Oracle控制文件备份恢复 resetlogs方式
Oracle控制文件备份恢复 noresetlogs 恢复
Oracle Rman跨resetlogs版本恢复
二:实验
实验1 重建控制文件语句未指定日志条目,未指定omf参数,那么resetlogs打开数据库后日志位置
1 实验前提
重建控制文件中不指定日志条目语句如下
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ZBCRM" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
DATAFILE
'/oracle/CRM/ZBCRM/system01.dbf',
'/oracle/CRM/ZBCRM/sysaux01.dbf',
'/oracle/CRM/ZBCRM/undotbs01.dbf',
'/oracle/CRM/ZBCRM/users01.dbf',
'/oracle/CRM/ZBCRM/sysaux02.dbf'
CHARACTER SET ZHS16GBK
;
参数文件中未指定omf参数
NAME VALUE
---------------------------------------- --------------------------------------------------
db_create_file_dest
db_create_online_log_dest_1
db_create_online_log_dest_2
db_create_online_log_dest_3
db_create_online_log_dest_4
db_create_online_log_dest_5
db_recovery_file_dest
db_recovery_file_dest_size 0
2 过程如下:
SQL> @/oracle/control1.sql
ORACLE instance started.
Total System Global Area 1152450560 bytes
Fixed Size 2225832 bytes
Variable Size 704645464 bytes
Database Buffers 436207616 bytes
Redo Buffers 9371648 bytes
Control file created.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SQL> col member for a50
SQL> select group#,member from v$logfile;
GROUP# MEMBER
---------- --------------------------------------------------
2 /oracle/app/db1/dbs/log2ZBCRM.dbf
1 /oracle/app/db1/dbs/log1ZBCRM.dbf
结果:当控制文件重建语句中未指定日志条目,也未设置omf参数,那么resetlogs 打开数据库后新创建的日志文件位于dbs目录下。
实验2 重建控制文件语句中未指定了日志位置,指定omf参数,那么resetlogs打开数据库后日志位置
1 实验前提
重建控制文件语句如下
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ZBCRM" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
DATAFILE
'/oracle/CRM/ZBCRM/system01.dbf',
'/oracle/CRM/ZBCRM/sysaux01.dbf',
'/oracle/CRM/ZBCRM/undotbs01.dbf',
'/oracle/CRM/ZBCRM/users01.dbf',
'/oracle/CRM/ZBCRM/sysaux02.dbf'
CHARACTER SET ZHS16GBK
;
参数文件中指定omf参数
NAME VALUE
---------------------------------------- ----------------------------------------
db_create_file_dest /oracle/CRM/ZBCRM/
db_create_online_log_dest_1
db_create_online_log_dest_2
db_create_online_log_dest_3
db_create_online_log_dest_4
db_create_online_log_dest_5
db_recovery_file_dest
db_recovery_file_dest_size 0
2 实验过程如下:
[oracle@oracle ~]$ cat control1.sql
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ZBCRM" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
DATAFILE
'/oracle/CRM/ZBCRM/system01.dbf',
'/oracle/CRM/ZBCRM/sysaux01.dbf',
'/oracle/CRM/ZBCRM/undotbs01.dbf',
'/oracle/CRM/ZBCRM/users01.dbf',
'/oracle/CRM/ZBCRM/sysaux02.dbf'
CHARACTER SET ZHS16GBK
;
[oracle@oracle ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Fri Jul 26 16:33:49 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to an idle instance.
SQL> @/oracle/control1.sql
ORACLE instance started.
Total System Global Area 1152450560 bytes
Fixed Size 2225832 bytes
Variable Size 704645464 bytes
Database Buffers 436207616 bytes
Redo Buffers 9371648 bytes
Control file created.
SQL> alter database open resetlogs;
Database altered.
SQL> col member for a60
SQL> /
GROUP# MEMBER
---------- ------------------------------------------------------------
2 /oracle/CRM/ZBCRM/ZBCRM/onlinelog/o1_mf_2_8z4f4kon_.log
1 /oracle/CRM/ZBCRM/ZBCRM/onlinelog/o1_mf_1_8z4f4gcl_.log
结果:当重建控制文件语句中为指定日志条目,仅指定omf参数db_create_file_dest时,resetlogs打开数据库后,日志位于db_create_file_dest指定的目录。