当配置了Fast Recovery Area的时候,db_recovery_file_dest和log_archive_dest_n都能决定archivelog的生成路径,Archivelog最终生成在哪个路径下,请看下面的测试
按照oracle的说法,当db_recovery_file_dest被指定,且没有log_archive_dest_n参数被显式指定的时候,log_archive_dest_10被隐含指向db_recovery_file_dest值
---没有log_archive_dest_n参数被设定
set pagesize 100
SYS@tstdb1-SQL> select name,value from v$system_parameter where name like 'log_archive_dest%' and name not like 'log_archive_dest_state_%' and value is not null;
no rows selected
SYS@tstdb1-SQL> show parameter db_recovery_file_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /oradata06/fra
db_recovery_file_dest_size big integer 100G
--log_archive_dest_10是隐含指定,没有值显示
SYS@tstdb1-SQL> show parameter log_archive_dest_10
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_10 string
---archive目标显示USE_DB_RECOVERY_FILE_DEST
SYS@tstdb1-SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1313
Next log sequence to archive 1315
Current log sequence 1315
---把log_archive_dest_10值强制置为空
alter system set log_archive_dest_10='' scope=spfile;
startup force
---重启实例后还是把USE_DB_RECOVERY_FILE_DEST作为归档目录
SYS@tstdb1-SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1315
Next log sequence to archive 1317
Current log sequence 1317
---把log_archive_dest_10设置为一个非FRA的目录
SYS@tstdb1-SQL> alter system set log_archive_dest_10='location=/oradata06/arch10' scope=both;
System altered.
SYS@tstdb1-SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oradata06/arch10
Oldest online log sequence 1316
Next log sequence to archive 1318
Current log sequence 1318
---检查归档生成在了log_archive_dest_10指定的目录下,FRA目录下没有
oracle@jq570322b:/oradata06/arch10>ls -rlt /oradata06/arch10
total 1296
-r--r----- 1 oracle oinstall 663040 Apr 28 09:44 1_1318_863298935.dbf
tstdb1@jq570322b:/oradata06/fra/TSTDB1/archivelog/2015_04_28>ls -rlt /oradata06/fra/TSTDB1/archivelog/2015_04_28
total 236016
-r--r----- 1 oracle oinstall 99112960 Apr 28 01:45 o1_mf_1_1314_1jKTs7DEb_.arc
-r--r----- 1 oracle oinstall 20176896 Apr 28 09:25 o1_mf_1_1315_1jKtbvXqL_.arc
-r--r----- 1 oracle oinstall 27648 Apr 28 09:27 o1_mf_1_1316_1jKtibPpC_.arc
-r--r----- 1 oracle oinstall 1510400 Apr 28 09:38 o1_mf_1_1317_1jKuHwJt0_.arc
---设置log_archive_dest_1为USE_DB_RECOVERY_FILE_DEST
alter system set log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST' scope=both;
SYS@tstdb1-SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1317
Next log sequence to archive 1319
Current log sequence 1319
col name format a50
col value format a50
set linesize 160
SYS@tstdb1-SQL> select name,value from v$system_parameter where name like 'log_archive_dest%' and name not like 'log_archive_dest_state_%' and value is not null;
NAME VALUE
-------------------------------------------------- --------------------------------------------------
log_archive_dest_1 location=USE_DB_RECOVERY_FILE_DEST
log_archive_dest_10 location=/oradata06/arch10
---切换一轮logfile后发现sequence#=1319的logfile在RECOVERY_FILE_DEST目录和/oradata06/arch10目录下都有
SYS@tstdb1-SQL> alter system switch logfile;
System altered.
tstdb1@jq570322b:/oradata06/fra/TSTDB1/archivelog/2015_04_28>ls -rlt /oradata06/fra/TSTDB1/archivelog/2015_04_28
total 236160
-r--r----- 1 oracle oinstall 99112960 Apr 28 01:45 o1_mf_1_1314_1jKTs7DEb_.arc
-r--r----- 1 oracle oinstall 20176896 Apr 28 09:25 o1_mf_1_1315_1jKtbvXqL_.arc
-r--r----- 1 oracle oinstall 27648 Apr 28 09:27 o1_mf_1_1316_1jKtibPpC_.arc
-r--r----- 1 oracle oinstall 1510400 Apr 28 09:38 o1_mf_1_1317_1jKuHwJt0_.arc
-r--r----- 1 oracle oinstall 66048 Apr 28 09:48 o1_mf_1_1319_1jKusVAR4_.arc
oracle@jq570322b:/oradata06/arch10>ls -rlt /oradata06/arch10
total 1440
-r--r----- 1 oracle oinstall 663040 Apr 28 09:44 1_1318_863298935.dbf
-r--r----- 1 oracle oinstall 66048 Apr 28 09:48 1_1319_863298935.dbf
---将log_archive_dest_1、log_archive_dest_10还原为空值后发现archivelog dest变为了OS缺省的路径了
alter system set log_archive_dest_1='' scope=both;
alter system set log_archive_dest_10='' scope=both;
SYS@tstdb1-SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination ?/dbs/arch
Oldest online log sequence 1318
Next log sequence to archive 1320
Current log sequence 1320
---如果要用回FRA可以重复设置一下db_recovery_file_dest参数
SYS@tstdb1-SQL> show parameter db_recovery_file_dest
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /oradata06/fra
db_recovery_file_dest_size big integer 100G
alter system set db_recovery_file_dest='/oradata06/fra' scope=both;
SYS@tstdb1-SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1318
Next log sequence to archive 1320
Current log sequence 1320
---或者设定一个log_archive_dest_n参数指向FRA
SYS@tstdb1-SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination ?/dbs/arch
Oldest online log sequence 1318
Next log sequence to archive 1320
Current log sequence 1320
alter system set log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST' scope=both;
SYS@tstdb1-SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1318
Next log sequence to archive 1320
Current log sequence 1320
结论:
没有指定log_archive_dest_n的情况下如果启用FRA那么archivelog会生成在FRA指定的目录下,如果指定log_archive_dest_n值为非FRA所在的路径,那么archivelog仅会生成在log_archive_dest_n指定的路径下,不会生成到FRA路径下,这时如果也要同时生成一份在FRA对应的路径下,必须另设一个log_arhive_dest_n=USE_DB_RECOVERY_FILE_DEST。
如果曾经使用log_archive_dest_n参数指定过archivelog的路径(不管这个路径是FRA还是非FRA),现在又将这些参数设置为空想重新用回FRA,那么必须重新执行"alter system set db_recovery_file_dest='/oradata06/fra' scope=both;"激活一下FRA的设置,或者将log_archive_dest_n直接指向FRA
更多细节可参考http://docs.oracle.com/cd/E11882_01/backup.112/e10642/rcmconfb.htm#CHDJEHIE
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/53956/viewspace-1608409/ ,如需转载,请注明出处,否则将追究法律责任。