【IMPDP】使用工具IMPDP匯入資料時ORA-39002、ORA-39070錯誤排查

secooler發表於2010-06-04
今天在使用IMPDP完成資料匯入的過程中遇到“ORA-39002、ORA-39070……”連續報錯。
導致問題原因很簡單,但是提示的錯誤資訊內容比較“詭異”,為了朋友們少走彎路,簡單記錄一下這個問題的處理過程。

1.問題再現
sec@secDB /db_backup/dpump_dir$ impdp sec/sec directory=dpump_dir dumpfile=20100604020437_sec.dmp logfile=impdp.log

Import: Release 10.2.0.3.0 - 64bit Production on Friday, 04 June, 2010 14:39:16

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
ORA-39002: invalid operation
ORA-39070: Unable to open the log file.
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 475
ORA-29283: invalid file operation

2.問題分析
這裡的“ORA-39070”提到的“Unable to open the log file.”初看非常的“詭異”,到底無法開啟什麼日誌檔案呢?難道是沒有許可權在這個目錄下寫檔案?經過“touch”測試排除了這種可能性。
不管怎麼說,這個問題與檔案操作相關。順著這個思路繼續前行,終於發現原來資料庫中的directory資料庫物件所指向的目錄為“/oradata/dpump_dir”,而在該作業系統中根本沒有這個目錄,因目錄不存在,日誌檔案也就理所當然的無處可寫。

不過這個報錯的資訊卻是不夠明顯,如果能夠給出更多的檢查和明確的報錯資訊就更好了。

sys@ora10g> col owner for a6
sys@ora10g> col DIRECTORY_NAME for a20
sys@ora10g> col DIRECTORY_PATH for a30
sys@ora10g> select * from dba_directories where DIRECTORY_NAME = 'DPUMP_DIR';

OWNER  DIRECTORY_NAME       DIRECTORY_PATH
------ -------------------- ------------------------------
SYS    DPUMP_DIR            /oradata/dpump_dir

3.問題處理
發現問題後,處理方法就簡單了許多,只需要重新建立directory資料庫物件即可。
sys@sec> drop directory dpump_dir;

Directory dropped.

sys@sec> create directory dpump_dir as '/db_backup/dpump_dir';

Directory created.

sys@sec> grant read, write on directory dpump_dir to public;

Grant succeeded.

4.導致該問題的潛在原因
在10g環境中即使在建立directory資料庫物件的過程中即使所引用的目錄不存在,該命令也是可以正常建立的,這就是容易誤操作的根本原因。
sys@ora10g> create directory dpump_dir_test as '/sec/ool/er';

Directory created.

小心陷阱。

5.小結
從該問題的處理過程中我們可以看到,在報錯資訊不實很明顯的時候我們往往手足無措。越是在這樣的場景,我們越應該沉著冷靜,從整個操作的源頭一步一步的去排查,終有柳暗花明之時。

Good luck.

secooler
10.06.04

-- The End --

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/519536/viewspace-664406/,如需轉載,請註明出處,否則將追究法律責任。

相關文章