手工產生HTML格式AWR遇到Bug 13527323解決執行個體

來源:互聯網
上載者:User

Oracle中的AWR報告是目前官方提供的最好的效能分析診斷工具。藉助對於一個連續snapshot的分析,我們可以快速的擷取到整體效能分析指標,綜合定位問題發生點。

任何Oracle版本中,我們都可能會遇到各種類型的Bug。發現Bug之後,和官方公布內容進行匹配確認,找到解決或者規避方法,是資料庫使用者應該具備的一種能力。

1、環境介紹和故障發生

筆者在11.2.0.3環境下,產生巡檢AWR報告,想查看業務高峰期作業負載情況。

SQL> select * from v$version;

 

BANNER

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

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

PL/SQL Release 11.2.0.3.0 - Production

CORE    11.2.0.3.0      Production

TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production

NLSRTL Version 11.2.0.3.0 – Production

使用sqlplus命令列來進行報告產生過程,調用awrrpt.sql。

D:\>sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0Production on 星期四 2月 27 09:07:02 2014

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

SQL> @?/rdbms/admin/awrrpt.sql

Current Instance

~~~~~~~~~~~~~~~~

 

  DB Id    DB Name      Inst Num Instance

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

 1083126127 COGDB              1 cogdb

 

Specify the Report Type

~~~~~~~~~~~~~~~~~~~~~~~

Would you like an HTML report, or a plain text report?

Enter 'html' for an HTML report, or 'text' for plain text

AWR目前支援兩個格式,html和text格式。text格式是從AWR的前身statspack中延續而來,格式簡單、產生負載小,但是可讀性不強。html格式是我們通常的選擇。

但是,本次報告出錯。

 

8</a></td>

<td class='awrnc'>&#160;

</td>

<td class='awrnc'>SELECT dbin.instance_number, d...</td></tr>

</table><p />

ERROR:

ORA-06502: PL/SQL: 數字或值錯誤 :  字串緩衝區太小

ORA-06512: 在 "SYS.DBMS_WORKLOAD_REPOSITORY", line 919

ORA-06512: 在 line 1

 

Report written to awrrpt_1_9583_9584.html

報告產生失敗,在目錄上雖然有報告檔案、也可以開啟,但是組建檔案不完整。

2、問題檢查和確定

一般而言,用戶端指令碼和伺服器端程式不匹配,通常是造成指令碼執行的一個很重要的原因。比如:我們使用10g用戶端的舊指令碼,調用11g伺服器的新程式,是可能引起故障的。比較典型的就是還原資料字典的過程。
 

AWR產生指令碼awrrpt.sql雖然是在用戶端,但是只是負責參數資料收集和傳入。產生AWR報告的關鍵程式是dbms_workload_repository包,awrrpt.sql並不直接和AWR資料字典打交道。所以,由於版本差異引起的問題,在這個案例上可能性是很低的。

為了預防萬一,我們在伺服器端進行報告產生。

[oracle@MISDB:~]$cd /tmp

[oracle@MISDB:/tmp]$sqlplus /nolog

 

SQL*Plus: Release 11.2.0.3.0 Production on Thu Feb 27 09:13:23 2014

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

 

SQL> conn / as sysdba

Connected.

 

SQL> @?/rdbms/admin/awrrpt.sql

Current Instance

~~~~~~~~~~~~~~~~

  DB Id    DB Name      Inst Num Instance

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

 1083126127 COGDB              1 cogdb

 

Specify the Report Type

~~~~~~~~~~~~~~~~~~~~~~~

Would you like an HTML report, or a plain text report?

Enter 'html' for an HTML report, or 'text' for plain text

Defaults to 'html'

Enter value for report_type:

要求產生html格式報告,依然報錯。

<td class='awrnc'>&#160;

</td>

<td class='awrnc'>SELECT dbin.instance_number, d...</td></tr>

</table><p />

ERROR:

ORA-06502: PL/SQL: numeric or value error: character string buffer too small

ORA-06512: at "SYS.DBMS_WORKLOAD_REPOSITORY", line 919

ORA-06512: at line 1

Report written to awrrpt_1_9583_9584.html

這種情境的確是不正常的,而且由於代碼加密的原因,我們也不能真的跟蹤到line 919行。這個時候可能就需要求助於官方經驗集合MOS。

經過查詢,在MOS中有一篇對於Bug13527323的介紹,文章編號為: ORA-6502 generating HTML AWR report using awrrpt.sql in Multibyte characterset database (文檔 ID 13527323.8)。
 
文章中,Oracle說在一些時候,使用awrrpt.sql指令碼產生報告是會拋出錯誤ora-6502的。對應的影響版本為11.2.0.3,而且Oracle認為在12.1一下都可能發生錯誤。這個描述與當前筆者遇到的情況相同。
 

對於故障原因,Oracle解釋是:In case of multibyte characters in SQL text, sometime AWR report generation fails with error ORA-6502. Also sending more than 4000 bytes of single varchar data to JDBC api's causes truncation of data. 
 
Rediscovery Notes:

 If html AWR report generation fails with ORA-6502 or generating

 AWR report using JDBC api's causes truncation of data then this bug

 as probably been rediscovered.

如果在SQL text中存在多種語言表示,那麼在資料輸出的時候,就會拋出異常ora-6502。

問題基本上就可以確定是這個了。那麼怎麼解決呢?對於策略,Oracle沒有明確說補丁集合之類,只說這種情況比較偶然。

3、問題解決

雖然定位了問題,但是終究還是需要解決的。html格式存在問題,那麼更簡單的text格式是否不會拋出異常呢?

SQL> @?/rdbms/admin/awrrpt.sql

Current Instance

~~~~~~~~~~~~~~~~

  DB Id    DB Name      Inst Num Instance

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

 1083126127 COGDB              1 cogdb

 

Specify the Report Type

~~~~~~~~~~~~~~~~~~~~~~~

Would you like an HTML report, or a plain text report?

Enter 'html' for an HTML report, or 'text' for plain text

Defaults to 'html'

輸入 report_type 的值:  text

Type Specified:                  text

 

最後結果成功產生:

 

Parameter Name                Begin value                      (if different)

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

control_files                /home/oracle/controlfile/cogdb/co

                              /oradb/app/oracle/oradata/control

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

Dynamic Remastering Stats              DB/Inst: COGDB/cogdb  Snaps: 9583-9584

                  No data exists for this section of the report.

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

 

End of Report

Report written to awrrpt_1_9583_9584.txt

 

確認報告內容也是完整的。在SQL Text部分,我們也的確發現了“多種語言”的情況。

 

-> Captured PL/SQL account for    0.0% of Total DB Time (s):          3,165

        Elapsed                  Elapsed Time

        Time (s)    Executions  per Exec (s)  %Total  %CPU    %IO    SQL Id

---------------- -------------- ------------- ------ ------ ------ -------------
 
          298.0              1        297.99    9.4  50.6  26.6 4wfkj936k5qhq
 
insert into f_cx_cmain ( select T1."POO" as 單號, T1."CLDE" as

 類代碼, T1."RDE" as代碼, T1."CDE" as 公司, T1

."BUODE" as 來原始碼, T1."SE" as 起期, T1."EE" as 終期, T1."UNDDDATE" as通過, T2."STATDATE" a

的確和Bug說明的情況相匹配。除了text格式,筆者認為使用OEM產品中的AWR產生模組,也可以避免這類問題的出現。

4、結論

任何軟體的使用過程中,Bug是難以避免。當操作結果和我們預想不同、而且從經驗判斷不是操作失誤的時候,就可以考慮是Bug的原因。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.