---
title: "oracle性能调优"
author: "lansky07"
date: "2009-03-08T19:27:01Z"
tags: []
slug: "oracle"
draft: false
lastmod: "2009-03-08T19:27:01Z"
id: 345494
url: "https://lansky07.iteye.com/blog/345494"
---

who trnes?  
application designers  
application developers  
database administrators  
system administrators

performance tuning areas:  
Application:  调优是一个团队的过程  
 sql statement performance  
 chanage management           
Instance tuning:  
 Memory  
 Database structure  
 instance configuration  
Operating system interactions:  
 I/O  
 Swap  
 Parameters

what to tune?  
好的DBA先监控  
How much tuning is required?  
1、减少用户的等待时间  
2、吞吐量大  
3、减少对磁盘的操作  
4、提高cache的命中率

调优应该在不同阶段：  
1、application design and programming 在系统设计，开发阶段  
2、Database configuration   数据库配置  
3、Adding a new application to an existing database  在一个已经存在数据库曾加系统  
4、Troubleshooting and tuning  在使用过程中  
调优目标：  
1、minimizing response time  响应时间  
2、increasing throughput  
3、increasing load capabilities  增加负荷能力  
4、decreasing recovery time  减少恢复时间

Tuning Steps in Development 开发阶段调优部骤：  
tune the design  表结构是否设计合理，不能过份追求规范化  
tune the application    检查如sql  
tune memory  
tune i/o  
tune contention  
tune the operation system

Baseline of Statistaices:基准基线  
在特定条件下建立一个系统工作的子标报告

投产使用阶段：  
1、定义问题  
2、收集子标  
3、考虑检查一些通用的性能错误  
4、假定猜想一个错误  
5、尝试去解决问题  
6、检查是否解决问题

调优的一些方法论：  
1、检查日志文件  
2、检查参数是否设置正确  
3、检查系统内存IOCPU等使用率  
4、判断SQL

系统使用很慢慢处理：  
1、分析等待时间还是处理问题时间慢  
2、检查哪部分占用时间最多  
3、把每个时间进一点细化

影响性能的一些因素，权衡性能和安全  
1、oracel控制文件太多，安全提高  
2、redo log文件变多  
3、Frequent checkpointing  
4、Backing up data files  
5、Performing archiving  
6、Block check numbers  
7、Number of concurrent users and transactions

 

Diagnostic诊断 and Tuning Tools 调优工具:Statspack  
了解日志文件的重要性及信息  检查日志文件alert log(常识)  
了解后台进程  
了解....

找到日志文件存放的目录：  
登录oracle系统conn /as sysdba  
sql&gt;show parameter dump   可以看到  
background\_dump\_dest     string     /u01/admin/pitts/bdump  
....

日志文件即存放在以上显示的目录下/u01/admin/pitts/bdump  
到此目录下查看 ls -l  可得到alert\_pitts.log  即alert\_+SID.log文件  
在打开的文件中查找日志文件中的错误命令：ORA- ；内部错误：ORA-600  
此文件会不断的增长，要时常拷贝走或清空  
mv ... cp ...  
清空：cat /dev/null &gt; alert\_pitts.log

要获取检查点信息，即会在日志文件中记录，要修改参数：  
SQL&gt;show parameter log\_ch  
SQL&gt;alert system set log\_checkpoints\_to\_alert = true scope=both;  
SQL&gt;alert system checkpoint;  
SQL&gt;vi /u01/admin/pitts/bdump/alert\_pitts.log  即可看到

和进程相关的:BP Trace Files  
这个文件也在/u01/admin/pitts/bdump目录下的如：pitts\_ora\_16697.trc文件  
组成为：oracle的SID\_ora\_程程ID

User Trance Files: 用户trance文件  
包含了用户执行的sql信息，每个进程一个