Oracle AWR入门
1.ASH占用的内存大小 ASH的采集信息保存在内存中,在旧的信息被采样到AWR中后,可被新采集的信息覆盖,重启oracle后该信息被清除。分配给ASH的内存大小可以查询到: SQL select pool, name, bytes/1024/1024 From v$sgastat where name like ‘%ASH %’; POO
1.ASH占用的内存大小
ASH的采集信息保存在内存中,在旧的信息被采样到AWR中后,可被新采集的信息覆盖,重启oracle后该信息被清除。分配给ASH的内存大小可以查询到:
SQL> select pool, name, bytes/1024/1024 From v$sgastat where name like ‘%ASH %’;
POOL NAME BYTES/1024/1024
———— ————————– —————
shared pool ASH buffers 4
2.mmon进程与mmnl进程
2.1)快照由一个称为 MMON 的新的后台进程(及其从进程)以及MMNL后台进程自动地每隔固定时间采样一次。我们先来看一下10g的概念指南中对这两个新增加的后台进程的介绍:
MMON进程负责执行多种和管理相关(manageability-related)的后台任务
例如:当某个测量值(metrics)超过了预设的限定值(threshold value)后提交警告,创建新的 MMON 隶属进程(MMON slave process)来进行快照(snapshot),捕获最近修改过的 SQL 对象的统计信息
2.2)MMNL进程负责执行轻量级的且频率较高的和可管理性相关的后台任务
例如:捕获会话历史信息,测量值计算等。
2.3)AWR的采样工作默认是由MMON进程每个1小时执行一次,ASH信息同样会被采样写出到AWR负载库中。虽然ASH buffer被设计为保留1小时的信息,但很多时候这个内存是不够的,当ASH buffer写满后,另外一个后台进程MMNL将会主动将ASH信息写出。
3.SYSAUX表空间
AWR 使用几个表来存储采集的统计数据,所有的表都存储在新的名称为 SYSAUX 的特定表空间中的 SYS 模式下,并且以 WRM$_* 和 WRH$_* 的格式命名。前一种类型存储元数据信息(如检查的数据库和采集的快照),后一种类型保存实际采集的统计数据。H 代表“历史数据 (historical)”而 M 代表“元数据 (metadata)”
使用sql语句: select table_name from dba_tables where table_name like ‘WRM$%’ or table_name like ‘WRH$%’;查询
当SYSAUX表空间满后,AWR将自动覆盖掉旧的信息,并在警告日志中记录一条相关信息:
ORA-1688: unable to extend table SYS.WRH$_ACTIVE_SESSION_HISTORY partition WRH$_ACTIVE_3533490838_1522 by 128 in tablespace SYSAUX
4.采样频率和保留时间
可以通过查询视图dba_hist_wr_control或(wrm$_wr_control)来查询AWR的采样频率和保留时间。默认为每1小时采样一次,采样信息保留时间为(7/10g|8/11g)天。
SQL> select * from dba_hist_wr_control;
DBID SNAP_INTERVAL RETENTION TOPNSQL
———- ——————– ——————– ———-
3393548168 +00000 00:30:00.0 +00010 00:00:00.0 DEFAULT
或者
SQL> select DBID, SNAP_INTERVAL, SNAPINT_NUM, RETENTION from wrm$_wr_control;
DBID SNAP_INTERVAL SNAPINT_NUM RETENTION
———- ——————– ———– ——————–
3393548168 +00000 00:30:00.0 1800 +00010 00:00:00.0
修改采集频率和保存时间: exec dbms_workload_repository.modify_snapshot_settings(interval=>30, retention=>5*24*60);
Note:输入的retention参数值不能被目前库中保存的数据的范围小(如果要减少保存时间,需要先删除历史数据)
5.采样数据量
由于数据量巨大,把所有ASH数据写到磁盘上是不可接受的。一般是在写到磁盘的时候过滤这个数据,写出的数据占采样数据的10%,写出时通过direct-path insert完成,尽量减少日志生成,从而最小化数据库性能的影响。
6.初始化参数statistics_level
AWR的行为受到参数STATISTICS_LEVEL的影响。这个参数有三个值:
BASIC:awr统计的计算和衍生值关闭.只收集少量的数据库统计信息.
TYPICAL:默认值.只有部分的统计收集.他们代表需要的典型监控oracle数据库的行为.
ALL : 所有可能的统计都被捕捉. 并且有操作系统的一些信息.这个级别的捕捉应该在很少的情况下,比如你要更多的sql诊断信息的时候才使用.
7.快照管理
7.1)执行
exec dbms_workload_repository.create_snapshot();
7.2)查询
select * from wrh$_active_session_history
7.3)删除
exec dbms_workload_repository.drop_snapshot_range(low_snap_id => 90, high_snap_id => 96, dbid => 1160732652);
8. 基线管理
8.1)创建baseline,保存这些数据用于将来分析和比较
exec dbms_workload_repository.create_baseline(start_snap_id => 1003, end_snap_id => 1013, ‘apply_interest_1′);
8.2)删除baseline
exec DBMS_WORKLOAD_REPOSITORY.DROP_BASELINE(baseline_name => ‘apply_interest_1′, cascade => FALSE);

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

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.

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.

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.

Oracle database paging uses ROWNUM pseudo-columns or FETCH statements to implement: ROWNUM pseudo-columns are used to filter results by row numbers and are suitable for complex queries. The FETCH statement is used to get the specified number of first rows and is suitable for simple queries.

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

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

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.

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.
