摘要:本文主要分2部分,一是介绍statspack,这个主要是为了在10g中延续9i的使用习惯。二是介绍awr、addm、ash报告的生成。这是在10g中常用的调优方法,可以在gc或者dbconsole界面中点击查看,也可以用命令行在生成。生成这些报告不难,难的是分析这些报告。
一、statspack:
1、建立statspack:
1 |
@?/rdbms/admin/spcreate |
2、建立snap level为7的snapshot:
1 2 3 4 5 |
var snap number; begin :snap:=statspack.snap(I_SNAP_LEVEL=>7); end; / |
3、执行消耗系统性能的脚本
4、再次snap,同第二步。
5、创建report:
1 |
@?/rdbms/admin/spreport |
6、跟进statspack调整,比如发现buffer busy wait,调整对应的表和表空间。
7、再次运行snap和spreport,观察效果。
二、addm、awr和ash:
awr默认每隔1小时截取一次。
注意,awr可以用图形界面,也可以用包。
在这里,我们先介绍图形界面的操作。
1、图形界面:
1.1 建立snapshot:
你可以用之前创建的gc,也可以用dbconsole(注意db control对后续很有好处,建议在之前安装的时候,勾上。)。
先检查一下dbconsole是否有启动:
1 2 3 4 |
[oracle@ocmdb1 bin]$ ./emctl status dbconsole TZ set to PRC OC4J Configuration issue. /oracle/app/oracle/product/10.2.0/db_1/oc4j/j2ee/OC4J_DBConsole_ocmdb1.localdomain_ocmgc not found. [oracle@ocmdb1 bin]$ |
如果是之前安装的时候没有安装,我们可以用emca来进行安装:
1 |
[oracle@ocmdb1 bin]$ export ORACLE_SID=ocmdb |
先用emca命令看一下有哪些参数:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
[oracle@ocmdb1 bin]$ emca /oracle/app/oracle/product/10.2.0/db_1/bin/emca [operation] [mode] [dbType] [flags] [parameters] -h | --h | -help | --help: prints this help message -version: prints the version -config dbcontrol db [-repos (create | recreate)] [-cluster] [-silent] [-backup] [parameters]: configure Database Control for a database -config centralAgent (db | asm) [-cluster] [-silent] [parameters]: configure central agent management -config all db [-repos (create | recreate)] [-cluster] [-silent] [-backup] [parameters]: configure both Database Control and central agent management -deconfig dbcontrol db [-repos drop] [-cluster] [-silent] [parameters]: de-configure Database Control -deconfig centralAgent (db | asm) [-cluster] [ -silent] [parameters]: de-configure central agent management -deconfig all db [-repos drop] [-cluster] [-silent] [parameters]: de-configure both Database Control and central agent management -addInst (db | asm) [-silent] [parameters]: configure EM for a new RAC instance -deleteInst (db | asm) [-silent] [parameters]: de-configure EM for a specified RAC instance -reconfig ports [-cluster] [parameters]: explicitly reassign Database Control ports -reconfig dbcontrol -cluster [-silent] [parameters]: reconfigures RAC Database Control deployment -displayConfig dbcontrol -cluster [-silent] [parameters]: displays information about the RAC Database Control configuration -upgrade (db | asm | db_asm) [-cluster] [-silent] [parameters]: upgrades an earlier version of the EM configuration to the current version -restore (db | asm | db_asm) [-cluster] [-silent] [parameters]: restores the current version of the EM configuration to an earlier version Parameters and Options: [parameters]: [ -respFile fileName ] [ -paramName paramValue ]* db: perform configuration operation for a database (including databases that use ASM) asm: perform configuration operation for an ASM-only instance db_asm: perform upgrade/restore operation for a database and an ASM instance -repos create: create a new Database Control repository -repos drop: drop the current Database Control repository -repos recreate: drop the current Database Control repository and recreate a new one -cluster: perform configuration operation for a RAC database -silent: perform configuration operation without prompting for parameters -backup: configure automatic backup for a database Parameters for single instance databases HOST: Database hostname SID: Database SID PORT: Listener port number ORACLE_HOME: Database ORACLE_HOME HOST_USER: Host username for automatic backup HOST_USER_PWD: Host user password for automatic backup BACKUP_SCHEDULE: Automatic backup schedule (HH:MM) EMAIL_ADDRESS: Email address for notifications MAIL_SERVER_NAME: Outgoing Mail (SMTP) server for notifications ASM_OH: ASM ORACLE_HOME ASM_SID: ASM SID ASM_PORT: ASM port ASM_USER_ROLE: ASM user role ASM_USER_NAME: ASM username ASM_USER_PWD: ASM user password SRC_OH: ORACLE_HOME for the database to be upgraded DBSNMP_PWD: Password for DBSNMP user SYSMAN_PWD: Password for SYSMAN user SYS_PWD: Password for SYS user DBCONTROL_HTTP_PORT: Database Control HTTP port AGENT_PORT: EM agent port RMI_PORT: RMI port for Database Control JMS_PORT: JMS port for Database Control Additional Parameters for cluster databases CLUSTER_NAME: Cluster name DB_UNIQUE_NAME: Database unique name SERVICE_NAME: Service name EM_NODE: Database Control node name EM_SID_LIST: Agent SID list [comma separated] [oracle@ocmdb1 bin]$ |
我们开始建立(注意会要sys、dbsnmp、sysman三个用户的密码,如果你忘记了,可以去alter user identified一下):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
[oracle@ocmdb1 bin]$ emca -config dbcontrol db -repos create STARTED EMCA at May 8, 2010 7:12:08 PM EM Configuration Assistant, Version 10.2.0.1.0 Production Copyright (c) 2003, 2005, Oracle. All rights reserved. Enter the following information: Database SID: ocmdb Listener port number: 1521 Password for SYS user: Password for DBSNMP user: Password for SYSMAN user: Email address for notifications (optional): Outgoing Mail (SMTP) server for notifications (optional): ----------------------------------------------------------------- You have specified the following settings Database ORACLE_HOME ................ /oracle/app/oracle/product/10.2.0/db_1 Database hostname ................ ocmdb1.localdomain Listener port number ................ 1521 Database SID ................ ocmdb Email address for notifications ............... Outgoing Mail (SMTP) server for notifications ............... ----------------------------------------------------------------- Do you wish to continue? [yes(Y)/no(N)]: Y May 8, 2010 7:14:42 PM oracle.sysman.emcp.EMConfig perform INFO: This operation is being logged at /oracle/app/oracle/product/10.2.0/db_1/cfgtoollogs/emca/ocmdb/emca_2010-05-08_07-12-08-PM.log. May 8, 2010 7:14:44 PM oracle.sysman.emcp.EMReposConfig createRepository INFO: Creating the EM repository (this may take a while) ... May 8, 2010 7:18:05 PM oracle.sysman.emcp.EMReposConfig invoke INFO: Repository successfully created May 8, 2010 7:18:16 PM oracle.sysman.emcp.util.DBControlUtil startOMS INFO: Starting Database Control (this may take a while) ... May 8, 2010 7:20:08 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration INFO: Database Control started successfully May 8, 2010 7:20:08 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration INFO: >>>>>>>>>>> The Database Control URL is http://ocmdb1.localdomain:1158/em <<<<<<<<<<< Enterprise Manager configuration completed successfully FINISHED EMCA at May 8, 2010 7:20:09 PM |
dconsole创建完成,你可以用 http://ocmdb1.localdomain:1158/em来访问了。
由于gc界面和dbconsole界面大同小异,我们就以dbconsole界面为例说说图形界面上的awr操作。gc界面我们不过是多点击了targets-database-选择数据库的操作。
在dbconsole的oem中,到administration-Statistics Management-Automatic Workload Repository-Manage Snapshots and Preserved Snapshot Sets-点击Snapshots后的数字,点击create,创建一个manual snapshot。
1.2 查看report
在Database Instance: ocmdb > Automatic Workload Repository > Snapshots的action的下拉菜单中,点击view report-go,当前选择的snapid是起始的,点击go之后会让你选择终止snapid。
1.3 生成addm
在awr report界面,点击view addm run.
也可以在home-下面的Advisor Central-ADDM
1.4 看awr的不同时间段对比报告:
在awr界面,点击compare periods
需要观察的是report部分。
1.5 看ash报告:
到Performance-run ASH report-点击Top Activity-选中中间长条的时间段-点击Run ASH Report-
2、我们再来看看命令行是怎么建立的,命令行的比图形界面更简单,字符控的同学可以用这个生产text来玩:
2.1 创建snapshot:
1 2 3 4 5 6 7 8 |
SQL> begin 2 dbms_workload_repository.CREATE_SNAPSHOT; 3 end; 4 / PL/SQL procedure successfully completed. SQL> |
2.2 产生awr report:
1 |
@?/rdbms/admin/awrrpt.sql |
2.3 产生addm report:
1 |
@?/rdbms/admin/addmrpt.sql |
2.4 产生awr对比报告:
1 |
@?/rdbm/admin/awrddrpt.sql |
2.5 产生ash报告:
1 |
@?/rdbms/admin/ashrpt.sql |
3条评论
没记错的话,只会考statspack的内容,多看看这个就ok了,无非是创建,然后生成报告就ok的,嘿嘿。
不是吧!居然考statspack?我觉得我等新手没什么机会用9i,准备完全不看的……
什么時間考試﹐考過了嗎?
也想考﹐正准備中呢?
到時可要請教了﹐赫赫﹗
新工作開始了嗎﹐高就在哪呀﹗