search
HomeDatabaseMysql Tutorial关于AWR更多介绍

AWR 是Oracle 10g 版本推出的新特性,全称叫Automatic Workload Repository-自动负载信息库, AWR 是通过对比两次快,照(snapshot

AWR 是Oracle 10g 版本推出的新特性,全称叫Automatic Workload Repository-自动负载信息库, AWR 是通过对比两次快,照(snapshot)收集到的统计信息,来生成报表数据,生成的报表包括多个部分。

设置AWR采样保留策略和采集频率

的采样历史数据默认保留7天,并且默认每1小时收集一次.

当前采样快照保留策略和采集频率可以通过下面的语句进行查询.下面显示的是 7 days and 1 hour

SQL> select to_char(snap_interval,’DD’),to_char(retention,’DD’) FROM dba_hist_wr_control;

TO_CHAR(SNAP_INTER TO_CHAR(RETENTION,
—————— ——————
+00000 01:00:00.0 +00007 00:00:00.0;

我们通过下面的方式来改变设置, 设置快照采集时间间隔为每 20 分钟一次 保留2天的历史数据. 参数指定的都是分钟.

begin
 dbms_workload_repository.modify_snapshot_settings (
 interval => 20,
 retention => 2*24*60
 );
 end;

AWR相关的表

元数据 (WRM$)
历史数据 (WRH$)
 AWR 报告相关的建议方法 (WRI$)
 Oracle 11g 新特性的AWR相关信息(WRR$)

Workload Repository Reports

Oracle提供两个主要的脚本生产AWR报告 (awrrpt.sql and awrrpti.sql). 他们的格式和 statspack 报告非常相似, 提供 HTML 和 text 两种格式. 两个报告输出相同的格式但是 awrrpti.sql允许选择单个实例:
 @$ORACLE_HOME/rdbms/admin/awrrpt.sql
 @$ORACLE_HOME/rdbms/admin/awrrpti.sql

下面是经常使用到的脚本:
REPORT NAME                                  SQL Script
Automatic Workload Repository Report          awrrpt.sql
Automatic Database Diagnostics Monitor Report addmrpt.sql
ASH Report                                    ashrpt.sql
AWR Diff Periods Report                      awrddrpt.sql
AWR Single SQL Statement Report              awrsqrpt.sql
AWR Global Report                            awrgrpt.sql
AWR Global Diff Report                        awrgdrpt.sql 


导出和导入 AWR 快照数据

AWR 数据存储在SYSAUX表空间的 WRH$ 和 DBA_HIST 表中 . 如果表增长的非常大,数据保存的时间长会影响数据库性能,因此默认只保留7天的历史数据.

一个比较好的解决方案是把AWR的数据转移到另一资料存储数据库中心, Oracle 提供了两个脚本 awrextr.sql and awrload.sql scripts可以把AWR数据迁移到
 另一个数据库中。在 $ORACLE_HOME/rdbms/admin 目录下可以找到这两个脚本.

– in source db
 SQL> @?/rdbms/admin/awrextr.sql

– in target db
 SQL>@?/rdbms/admin/awrload.sql

或者
 使用 oracle 内部包
dbms_swrf_internal.AWR_EXTRACT
 DBMS_SWRF_INTERNAL.AWR_LOAD
 DBMS_SWRF_INTERNAL.MOVE_TO_AWR
 DBMS_SWRF_INTERNAL.CLEAR_AWR_DBID

清除 AWR

exec dbms_swrf_internal.unregister_database();

dbms_workload_repository.DROP_SNAPSHOT_RANGE;

禁用 Oracle AWR

如果想禁用AWR ,可以使用下面的方式禁用AWR,下面列出了详细的操作步骤.

1,设置 STATISTICS_LEVEL 参数为 BASIC.
 2,执行 CATNOAWR.sql脚本删除相关的awr表. 这个脚本执行存储过程 procedure dbms_swrf_internal.remove_wr_control, 删除wrm$_wr_control 相关的数据和所有AWR 相关的表.
3,执行 DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS(interval=>0):
 4,从Metalink上下载 dbms_awr.plb 脚本, 执行 DBMS_AWR.DISABLE_AWR() [脚本参见 Metalink note 436386.1].
 5,如果数据库是通过手工创建的,,不是使用DBCA创建的不需要执行 CATAWRTB.sql .
 6,设置_awr_restrict_mode = TRUE 

重建 AWR

Oracle 建议我们重建 AWR,数据保存在 SYSAUX 表空间下:

alter system set sga_target=0 scope=spfile;
 alter system set statistics_level = basic scope=both;
 alter system set cluster_database=false;

shutdown immediate

startup restrict
– in 10g begin —
@?/rdbms/admin/catnoawr.sql
 alter system flush shared_pool;
 @?/rdbms/admin/catsvrm.sql –in the script had calls catawrtb.sql
– in 10g end —

– in 11g begin—
SQL> @?/rdbms/admin/catnoawr.sql
 SQL> alter system flush shared_pool;
 SQL> @?/rdbms/admin/catawr.sql
 SQL> @?/rdbms/admin/utlrp.sql
 sql> @?/rdbms/admin/execsvrm.sql
– in 11g end—

Then re-enable the AWR statistics gathering as required, by setting STATISTICS_LEVEL back to its original value, and restart the instance normally

Tip:
 When SYSAUX tablespace is keep growing,you can check the V$SYSAUX_OCCUPANTS View to find out who/what is occupying space in SYSAUX.

本文永久更新链接地址

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Explain the InnoDB Buffer Pool and its importance for performance.Explain the InnoDB Buffer Pool and its importance for performance.Apr 19, 2025 am 12:24 AM

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

MySQL vs. Other Programming Languages: A ComparisonMySQL vs. Other Programming Languages: A ComparisonApr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Learning MySQL: A Step-by-Step Guide for New UsersLearning MySQL: A Step-by-Step Guide for New UsersApr 19, 2025 am 12:19 AM

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL: Essential Skills for Beginners to MasterMySQL: Essential Skills for Beginners to MasterApr 18, 2025 am 12:24 AM

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL: Structured Data and Relational DatabasesMySQL: Structured Data and Relational DatabasesApr 18, 2025 am 12:22 AM

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL: Key Features and Capabilities ExplainedMySQL: Key Features and Capabilities ExplainedApr 18, 2025 am 12:17 AM

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

The Purpose of SQL: Interacting with MySQL DatabasesThe Purpose of SQL: Interacting with MySQL DatabasesApr 18, 2025 am 12:12 AM

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

MySQL for Beginners: Getting Started with Database ManagementMySQL for Beginners: Getting Started with Database ManagementApr 18, 2025 am 12:10 AM

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools