Decode360's Blog

          業(yè)精于勤而荒于嬉 QQ:150355677 MSN:decode360@hotmail.com

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 ::  :: 管理 ::
            302 隨筆 :: 26 文章 :: 82 評論 :: 0 Trackbacks
          一、重要的腳本
          ?
          ??? 1、通過導(dǎo)出保存及共享數(shù)據(jù)
          ?
          ??? 有時需要將原始數(shù)據(jù)導(dǎo)出后,請教專業(yè)人士進行分析,可以使用spuexp.par,內(nèi)容如下:
          ?
          ??? file=spuexp.dmp log=spuexp.log compress=y grants=y indexes=y rows=y constraints=y owner=PERFSTAT consistent=y
          ?
          ??? 使用一下腳本進行導(dǎo)出:
          ?
          ??? SQL> host exp userid=perfstat/perfstat parfile=E:\oracle\product\10.2.0\db_1\RDBMS\ADMIN\spuexp.par
          ??? ... ...
          ??? 成功終止導(dǎo)出, 沒有出現(xiàn)警告。
          ?
          ??? 在當(dāng)前目錄下生成spuexp.dmp文件。
          ?
          ??? 2、刪除數(shù)據(jù)腳本
          ?
          ??? 用于刪除數(shù)據(jù)的spdrop.sql腳本主要調(diào)用了spdtab.sql和spdusr.sql兩個腳本
          ??? spdtab.sql用于刪除表和同義詞
          ??? spdusr.sql用于刪除用戶
          ?
          ?
          二、調(diào)整Statspack收集選項
          ?
          ??? Statspack有兩種類型的收集選項:級別(level)、門限(threshold)
          ?
          ??? 1、級別(level)
          ?
          ??? 一共分為三個級別,分別是0、5、10,默認(rèn)是5。
          ?
          ??? ① level 0:一般性統(tǒng)計。包括等待事件、系統(tǒng)事件、系統(tǒng)統(tǒng)計、回滾段統(tǒng)計、行緩存、SGA、會話鎖、緩沖池統(tǒng)計等
          ??? ② level 5:增加SQL語句。SQL語句收集結(jié)果放在stats$sql_summary中
          ??? ③ level 10:增加子鎖存統(tǒng)計。將附加子鎖存入stats$lathc_children中(本級別建議在oracle support指導(dǎo)下進行)
          ?
          ??? 修改方式:
          ?
          ??? ① SQL> execute statspack.snap(i_snap_level=>0,modify_parameter=>'true'); --以后都修改
          ??? ② SQL> execute statspack.snap(i_snap_level=>10); --只修改本次
          ?
          ??? 2、快照門限
          ?
          ??? 門限只用于stats$sql_summary表中獲取的SQL語句。由于每個快照都會收集很多數(shù)據(jù),每一行都代表獲取快照時數(shù)據(jù)庫中的一個SQL語句,因此stats$sql_summary很快就會成為Statspack中最大的表,所以需要加門限進行限制。
          ?
          ??? executions_th:SQL語句執(zhí)行的數(shù)量(默認(rèn)值100)
          ??? disk_reads_th:SQL語句執(zhí)行的磁盤讀入數(shù)(默認(rèn)值1000)
          ??? parse_calls_th:SQL語句執(zhí)行的解析調(diào)用數(shù)量(默認(rèn)值1000)
          ??? buffer_gets_th:SQL語句執(zhí)行的緩沖區(qū)獲取的數(shù)量(默認(rèn)值10000)
          ?
          ??? 任何一個門限值超過以上參數(shù)就會產(chǎn)生一條記錄。
          ?
          ??? 使用一下腳本修改門限的默認(rèn)值:
          ?
          ??? SQL> execute statspack.modify_statspack_parameter(i_buffer_gets_th=>100000,i_disk_reads_th=>100000);
          ?
          ???
          ?
          三、整理分析結(jié)果
          ?
          ?
          ??? Statspack進行快照采集之后,會在stats$sysstat表中,針對每個snap生成N行數(shù)據(jù),每一行表示當(dāng)前某一項參數(shù)的值,具體的參數(shù)代碼及名稱可以使用以下腳本查詢:
          ?
          ??? SQL> select distinct statistic#,name from stats$sysstat order by 1;
          ?
          ??? statistic# name
          ??? ---------- ------------------------------------
          ?????????????0?logons cumulative
          ???????????? 1?logons current
          ????????? ?? 2?opened cursors cumulative
          ???????????? 3?opened cursors current
          ??????????? ?4?user?commits
          ??? ... ...
          ?
          ??? 1、物理讀寫IO操作:
          ?
          select sn.snap_id,
          ?????? to_char(snap_time, 'hh24:mi:ss') sp_time,
          ?????? (newreads.value - oldreads.value) reads,
          ?????? (newwrites.value - oldwrites.value) writes
          ? from stats$sysstat? oldreads,
          ?????? stats$sysstat? newreads,
          ?????? stats$sysstat? oldwrites,
          ?????? stats$sysstat? newwrites,
          ?????? stats$snapshot sn
          ?where newreads.snap_id = sn.snap_id
          ?? and newwrites.snap_id = sn.snap_id
          ?? and oldreads.snap_id = sn.snap_id - 1
          ?? and oldwrites.snap_id = sn.snap_id - 1
          ?? and oldreads.statistic# = 37
          ?? and newreads.statistic# = 37
          ?? and oldwrites.statistic# = 40
          ?? and newwrites.statistic# = 40
          ?? and (newreads.value - oldreads.value) > 0
          ?? and (newwrites.value - oldwrites.value) > 0;
          ?
          ??? 該SQL表述了在各個時間段中的IO物理讀和IO物理寫的數(shù)量,可用于分析各個時間段的峰值以及平均IO量,以減少競爭。
          ?
          ??? 2、Buffer命中率:
          ?
          select sn.snap_id,
          ?????? to_char(snap_time, 'hh24:mi:ss') sp_time,
          ?????? round(100 *
          ???????????? ((a.value - d.value) + (b.value - e.value) - (c.value - f.value))
          ?????????? / ((a.value - d.value) + (b.value - e.value))) "Buffer Hit Ratio"
          ? from stats$sysstat? a,
          ?????? stats$sysstat? b,
          ?????? stats$sysstat? c,
          ?????? stats$sysstat? d,
          ?????? stats$sysstat? e,
          ?????? stats$sysstat? f,
          ?????? stats$snapshot sn
          ?where a.snap_id = sn.snap_id
          ?? and b.snap_id = sn.snap_id
          ?? and c.snap_id = sn.snap_id
          ?? and d.snap_id = sn.snap_id - 1
          ?? and e.snap_id = sn.snap_id - 1
          ?? and f.snap_id = sn.snap_id - 1
          ?? and a.statistic# = 47
          ?? and d.statistic# = 47
          ?? and b.statistic# = 50
          ?? and e.statistic# = 50
          ?? and c.statistic# = 54
          ?? and f.statistic# = 54;
          ?
          ??? 注:Buffer Hit Ratio = (db block gets + consistent gets - physical reads) / (db block gets + consistent gets)
          ?
          ?
          ?
          ?




          -The End-

          posted on 2009-01-19 21:50 decode360-3 閱讀(217) 評論(0)  編輯  收藏 所屬分類: Oracle
          主站蜘蛛池模板: 蛟河市| 凤阳县| 涞源县| 石城县| 漳平市| 长治市| 孝昌县| 怀仁县| 武宣县| 和政县| 柳河县| 成都市| 平罗县| 云林县| 华阴市| 隆安县| 北海市| 郸城县| 宁明县| 高要市| 德阳市| 万安县| 读书| 富平县| 界首市| 四子王旗| 乡宁县| 托克逊县| 万年县| 阿拉尔市| 金湖县| 筠连县| 吴江市| 获嘉县| 丹凤县| 巴里| 兰溪市| 井研县| 祥云县| 裕民县| 临泽县|