標籤:oracle ash dump
最近在看一些Oracle分享的時候,經常提到匯出ASH的dump給另外的人來做分析,但我沒有什麼相關的操作,不知道是怎樣的一個操作流程,於是上網看了各種博文。於是自己動手做實驗做一次匯出匯入。
實驗環境:Oracle 11.2.0.4+rhel 7.2
執行下面的語句對ASH資訊做dump操作
[email protected]>alter system set events ‘immediate trace name ashdump level 10‘;
上面的語句中level的意思是dump出ASH buffer中最近n分鐘的資料,這裡以10分鐘為例。
使用下面的語句打到對應的trace檔案
[email protected]>SELECT value FROM v$diag_info WHERE name = ‘Default Trace File‘;VALUE-------------------------------------------------------------------/u01/app/oracle/diag/rdbms/ora11g/ora11g/trace/ora11g_ora_7556.trc
先簡單查看一下trace檔案中的內容:
650) this.width=650;" src="https://s4.51cto.com/wyfs02/M00/07/44/wKiom1nGKjDybuqCAADAJ3BVIGQ357.png" style="float:none;" title="1.png" alt="wKiom1nGKjDybuqCAADAJ3BVIGQ357.png" />
650) this.width=650;" src="https://s4.51cto.com/wyfs02/M01/A5/F5/wKioL1nGKfiycWVXAACIYhiYpMA350.png" style="float:none;" title="2.png" alt="wKioL1nGKfiycWVXAACIYhiYpMA350.png" />
從上面的兩個圖中可以看到trace檔案中包含了三類資訊:trace的基本資料、匯入dump的方法和ash的實際資料,其實只要按照trace中的檔案給出的方法就可以很容易的把dump資料匯入到資料庫中。
1、建立暫存資料表
CREATE TABLE ashdump ASSELECT * FROM SYS.WRH$_ACTIVE_SESSION_HISTORY WHERE rownum < 0;
2、產生sqlldr的control file
[[email protected] ash]$ sed -n ‘1,/^Step 2:/d;/^Step 3:/,$d;p‘ ora11g_ora_7556.trc |sed ‘/^-/d‘ > ashldr.ctl
3、使用sqlldr工具把trace檔案中的資料匯入到暫存資料表中
[[email protected] ash]$ sqlldr zx/zx control=ashldr.ctl data=ora11g_ora_7556.trc errors=1000000SQL*Loader: Release 11.2.0.4.0 - Production on Sat Sep 23 17:16:40 2017Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.Commit point reached - logical record count 19Commit point reached - logical record count 37Commit point reached - logical record count 55Commit point reached - logical record count 73Commit point reached - logical record count 91Commit point reached - logical record count 109Commit point reached - logical record count 127Commit point reached - logical record count 145Commit point reached - logical record count 163Commit point reached - logical record count 181Commit point reached - logical record count 199Commit point reached - logical record count 217Commit point reached - logical record count 235Commit point reached - logical record count 253Commit point reached - logical record count 271Commit point reached - logical record count 289Commit point reached - logical record count 307Commit point reached - logical record count 325Commit point reached - logical record count 343Commit point reached - logical record count 361Commit point reached - logical record count 379Commit point reached - logical record count 397Commit point reached - logical record count 415Commit point reached - logical record count 433Commit point reached - logical record count 451Commit point reached - logical record count 469Commit point reached - logical record count 487Commit point reached - logical record count 505Commit point reached - logical record count 523Commit point reached - logical record count 541Commit point reached - logical record count 559Commit point reached - logical record count 577Commit point reached - logical record count 595Commit point reached - logical record count 613Commit point reached - logical record count 631Commit point reached - logical record count 649Commit point reached - logical record count 651[email protected]>select count(*) from ashdump; COUNT(*)---------- 650
資料匯入成功後就可以根據具體的問題現在做近一步的分析。
其實匯出和匯入的步驟非常簡單,Oracle直接給出了步驟,難的是拿到資料後如何使用這些資料進行近一步的分析,從而找出問題的根本原因。
如下分析每個sampletime的會話數量
650) this.width=650;" src="https://s5.51cto.com/wyfs02/M00/A5/F5/wKioL1nGLUGRx4j_AABJYZtjTBQ239.png" title="Capture.PNG" alt="wKioL1nGLUGRx4j_AABJYZtjTBQ239.png" />
參考:http://www.eygle.com/archives/2009/08/howto_dump_ashinfo.html
https://antognini.ch/2017/07/offline-analysis-of-ash-data-with-ashdump/
本文出自 “DBA Fighting!” 部落格,請務必保留此出處http://hbxztc.blog.51cto.com/1587495/1968021
Oracle 匯出 ASH的dump資訊