DB_RECOVERY_FILE_DEST参数是默认的flash
recovery area的路径,里面存放有归档日志、闪回日志以及rman的备份文件等文件。
LOG_ARCHIVE_DEST_n参数是存放归档日志的路径,n表示1~10的一个整数,由于归档日志在recovery的时候担当了重要的角色,所以我们可以设置多个归档目录(最多可以设置10个)。这种情况下,联机日志在归档时,会在不同的目录下都会生成有一个相同的归档文件,通过冗余的来保证归档日志的安全。
系统默认的情况是以DB_RECOVERY_FILE_DEST定义的目录来存放归档日志。但是,课上演示的时候,老师已经设置了log_archive_dest_1、log_archive_dest_2和log_archive_dest_3,三个参数。我现在将这三个参数修改回去,让系统使用默认的DB_RECOVERY_FILE_DEST目录来存放归档日志。
经过下面的操作,发现提示找不到归档的目录。
SQL> alter system set log_archive_dest_1='';
SQL> alter system set log_archive_dest_2='';
SQL> alter system set log_archive_dest_3='';
SQL> alter system archive log current;
alter system archive log current
*
ERROR at line 1:
ORA-16014: log 2 sequence# 50 not archived, no
available destinations
ORA-00312: online log 2 thread 1:
'/opt/ora10g/oradata/orcl/redo02.log'
SQL> archive log list;
Database log modeArchive Mode
Automatic archivalEnabled
Archive destination?/dbs/arch
Oldest online log sequence49
Next log sequence to archive50
Current log sequence51
解决办法,我们暂时先指定一个目录来存放归档日志。然后再修改三个log_archive_dest_n的系统参数时,指定好scope为spfile,重启实例即可。
SQL> alter system set log_archive_dest_1='location=/logs/log_1';
SQL> alter system archive log current;
System altered.
SQL> alter system set log_archive_dest_1='' scope=spfile;
SQL> alter system set log_archive_dest_2='' scope=spfile;
SQL> alter system set log_archive_dest_3='' scope=spfile;
SQL> startup force
ORACLE instance started.
Total System Global Area285212672 bytes
Fixed Size1218992 bytes
Variable Size104859216 bytes
Database Buffers176160768 bytes
Redo Buffers2973696 bytes
Database mounted.
Database opened.
查看一下现在使用的归档的目录,已经成功改回为了DB_RECOVERY_FILE_DEST。
SQL> archive log list;
Database log modeArchive Mode
Automatic archivalEnabled
Archive destinationUSE_DB_RECOVERY_FILE_DEST
Oldest online log sequence51
Next log sequence to archive53
Current log sequence53
最后再查看一下log_archive_dest_n参数,这些参数都没有被设置了,均为空:
SQL> show parameter log_archive_dest
NAMETYPEVALUE
------------------------------------ -----------
------------------------------
log_archive_deststring
log_archive_dest_1string
log_archive_dest_10string
log_archive_dest_2string
log_archive_dest_3string
log_archive_dest_4string
log_archive_dest_5string
log_archive_dest_6string
log_archive_dest_7string
log_archive_dest_8string
log_archive_dest_9string
小结:log_archive_dest_n与DB_RECOVERY_FILE_DEST参数都可以用来存放归档日志,但二者的关系是:不设置log_archive_dest_n时,使用DB_RECOVERY_FILE_DEST来存文件;当设置了log_archive_dest_n时,则使用log_archive_dest_n来存放归档日志。
下面我们,再对log_archive_dest_n进行设置,让DB_RECOVERY_FILE_DEST“失效”。
SQL>alter
system set log_archive_dest_1='location=/logs/log_1' scope=spfile;
SQL>alter
system set log_archive_dest_2='location=/logs/log_2' scope=spfile;
SQL>alter
system set log_archive_dest_3='location=/logs/log_3' scope=spfile;
SQL>
startup force
ORACLE instance
started.
Total System
Global Area 285212672 bytes
Fixed Size1218992 bytes
Variable
Size109053520 bytes
Database
Buffers171966464 bytes
Redo
Buffers2973696 bytes
Database
mounted.
Database opened.
我们进行下手动归档
SQL>
alter system archive log current;
查看下系统时间,发现三个目录下,都已经有了最新的归档日志:
[root@localhost
logs]$ date
Wed Sep1 10:48:39 CST 2010
[root@localhost
logs]# ll -t log_1
-rw-r----- 1
oracle oinstall280576 Sep1 10:48 1_54_723037014.dbf
[root@localhost
logs]# ll -t log_2
-rw-r----- 1
oracle oinstall280576 Sep1 10:48 1_54_723037014.dbf
[root@localhost
logs]# ll -t log_3
-rw-r----- 1
oracle oinstall280576 Sep1 10:48 1_54_723037014.dbf
而DB_RECOVERY_FILE_DEST目录下,已经不再会存放新的归档日志了:
[oracle@localhost
archivelog]$ ll 2010_09_01/
-rw-r----- 1
oracle oinstall 20992 Sep1 10:07
o1_mf_1_52_67vfc7q5_.arc