手工生成HTML格式AWR遇到Bug 13527323解决实例
Oracle中的AWR报告是目前官方提供的最好的性能分析诊断工具。借助对于一个连续snapshot的分析,我们可以快速的获取到整体性能分析
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
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格式报告,依然报错。
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values and pointers to data rows, and is suitable for non-primary key column queries.

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

MySQL and MariaDB can coexist, but need to be configured with caution. The key is to allocate different port numbers and data directories to each database, and adjust parameters such as memory allocation and cache size. Connection pooling, application configuration, and version differences also need to be considered and need to be carefully tested and planned to avoid pitfalls. Running two databases simultaneously can cause performance problems in situations where resources are limited.

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

MySQL supports four index types: B-Tree, Hash, Full-text, and Spatial. 1.B-Tree index is suitable for equal value search, range query and sorting. 2. Hash index is suitable for equal value searches, but does not support range query and sorting. 3. Full-text index is used for full-text search and is suitable for processing large amounts of text data. 4. Spatial index is used for geospatial data query and is suitable for GIS applications.
