Oracle 11g CPU负载很高紧急处理【负载100%】

\\ 查询负载很高前35个进程

ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head -35

\\ 查询前35负载高的sPID

ps aux|grep -v PID|sort -rn -k +3|head -35|awk {print$2}

\\ 把得到的spid替换进来(!!!注意不要少了逗号和分号!!!)

select sql_id from v$session
where paddr in(
select addr from v$process
where spid in(
‘30907‘,
‘31801‘,
‘31463‘,
‘31150‘,
‘32289‘,
‘31895‘,
‘590‘,
‘31952‘,
‘611‘,
‘32152‘,
‘661‘,
‘32542‘,
‘32203‘,
‘2019‘,
‘2215‘
)
)

 

 

 

查询结果显示,sql_id为 fm0738ywgbyxk 出现很多(异常sql_id)

---注:请替换成您实际的sql_id

---注:请替换成您实际的sql_id

---注:请替换成您实际的sql_id

 

---fm0738ywgbyxk
---12个进程

SELECT sid,serial#,sql_id from v$session where sql_id in ( fm0738ywgbyxk );
SELECT count(*) from v$session where sql_id in ( fm0738ywgbyxk );

---随机抽一条,查看一下具体是执行的啥内容

select sql_text from v$sqlarea a,v$session b where a.SQL_ID=b.PREV_SQL_ID and b.SID=291;

select c.SCHOOL_ID WAREHOUSE_ID, count( ARCHIVE_ID) SIGN,c.BUSINESS_TYPE from TB_CONTRACT c,FES_STAFF_ARCHIVE st where c.state!=2000 and st.id=c.ARCHIVE_ID and c.PAY_DATE between to_date(‘2020-02-01 00:00:00‘,‘yyyy-MM-dd HH24:MI:SS‘) and to_date(‘2020-04-27 23:59:59‘,‘yyyy-MM-dd HH24:MI:SS‘) and c.BUSINESS_TYPE in (17,21) group by c.SCHOOL_ID ,c.BUSINESS_TYPE

 

--- 生成kill语句

SELECT
alter system kill session ‘‘‘ || SID || , || serial# || ‘‘‘;
FROM
v$session
WHERE
sql_id IN (fm0738ywgbyxk);


--- 执行生成的kill语句,如下:

alter system kill session 291,42431;
alter system kill session 483,24520;
alter system kill session 667,23176;
alter system kill session 768,57609;
alter system kill session 861,65267;
alter system kill session 1243,1739;
alter system kill session 1335,44615;
alter system kill session 1522,31640;
alter system kill session 1622,30425;
alter system kill session 1716,7696;
alter system kill session 1808,44494;
alter system kill session 2096,58865;

Oracle 11g CPU负载很高紧急处理【负载100%】

上一篇:Sql进阶语法


下一篇:RDS下执行SQL小脚本