這篇介紹使用Logminer時遇到ORA-01336: specified dictionary file cannot be opened錯誤的各種場景
1:dictionary_location參數的路徑最後多了一個/符號。
SQL> show parameter utl_file_dir;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
utl_file_dir string /u01/app/utl_file_dir
SQL> exec dbms_logmnr_d.build(dictionary_filename=>'logmin.ora', dictionary_location=>'/u01/app/utl_file_dir/',options=>dbms_logmnr_d.store_in_flat_file);
BEGIN dbms_logmnr_d.build(dictionary_filename=>'logmin.ora', dictionary_location=>'/u01/app/utl_file_dir/',options=>dbms_logmnr_d.store_in_flat_file); END;
*
ERROR at line 1:
ORA-01336: specified dictionary file cannot be opened
ORA-29280: invalid directory path
ORA-06512: at "SYS.DBMS_LOGMNR_INTERNAL", line 6003
ORA-06512: at "SYS.DBMS_LOGMNR_INTERNAL", line 6093
ORA-06512: at "SYS.DBMS_LOGMNR_D", line 12
ORA-06512: at line 1
如下所示,將dictionary_location的值從dictionary_location=>'/u01/app/utl_file_dir/' 改為=>'/u01/app/utl_file_dir'就會OK。
SQL> exec dbms_logmnr_d.build(dictionary_filename=>'logmin.ora', dictionary_location=>'/u01/app/utl_file_dir',options=>dbms_logmnr_d.store_in_flat_file);
PL/SQL procedure successfully completed.
SQL>
2:隨意指定的dictionary_location,與參數utl_file_dir不一致。
這個純屬菜鳥犯的錯誤,沒有太多要說的。如下所示,你就知道這個是怎樣的一個場景:
SQL> exec dbms_logmnr_d.build(dictionary_filename=>'logmin.ora', dictionary_location=>'/u01/app/kkk',options=>dbms_logmnr_d.store_in_flat_file);
BEGIN dbms_logmnr_d.build(dictionary_filename=>'logmin.ora', dictionary_location=>'/u01/app/kkk',options=>dbms_logmnr_d.store_in_flat_file); END;
*
ERROR at line 1:
ORA-01336: specified dictionary file cannot be opened
ORA-29280: invalid directory path
ORA-06512: at "SYS.DBMS_LOGMNR_INTERNAL", line 6003
ORA-06512: at "SYS.DBMS_LOGMNR_INTERNAL", line 6093
ORA-06512: at "SYS.DBMS_LOGMNR_D", line 12
ORA-06512: at line 1
SQL> ! oerr ora 1336
01336, 00000, "specified dictionary file cannot be opened"
// *Cause: The dictionary file or directory does not exist or is inaccessible.
// *Action: Make sure that the dictionary file and directory exist and are
// accessible.
SQL> show parameter utl_file_dir;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
utl_file_dir string /u01/app/utl_file_dir
SQL>
SQL> exec dbms_logmnr_d.build(dictionary_filename=>'logmin.ora', dictionary_location=>'/u01/app/utl_file_dir',options=>dbms_logmnr_d.store_in_flat_file);
PL/SQL procedure successfully completed.
SQL>
3:定義utl_file_dir 參數最好使用完整路徑,使用預定義環境變量會導致無法打開文件目錄
SQL> alter system set utl_file_dir='$ORACLE_BASE/log_mnr' scope=spfile;
System altered.
SQL> shutdown immediate;
SQL> startup;
SQL> exec dbms_logmnr_d.build(dictionary_filename=>'logmin.ora', dictionary_location=>'/u01/app/oracle/log_mnr',options=>dbms_logmnr_d.store_in_flat_file);
BEGIN dbms_logmnr_d.build(dictionary_filename=>'logmin.ora', dictionary_location=>'/u01/app/oracle/log_mnr',options=>dbms_logmnr_d.store_in_flat_file); END;
*
ERROR at line 1:
ORA-01336: specified dictionary file cannot be opened
ORA-29280: invalid directory path
ORA-06512: at "SYS.DBMS_LOGMNR_INTERNAL", line 6003
ORA-06512: at "SYS.DBMS_LOGMNR_INTERNAL", line 6093
ORA-06512: at "SYS.DBMS_LOGMNR_D", line 12
ORA-06512: at line 1