2023年9月27日 星期三

impdp 產生 ORA-39384 錯誤案例

Oracle 版本: 19.15

OS 版本: Aix 7.2


問題描述:

以 schema level 將 11.2.0.4 的使用者 expdp 出來後,將其 impdp 至 19.15 產生了 ORA-39384: Warning: User SCOTT Has Been Locked And The Password Expired 這個錯誤:

Export From 11g DB:

$ expdp \'/ as sysdba\' directory=expdir schemas=scott dumpfile=exp_scott%U.dmp logfile=exp_scott.log


Import to 19c DB:

$ impdp \'/ as sysdba\' directory=impdir dumpfile= exp_scott%U.dmp logfile=imp_scott.log

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production

Master table "SYS"."SYS_IMPORT_FULL_01" successfully loaded/unloaded

Starting "SYS"."SYS_IMPORT_FULL_01":  "/******** AS SYSDBA" directory=impdir dumpfile=exp_scott%U.dmp logfile=imp_scott.log 

Processing object type SCHEMA_EXPORT/USER

ORA-39384: Warning: User SCOTT Has Been Locked And The Password Expired


問題分析:

在 impdp 的過程當中,如果資料庫不存在需要的使用者,則會先行建立此使用者,這個訊息就是 impdp 一開始建立使用者的時候發生錯誤,使用者沒有建立起來,後續的物件自然也無法 import 成功。


ORA-39384 顯示使用者被 Locked 或者是密碼過期,可是檢查來源端 11g 的使用者卻沒有 Locked 或是密碼過期,為何 impdp 會無法建立此 User ?


這個問題來自於 Oracle 12c 之後對於安全性的嚴謹度加強,早期資料庫的使用者如果它的 password_versions (select password_versions from dba_users) 為 10G 或是更舊,那麼此使用者 impdp 到 12c 以上的資料庫就會產生此問題。


解決方法:

這個問題的解決思路在於讓 12c 以上的資料庫可以相容於舊資料庫的設定,於 $ORACLE_HOME/network/admin 底下的 sqlnet.ora 設定如下即可正常 impdp :

sqlnet.allowed_logon_version_server = 10

sqlnet.allowed_logon_version_client = 10


ORA-28040: No matching authentication

Oracle 版本: 12.2.0.1

OS 版本: Aix 7.1


問題描述:

在資料庫升級到 12.2.0.1 (或以上版本) 之後, Client 無法連線並出現 ORA-28040: No matching authentication 錯誤。


問題分析:

在資料庫升級之後, Client 端的版本 (Oracle Client 、 JDBC …etc) 沒有一併升級導致兩者不相容所產生的連線問題。


解決方法:

於 $ORACLE_HOME/network/admin 底下的 sqlnet.ora 設定如下,讓資料庫可以相容舊版本的 Client 即可:

sqlnet.allowed_logon_version_server = 8

sqlnet.allowed_logon_version_client = 8


2023年8月17日 星期四

grant 產生 ORA-4021 錯誤案例

Oracle 版本: 12.1.0.2.0 , RAC

OS 版本: AIX 5.3


問題描述:

於針對 gv_$ 開頭的 view 授予權限時, session 會 hang 住,最終出現 ORA-04021 timeout occurred while waiting to lock object ,無法 grant 成功 。

SQL> grant select on gv_$instance to scott;

                 *

ERROR at line 1:

ORA-04021: timeout occurred while waiting to lock object

(此命令 hang 住,最終出現 ORA-04021 的 timeout 錯誤)


問題分析:

針對 grant select on gv_$instance to scott 語法進行 hanganalyze 與 systemstate dump 分析:

SQL> oradebug setospid 515;

SQL> oradebug hanganalyze 3;

SQL> oradebug dump systemstate 266;

SQL> oradebug hanganalyze 3;


由 trace 顯示此 grant session 遭遇到 library cache lock 的等待,並且被 sid 為 344 的 session 阻塞 :


同樣的方法 trace sid 為 344 的 session ,此 session 正在進行 virtual circuit next request 的等待 :


virtual circuit next request 是一個 idle 的等待事件,當資料庫有設定 EM Express ,使用者經由網頁開啟並登入,此時資料庫會進行如下操作來撈取相關資訊顯示在 EM Express 上 :

begin

:rept := dbms_report.get_report(:report_ref, :content, :comp); 

end;


若使用者沒有登出 Web 頁面, EM Express 的 session 就會出現 virtual circuit next request 這個 idle 的等待事件。由於此時 EM Express 尚未釋放相關的 LibraryHandle ,造成其它 session 對於 gv$instance 的操作產生了 library cache lock ,一直沒有等到 lock 釋放而出現了 ORA-04021 的錯誤。


解決方法:

將登入進 EM Express 的使用者 session kill ,或者是由 EM Express 的網頁進行登出的動作,再重新進行 grant 操作便可成功。