log_archive_min_succeed_dest的一次实验

LOG_ARCHIVE_MIN_SUCCEED_DEST defines the minimum number of destinations that must succeed in order for the online logfile to be available for reuse.

看文档时看到这个参数,有点疑惑,网上查了下更疑惑了。ocp-053中有考题如下:

You have configured flash recovery area in your database and you set the following Initialization parameters
for your database instance:
LOG_ARCHIVE_DEST 1 = ,,LOCATION=/disk1/arch MANDATORY'
LOG _ARCHIEVE_DEST 2 = ,,LOCATION=/disk2/arch'
LOG_ARCHIVK_DEST_3 = ,,LOCATION=/diSk3/arch
LOG_ARCH1VK_DEST_4 = ' LOCATION=/disk4/arch'
LOG_ARCHIVE_MIN-SUCCEED_DEST = 2
While the database instance is functional, you realized that the destination set by the
LOG_ARCHIVE_DEST_I parameter Is not available for the archived redo log file to be created in. All redo
log groups have been used. What happens in an event of log switch?
A. The online redo log file Is not allowed to be overwritten.
B. The archived redo log files are written to the flash recovery area until the MANDATORY destination is
made available.
C. The database instance will crash because the archived redo log file cannot be created in a destination
set as MANDATORY.
D. The destination set by the LOG_ARCHIVE_DEST_1 parameter is ignored and the archived redo log files
are created in the next two available locations to guarantee archive log success.
Answer: D

这里的mandatory是 log_archive_dest_n中的一个参数,官方解释如下:

mandatory:必须归档成功
 Specifies that the transmission of redo data to the destination must succeed before the local online redo log file can be made available for reuse. If the MANDATORY attribute is not specified, then the destination is optional.

两者有冲突,另怀疑 log_archive_min_succeed_dest的作用
大致实验步骤如下:定义三个归档路径,其中一个为mandatory,定义该参数为3,将man的那个目录取消,切换日志,查看是否会hang

1.定义三个归档路径

SQL> alter system set log_archive_dest_1 = 'location=use_db_recovery_file_dest' scope=both;

System altered

SQL> alter system set log_archive_dest_2 = 'location=F:lab2013-7-14log2 mandatory' scope=both;  

System altered

SQL> alter system set log_archive_dest_3 = 'location=F:lab2013-7-14log3' scope=both;  

System altered

SQL> alter system switch logfile;

System altered
这边在路径2,3中生成的归档日志名是一样的,根据log_archive_format中所定义的格式生成,但是在闪回恢复区中的名字不一样(这里记录一下,以后看)

2.定义参数
SQL> show parameter log_archive_min_succeed_dest;
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_min_succeed_dest         integer     1

默认为1,这里将其改为3
SQL> alter system set log_archive_min_succeed_dest=3 scope=both;
 
System altered

3.将路径3移除
F:lab2013-7-14log3  --> F:lab2013-7-14log3-out

切换日志,结果如图:

本该在路径3下生成的归档,到路径3的父目录下生成了,这是不是该参数定义的保障呢?
将参数切换为2,再试试
结果如下图:

看来和这个参数没有关系,只要定义了路径,他就会往父目录送
但是注意,这里的文件名和路径2里的不同,它将路径3丢失的文件夹名包含了其中

这时查看v$archive_dest的信息,很怪,出乎我意料了,竟然没有错误信息,并且全是可用

SQL> select dest_name,status,error from v$archive_dest;
 
DEST_NAME                                                                        STATUS    ERROR
-------------------------------------------------------------------------------- --------- -----------------------------
LOG_ARCHIVE_DEST_1                                                               VALID     
LOG_ARCHIVE_DEST_2                                                               VALID     
LOG_ARCHIVE_DEST_3                                                               VALID     

4.将路径2移除
有意思了,切换结果如下图:


就算设置了该参数,但是归档依然在父目录生成
 v$archive_dest中的数据也是没有变化

SQL> select dest_name,status,error from v$archive_dest;
 
DEST_NAME                                                                        STATUS    ERROR
-------------------------------------------------------------------------------- --------- -----------------
LOG_ARCHIVE_DEST_1                                                               VALID     
LOG_ARCHIVE_DEST_2                                                               VALID     
LOG_ARCHIVE_DEST_3                                                               VALID     

以上实验证明了两件事:

log_archive_min_succeed_dest这个参数的确是没有用,他并不能保证生成的归档日志数量(这个猜想其实也不对,毕竟实验中生成了3次归档)

不管是否设置了mandatory,当归档路径找不到时,它就会回到父目录下(也即是mandatory这个参数么有用。这里有个猜想,如果我整个F盘读没有了,那么会如何,下次用u盘,尝试一下)

有趣的地方出现了,推翻了我前面的理论

SQL> alter system set log_archive_dest_3='' scope=both;
 
alter system set log_archive_dest_3='' scope=both
 
ORA-02097: 无法修改参数, 因为指定的值无效
ORA-16028: 新 LOG_ARCHIVE_DEST_3 导致少于 LOG_ARCHIVE_MIN_SUCCEED_DEST 所需的目的地数量

看来这个参数的真正意义在于限定本地归档目录的数量。

稍后我会做一个在u盘上的相关实验,证明括号中的猜想

参考文档:

http://www.itpub.net/forum.php?mod=viewthread&tid=1756370

http://www.itpub.net/forum.php?mod=viewthread&tid=1119087

http://docs.oracle.com/cd/E11882_01/server.112/e25494/archredo006.htm

原文地址:https://www.cnblogs.com/archersun/p/3190168.html