oracle故障快速定位

來源:互聯網
上載者:User

首先用作業系統命令找出CPU利用率較高的進程ID

1.查看資料庫當前執行的所有SQL和對應的進程ID

column machine format a16;
column program format a16;
select p.spid,s.status,s.machine,p.program,q.sql_text
from v$session s,v$sqlarea q,v$process p
where s.sql_address=q.address and s.sql_hash_value=q.hash_value
and s.paddr=p.addr
order by 5;

 

2.查看當前被鎖的表和對應的進程ID---------

column object_name format a20;
column program format a30;
column username format a18;
column machine format a16;
select o.object_name, p.spid,l.session_id, s.serial#, s.program,
s.username, s.machine,s.seconds_in_wait
from v$locked_object l, all_objects o, v$session s,v$process p
where o.object_id = l.object_id and s.sid = l.session_id
and s.paddr=p.addr and s.status='ACTIVE'
order by 1 desc;

 查看長時間操作的SQL

column target_desc format a15;column message format a50;column opname format a12;select sid, opname, target_desc,sofar, totalwork, trunc(sofar/totalwork*100,2) || '%' as perwork,to_char(start_time,'DD HH24:MI:SS') starttime,elapsed_seconds,messagefrom v$session_longops order by 8

 

-----Top Event------
select sid,state,wait_class,event from v$session_wait;

-----曆史分析---------- v$active_session_history,DBA_HIST_ACTIVE_SESS_HISTORY
select to_char(sample_time,'DDHH24MI'),count(*) from
DBA_HIST_ACTIVE_SESS_HISTORY
where sample_time>sysdate-1
group by to_char(sample_time,'DDHH24MI')
order by 1

曆史不同時段的共同sql

set pagesize 0
column sql_id format a14;
column sql_text format a50;
select distinct d.sql_id,q.sql_text
from DBA_HIST_ACTIVE_SESS_HISTORY d,v$sqlarea q
where sample_time between to_date('02131558','MMDDHH24MI') and to_date('02131559','MMDDHH24MI')
and d.sql_id=q.sql_id
intersect
select distinct d.sql_id,q.sql_text
from DBA_HIST_ACTIVE_SESS_HISTORY d,v$sqlarea q
where sample_time between to_date('02131551','MMDDHH24MI') and to_date('02131552','MMDDHH24MI')
and d.sql_id=q.sql_id

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.