Home Database Mysql Tutorial 关于AWR更多介绍

关于AWR更多介绍

Jun 07, 2016 pm 03:21 PM
oracle database

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 of this Website
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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MySQL: An Introduction to the World's Most Popular Database MySQL: An Introduction to the World's Most Popular Database Apr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

Why Use MySQL? Benefits and Advantages Why Use MySQL? Benefits and Advantages Apr 12, 2025 am 12:17 AM

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

What to do if the oracle can't be opened What to do if the oracle can't be opened Apr 11, 2025 pm 10:06 PM

Solutions to Oracle cannot be opened include: 1. Start the database service; 2. Start the listener; 3. Check port conflicts; 4. Set environment variables correctly; 5. Make sure the firewall or antivirus software does not block the connection; 6. Check whether the server is closed; 7. Use RMAN to recover corrupt files; 8. Check whether the TNS service name is correct; 9. Check network connection; 10. Reinstall Oracle software.

How to solve the problem of closing oracle cursor How to solve the problem of closing oracle cursor Apr 11, 2025 pm 10:18 PM

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

How to create cursors in oracle loop How to create cursors in oracle loop Apr 12, 2025 am 06:18 AM

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

How to stop oracle database How to stop oracle database Apr 12, 2025 am 06:12 AM

To stop an Oracle database, perform the following steps: 1. Connect to the database; 2. Shutdown immediately; 3. Shutdown abort completely.

How to create oracle dynamic sql How to create oracle dynamic sql Apr 12, 2025 am 06:06 AM

SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values ​​to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.

How to open a database in oracle How to open a database in oracle Apr 11, 2025 pm 10:51 PM

The steps to open an Oracle database are as follows: Open the Oracle database client and connect to the database server: connect username/password@servername Use the SQLPLUS command to open the database: SQLPLUS

See all articles