Exp匯出報錯EXP-00091分析解決

realkid4發表於2014-07-26

 

Oracle EXP/IMP是早期推出資料備份還原工具。因其簡單易用、功能強大的特性,廣泛的被行業接受。一些開發工具(如PL/SQL Developer)中甚至整合嵌入了EXP/IMP工具。一些國內開發團隊預設資料部署策略中,EXP/IMP也佔到了相當比例。

隨著Oracle版本的推進,新特性的推出,特別是海量資料庫不斷出現在企業應用環境下,傳統的EXP/IMP工具架構已經不能承擔發展的需要。於是在10g版本中,Oracle推出了服務端執行的資料泵Data Pump工具。到11g版本中,Data Pump已經成為成熟的資料匯入匯出、備份解決方案。

但是在實際開發領域,Exp/Imp還是有很大的市場。雖然11g中已經不推薦使用Exp/Imp,但是很多廠商部署小資料應用還是採用Exp/Imp方法。

本次記錄的是一次部署匯出Exp中出現的問題,記錄下來,留待需要的朋友需要。

 

1、問題綜述

 

廠商上線部署系統,進行最後的資料匯出匯入測試。由於不是最終的環境,而且上線系統資料量初始比較少,所以推薦使用Exp/Imp或者Data Pump工具。在匯出過程中,系統資料雖然成功匯出,但是出現報錯EXP-00091。對應截圖照片如下(安全原因,遮蔽部分資訊):

 

Exp匯出報錯EXP-00091分析解決

 

匯出操作最後以成功。但是在日誌中,每個資料表資料雖然可以匯出,但是對應的統計量匯出時候,報錯EXP-00091Exporting questionable statistics,匯出統計量資訊問題。

筆者之前沒有遇到過這種問題,對於匯出操作前廠商進行過何種操作也沒有相關資訊,可以獲得的匯出語句如下:

 

Exp匯出報錯EXP-00091分析解決

匯出語法也沒有什麼額外的資訊過程。一時間筆者也沒有處理的思路。

 

2、問題分析和檢索

 

留下錯誤資訊提示和語句資訊之後,筆者查詢了Oracle MOS官方網站,希望找到對應的資料。在文件EXP Utility Reports EXP-91 During Export (文件 ID 730106.1)中,筆者找到了這個問題的解釋。

Oracle統計量是CBO的工作基礎。Oracle優化器在發展歷程中,經歷了從RBOCBO的演變過程。RBO時代,優化器生成規則是以程式碼的方式固化在Oracle程式碼中的。而CBO的工作是基於資料物件統計量。統計量反映在實體上,就是一系列的後設資料資訊。在9i時代,CBORBO共同作用,而且統計量是需要人工進行收集維護的。而且,由於資料變化的原因,在一些早期CBO版本中,“實時”統計量往往還不能獲得最好的執行計劃。

所以,在9iExp/Imp工具開始,統計量匯出就成為Exp工具預設行為。Exp/Imp工具是一個客戶端工具,客戶端的字符集設定nls_lang和資料庫伺服器端是存在不同的。如果nls_lang環境變數設定與資料庫伺服器設定不同,就會導致這個問題出現。

下面我們通過實驗來試圖重現錯誤,來證實我們的推論。

 

3、錯誤模擬

 

我們使用oracle 11gR2來進行測試模擬,具體版本號為11.2.0.4。客戶端作業系統為Windows

 

 

SQL> select * from v$version;

 

BANNER

--------------------------------------------------------------------------------

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

PL/SQL Release 11.2.0.4.0 - Production

CORE      11.2.0.4.0     Production

TNS for 64-bit Windows: Version 11.2.0.4.0 - Production

NLSRTL Version 11.2.0.4.0 – Production

 

 

當前,伺服器NLS關鍵引數如下。注意,檢視nls資訊一定是資料庫層面的。

 

 

SQL> select * from nls_database_parameters;

 

PARAMETER                      VALUE

------------------------------ --------------------------------------------------------------------------------

NLS_LANGUAGE                   AMERICAN

NLS_TERRITORY                  AMERICA

NLS_CURRENCY                   $

NLS_ISO_CURRENCY               AMERICA

NLS_NUMERIC_CHARACTERS         .,

NLS_CHARACTERSET               AL32UTF8

(篇幅原因,有省略……

 

 

Nls_lang環境變數的引數格式包括nls_languagenls_territorynls_characterset。具體格式如下:

 

NLS_LANG=_.< Characterset>

 

 

首先,我們先檢視一下正常的Exp匯出過程。

 

 

C:\Users\admin>set nls_lang=american_america.al32utf8

C:\Users\admin>exp \"/ as sysdba\" owner=scott file=scott.dmp

 

Export: Release 11.2.0.4.0 - Production on Sat Jul 26 19:34:55 2014

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

 

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit

Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set

 

About to export specified users ...

. exporting pre-schema procedural objects and actions

. exporting foreign function library names for user SCOTT

. exporting PUBLIC type synonyms

. exporting private type synonyms

. exporting object type definitions for user SCOTT

About to export SCOTT's objects ...

. exporting database links

. exporting sequence numbers

. exporting cluster definitions

. about to export SCOTT's tables via Conventional Path ...

. . exporting table                          BONUS          0 rows exported

. . exporting table                           DEPT          4 rows exported

. . exporting table                            EMP         14 rows exported

. . exporting table                       SALGRADE          5 rows exported

(篇幅原因,有省略……

. exporting statistics

Export terminated successfully without warnings.

 

 

沒有錯誤資訊出現,如果我們隨意調整一個nls_lang引數,情況就發生了不同。

 

 

C:\Users\admin>set nls_lang=american_china.zhs16gbk –設定完全不同的nls_lang引數

C:\Users\admin>exp \"/ as sysdba\" owner=scott file=scott.dmp

 

Export: Release 11.2.0.4.0 - Production on Sat Jul 26 19:38:00 2014

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

 

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

server uses AL32UTF8 character set (possible charset conversion)

 

About to export specified users ...

. exporting pre-schema procedural objects and actions

. exporting foreign function library names for user SCOTT

. exporting PUBLIC type synonyms

. exporting private type synonyms

. exporting object type definitions for user SCOTT

About to export SCOTT's objects ...

. exporting database links

. exporting sequence numbers

. exporting cluster definitions

. about to export SCOTT's tables via Conventional Path ...

. . exporting table                          BONUS          0 rows exported

EXP-00091: Exporting questionable statistics.

. . exporting table                           DEPT          4 rows exported

EXP-00091: Exporting questionable statistics.

EXP-00091: Exporting questionable statistics.

. . exporting table                            EMP         14 rows exported

EXP-00091: Exporting questionable statistics.

EXP-00091: Exporting questionable statistics.

. . exporting table                       SALGRADE          5 rows exported

EXP-00091: Exporting questionable statistics.

. exporting synonyms

(篇幅原因,有省略……

Export terminated successfully with warnings.

 

 

nls_lang引數和字符集不匹配的情況出現之後,EXP-00091錯誤就出現了。實驗能夠重現。

 

4、問題解決方案

 

定位了故障原因,要解決也就相對簡單了。針對這個問題,有幾個策略可以使用:

首先,是調整nls_lang為正確的引數取值;其次,是使用statistics=none,顯示的不進行統計量匯出;最後就是直接使用Data Pump工具。

 

5、結論

 

資料備份還原操作是我們最經常進行的資料庫操作之一。選擇合適的工具、方法,熟悉各種引數的含義和作用,是作為DBA應盡的基本責任。不問實際情況,直接拷貝網路上的程式碼步驟,是對自己工作不負責的行為。


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

相關文章