《OracleAWR与ASH性能报告深入解析》一数据库版本LEO1@LEO1select*fromv$version;BANNER---------------------------------..
《Oracle AWR与ASH性能报告深入解析》
一数据库版本
LEO1@LEO1> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
二 AWR性能诊断报告
AWR:Automatic Workload Repository 自动工作负载信息库
通常在诊断数据库性能的时候分三个阶段
第一阶段:SQL语句级性能优化
第二阶段:session级性能优化,这时我们可以用ASH来做分析
第三阶段:DB级性能优化,AWR就是数据库层性能诊断报告,当我们无法判断数据库哪里性能出现问题时我们可以做一个全身体检报告来找到我们瓶颈所在。
AWR机制:通过对系统整体动态采样收集快照信息,存储在SYSAUX表空间,每小时采样一次,可以保存7天,MMON进程实施,快照分析后写入DBA_HIST_%开头的数据字典。
AWR信息来源:DBA_HIST_%开头的数据字典,请见下图
LEO1@LEO1> select table_name from dictionary where table_name like 'DBA_HIST_%';
TABLE_NAME
------------------------------------------------
DBA_HIST_ACTIVE_SESS_HISTORY
DBA_HIST_ASH_SNAPSHOT
DBA_HIST_BASELINE
DBA_HIST_BASELINE_DETAILS
DBA_HIST_BASELINE_METADATA
DBA_HIST_BASELINE_TEMPLATE
DBA_HIST_BG_EVENT_SUMMARY
DBA_HIST_BUFFERED_QUEUES
DBA_HIST_BUFFERED_SUBSCRIBERS
DBA_HIST_BUFFER_POOL_STAT
DBA_HIST_CLUSTER_INTERCON
DBA_HIST_COLORED_SQL
DBA_HIST_COMP_IOSTAT
DBA_HIST_CR_BLOCK_SERVER
DBA_HIST_CURRENT_BLOCK_SERVER
DBA_HIST_DATABASE_INSTANCE
DBA_HIST_DATAFILE
DBA_HIST_DB_CACHE_ADVICE
…………………………………………………
109 rows selected.
AWR信息就是来自上面这些数据字典表,它是把这些表中数据进行汇总统计后生成HTML or TXT格式
LEO1@LEO1> select snap_id,name,value from DBA_HIST_SGA where snap_id>=173 and snap_id
SNAP_ID NAME VALUE
---------- ----------------------------------------------------------------------------------------------------------------------------------
173 Database Buffers 117440512
173 Fixed Size 2214856
173 Redo Buffers 8052736
173 Variable Size 385877048
174 Database Buffers 117440512
174 Fixed Size 2214856
174 Redo Buffers 8052736
174 Variable Size 385877048
上面这个例子显示了173-174快照中SGA的信息
OEM可以生成图形化性能分析图,UI版AWR
AWR基线:我们可以在数据库平稳正常的状态下创建AWR基线(参照物),在实际生产中可以作为性能指标曲线的一个参照物,有了基线对比,我们就可以很方便的了解到系统的一个真实的性能趋势。
AWR创建:sqlplus / as system @下面的脚本就可以创建AWR报告了
创建脚本目录:/u01/app/oracle/product/11.2.0/db_1/rdbms/admin/awrrpt.sql
AWR报告分析说明
1. WORKLOAD REPOSITORY report for
2. DB Name
DB Id
Instance
Inst num
Startup Time
Release
RAC
EMSTA
433507400
emsta1
1
14-Aug-12 22:08
11.2.0.2.0
YES
Host Name
Platform
CPUs
Cores
Sockets
Memory (GB)
emsta1
Solaris[tm] OE (64-bit)
64
32
8
128.00
Snap Id
Snap Time
Sessions
Cursors/Session
Begin Snap:
6023
07-Sep-12 14:00:09
1788
2.8
End Snap:
6026
07-Sep-12 17:00:06
1793
2.9
Elapsed:
179.94 (mins)
DB Time:
79.25 (mins)
数据库名:EMSTA DB ID:433507400 实例名:emsta1 第一个实例 启动时间 版本 是RAC
主机名:emsta1 操作系统平台:Solaris 64位 64颗CPU 32核 内存:128GB
由上述硬件判断这是2台小机组成的RAC模式数据库,上面的是实例1,下面的是实例2,名称后缀不同。
起始快照id:6023
终止快照id:6026 快照与快照间隔1小时从14:00~17:00一共3小时采样信息
起始快照与终止快照间隔时间:180分钟
所有用户使用数据库时间总和(累加值):80分钟
起始时间有1788个会话,每个会话使用2.8个游标
结束时间有1793个会话,,每个会话使用2.9个游标
DB Name
DB Id
Instance
Inst num
Startup Time
Release
RAC
EMSTA
433507400
emsta2
2
14-Aug-12 22:08
11.2.0.2.0
YES
Host Name
Platform
CPUs
Cores
Sockets
Memory (GB)
emsta2
Solaris[tm] OE (64-bit)
64
32
8
128.00
Snap Id
Snap Time
Sessions
Cursors/Session
Begin Snap:
6023
07-Sep-12 14:00:09
1363
3.0
End Snap:
6026
07-Sep-12 17:00:06
1378
3.0
Elapsed:
179.94 (mins)
DB Time:
136.61 (mins)
实例2中各个部分的含义值和实例1相同,这里不再另外说明
2.cache size
Begin
End
Buffer Cache:
15,360M
15,360M
Std Block Size:
8K
Shared Pool Size:
6,272M
6,272M
Log Buffer:
111,456K
Instance1:数据库缓冲区15360M
共享池6272M
redo log 缓冲区111.456M
数据块大小8K
Buffer Cache:
13,696M
13,696M
Std Block Size:
8K
Shared Pool Size:
6,144M
6,144M
Log Buffer:
111,456K
Instance2:数据库缓冲区13696M
共享池6144M
redo log 缓冲区111.456M
数据块大小8K
2个实例的SGA有一点点的大小差异,但是差距不大。
3.Load profile
数据库负载属性信息 美秒 每个事物 每次执行 每次调用
Per Second
Per Transaction
Per Exec
Per Call
DB Time(s):
0.4
0.3
0.01
0.00
DB CPU(s):
0.4
0.2
0.01
0.00
Redo size:
15,275.9
8,983.0
Logical reads:
13,716.1
8,065.8
Block changes:
79.2
46.6
Physical reads:
365.3
214.8
Physical writes:
4.5
2.7
User calls:
232.7
136.8
Parses:
11.4
6.7
Hard parses:
0.3
0.2
W/A MB processed:
2.7
1.6
Logons:
0.0
0.0
Executes:
54.3
32.0
Rollbacks:
0.0
0.0
Transactions:
1.7
Instance1:逻辑读和物理读较多,是以读为主
Instance2:物理写较多,是以写为主
如果我们有一个基线值,就好比较性能优略了
Per Second
Per Transaction
Per Exec
Per Call
DB Time(s):
0.8
0.1
0.00
0.00
DB CPU(s):
0.4
0.1
0.00
0.00
Redo size:
102,788.5
11,594.5
Logical reads:
4,287.6
483.6
Block changes:
436.4
49.2
Physical reads:
100.5
11.3
Physical writes:
40.6
4.6
User calls:
261.7
29.5
Parses:
108.9
12.3
Hard parses:
0.1
0.0
W/A MB processed:
0.9
0.1
Logons:
3.1
0.4
Executes:
263.1
29.7
Rollbacks:
0.0
0.0
Transactions:
8.9
业务类型不同关注数据指标也不同
OLAP:关注IO指标
OLTP:关注内存 CPU指标
4.Top 5 Timed Foreground Events
Leonarding
2013.3.10
天津&spring
分享技术~成就梦想
Blog:
本文出自 “刘盛分享技术~成就梦想” 博客,请务必保留此出处

Stored procedures are precompiled SQL statements in MySQL for improving performance and simplifying complex operations. 1. Improve performance: After the first compilation, subsequent calls do not need to be recompiled. 2. Improve security: Restrict data table access through permission control. 3. Simplify complex operations: combine multiple SQL statements to simplify application layer logic.

The working principle of MySQL query cache is to store the results of SELECT query, and when the same query is executed again, the cached results are directly returned. 1) Query cache improves database reading performance and finds cached results through hash values. 2) Simple configuration, set query_cache_type and query_cache_size in MySQL configuration file. 3) Use the SQL_NO_CACHE keyword to disable the cache of specific queries. 4) In high-frequency update environments, query cache may cause performance bottlenecks and needs to be optimized for use through monitoring and adjustment of parameters.

The reasons why MySQL is widely used in various projects include: 1. High performance and scalability, supporting multiple storage engines; 2. Easy to use and maintain, simple configuration and rich tools; 3. Rich ecosystem, attracting a large number of community and third-party tool support; 4. Cross-platform support, suitable for multiple operating systems.

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi


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

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 English version
Recommended: Win version, supports code prompts!

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.

Atom editor mac version download
The most popular open source editor

SublimeText3 Chinese version
Chinese version, very easy to use
