Welcome 微信登录

首页 / 数据库 / MySQL / 手工生成HTML格式AWR遇到Bug 13527323解决实例

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 ProductionPL/SQL Release 11.2.0.3.0 - ProductionCORE    11.2.0.3.0      ProductionTNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - ProductionNLSRTL Version 11.2.0.3.0 – Production使用sqlplus命令行来进行报告生成过程,调用awrrpt.sql。D:>sqlplus /nologSQL*Plus: Release 11.2.0.1.0Production on 星期四 2月 27 09:07:02 2014Copyright (c) 1982, 2010, Oracle.  All rights reserved.SQL> @?/rdbms/admin/awrrpt.sqlCurrent 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 textAWR目前支持两个格式,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 919ORA-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 2014Copyright (c) 1982, 2011, Oracle.  All rights reserved. SQL> conn / as sysdbaConnected. SQL> @?/rdbms/admin/awrrpt.sqlCurrent 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 textDefaults 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 smallORA-06512: at "SYS.DBMS_WORKLOAD_REPOSITORY", line 919ORA-06512: at line 1Report 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.sqlCurrent 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 textDefaults to "html"输入 report_type 的值:  textType 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 ReportReport 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的原因。更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12本文永久更新链接地址