可以用来解决的问题:单个归档目录满导致数据库hang的问题
多路径归档的实现如下通过LOG_ARCHIVE_DEST_n和log_archive_min_succeed_dest两个参数来控制,具体如下
使用LOG_ARCHIVE_DEST_n参数定位多个归档路径
使用初始化参数LOG_ARCHIVE_DEST_n配置归档位置时,可以在归档位置上指定OPTIONAL或MANDATORY选项.指定MANDATORY选项时,可以设置REOPEN属性.
OPTIONAL:该选项是默认选项.使用该选项时,无论归档是否成功,都可以覆盖重做日志.
MANDATORY:强制归档.使用该选项时,只有在归档成功之后,重做日志才能被覆盖.
REOPEN:该属性用于指定重新归档的时间间隔,默认值为300秒,必须跟在MANDATORY后.
例:
alter system setlog_archive_dest_1='location=/oracle/archive/arch1 optional';
使用初始化参数LOG_ARCHIVE_MIN_SUCCEED_DEST控制本地归档的最小成功个数
SQL>show parameter log_archive_min_succeed_dest
NAME TYPE VALUE
----------------------------------------------- ------------------------------
log_archive_min_succeed_dest integer 1
SQL>
Altersystem set log_archive_min_succeed_dest=2;
实验结果:
如果要解决归档空间满或者某路径归档满的问题,可以设置两个归档路径,路径为可选optional,且log_archive_min_succeed_dest参数设置为1,即可解决相关问题。缺点是两个目录都正常情况下,需要归档两份归档日志。具体实验如下,实验主机为linux +oracle 11g。
1,修改为多路径模式,每个路径为可选,但至少一个是成功才可以日志覆盖
SQL> alter systemset log_archive_dest_1='location=/oracle/archive/arch1 optional';
System altered.
SQL> alter systemset log_archive_dest_2='location=/oracle/archive/arch2 optional';
System altered.
SQL> showparameter log_archive_min_succeed_dest
NAME TYPE VALUE
----------------------------------------------- ------------------------------
log_archive_min_succeed_dest integer 1
2,多次归档测试,归档均成功
SQL> alter systemswitch logfile;
System altered.
[root@dtydb0 arch1]#ls -l /oracle/archive/arch*
/oracle/archive/arch1:
total 389564
-rw-r----- 1 oracleoinstall 397999616 May 14 17:05 1_211_740745127.dbf
-rw-r----- 1 oracleoinstall 507904 May 14 17:06 1_212_740745127.dbf
/oracle/archive/arch2:
total 389564
-rw-r----- 1 oracleoinstall 397999616 May 14 17:05 1_211_740745127.dbf
-rw-r----- 1 oracleoinstall 507904 May 14 17:06 1_212_740745127.dbf
3,修改arch1的权限,是不能归档到arch1,继续归档,发现只能归档到arch2,当数据库归档正常。
[root@dtydb0archive]# chown -R root:root ./arch1
[root@dtydb0archive]# ls -lrt
SQL>
SQL> alter systemswitch logfile;
System altered.
[root@dtydb0archive]# ls -l /oracle/archive/arch*
/oracle/archive/arch1:
total 389564
-rw-r----- 1 rootroot 397999616 May 14 17:05 1_211_740745127.dbf
-rw-r----- 1 rootroot 507904 May 14 17:06 1_212_740745127.dbf
/oracle/archive/arch2:
total 390272
-rw-r----- 1 oracleoinstall 397999616 May 14 17:05 1_211_740745127.dbf
-rw-r----- 1 oracleoinstall 507904 May 14 17:06 1_212_740745127.dbf
-rw-r----- 1 oracleoinstall 351744 May 14 17:08 1_213_740745127.dbf
-rw-r----- 1 oracleoinstall 332800 May 14 17:08 1_214_740745127.dbf
-rw-r----- 1 oracleoinstall 2560 May 14 17:08 1_215_740745127.dbf
-rw-r----- 1 oracleoinstall 6656 May 14 17:08 1_216_740745127.dbf
4,修改回权限,2个路径的归档又恢复正常
[root@dtydb0archive]# chown -R oracle:oinstall /oracle/archive/arch1
[root@dtydb0archive]# ls -l /oracle/archive/arch*
/oracle/archive/arch1:
total 389788
-rwxr-xr-x 1 oracleoinstall 397999616 May 14 17:05 1_211_740745127.dbf
-rwxr-xr-x 1 oracleoinstall 507904 May 14 17:06 1_212_740745127.dbf
-rw-r----- 1 oracleoinstall 220672 May 14 17:14 1_219_740745127.dbf
/oracle/archive/arch2:
total 391464
-rw-r----- 1 oracleoinstall 397999616 May 14 17:05 1_211_740745127.dbf
-rw-r----- 1 oracleoinstall 507904 May 14 17:06 1_212_740745127.dbf
-rw-r----- 1 oracleoinstall 351744 May 14 17:08 1_213_740745127.dbf
-rw-r----- 1 oracleoinstall 332800 May 14 17:08 1_214_740745127.dbf
-rw-r----- 1 oracleoinstall 2560 May 14 17:08 1_215_740745127.dbf
-rw-r----- 1 oracleoinstall 6656 May 14 17:08 1_216_740745127.dbf
-rw-r----- 1 oracleoinstall 628736 May 14 17:11 1_217_740745127.dbf
-rw-r----- 1 oracleoinstall 342528 May 14 17:12 1_218_740745127.dbf
-rw-r----- 1 oracleoinstall 220672 May 14 17:14 1_219_740745127.dbf