您好,登錄后才能下訂單哦!
這篇文章主要講解了“ORACLE問題處理的腳本是什么”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“ORACLE問題處理的腳本是什么”吧!
登上數據庫服務器后,第一個就是通過系統命令確認下CPU、內存、I/O是否異常,每個系統的命令不一樣,常見的有top、topas、vmstat、iostat
--wait_event col event for a45 SELECT inst_id,EVENT, SUM(DECODE(WAIT_TIME, 0, 0, 1)) "Prev", SUM(DECODE(WAIT_TIME, 0, 1, 0)) "Curr", COUNT(*) "Tot" , sum(SECONDS_IN_WAIT) SECONDS_IN_WAIT FROM GV$SESSION_WAITWHERE event NOT IN ('smon timer','pmon timer','rdbms ipc message','SQL*Net message from client', 'gcs remote message') AND event NOT LIKE '%idle%' AND event NOT LIKE '%Idle%' AND event NOT LIKE '%Streams AQ%'GROUP BY inst_id,EVENTORDER BY 1,5 desc;
--session_by_event SELECT /*+rule */ sid, s.serial#, spid, event, sql_id, seconds_in_wait ws, row_wait_obj# obj, s.username, s.machine, BLOCKING_INSTANCE||'.'||blocking_session b_sess FROM v$session s, v$process p WHERE event='&event_name' AND s.paddr = p.addr order by 6;
--session_by_sid SELECT s.sid, s.serial#, spid, event, sql_id, PREV_SQL_ID, seconds_in_wait ws, row_wait_obj# obj,s.username, s.machine, module,blocking_session b_sess,logon_time FROM v$session s, v$process p WHERE sid = '&sid' AND s.paddr = p.addr;
--obj_info col OBJECT_NAME for a30 select owner,object_name,subobject_name,object_type from dba_objects where object_id=&oid;
--sql_text select sql_id,SQL_fullTEXT from v$sqlarea --DBA_HIST_SQLTEXT where (sql_id='&sqlid' or hash_value=to_number('&hashvale') ) and rownum<2;
--blocking_sess select count(*),blocking_session from v$session where blocking_session is not null group by blocking_session;
--lockset linesize 180 col username for a15 col owner for a15 col OBJECT_NAME for a30 col SPID for a10 --查詢某個會話的鎖 select /*+rule*/SESSION_ID,OBJECT_ID,ORACLE_USERNAME,OS_USER_NAME,PROCESS,LOCKED_MODE from gv$locked_object where session_id=&sid; --查詢TM、TX鎖 select /*+rule*/* from v$lock where ctime >100 and type in ('TX','TM') order by 3,9; --查詢數據庫中的鎖 select /*+rule*/s.sid,p.spid,l.type,round(max(l.ctime)/60,0) lock_min, s.sql_id,s.USERNAME,b.owner,b.object_type,b.object_name from v$session s, v$process p,v$lock l,v$locked_object o,dba_objects b where o.SESSION_ID=s.sid and s.sid=l.sid and o.OBJECT_ID=b.OBJECT_ID and s.paddr = p.addr and l.ctime >100 and l.type in ('TX','TM','FB') group by s.sid,p.spid,l.type,s.sql_id,s.USERNAME,b.owner,b.object_type,b.object_name order by 9,1,3;
--systemstate dump sqlplus -prelim / as sysdba oradebug setmypid oradebug unlimit; oradebug dump systemstate 266; --wait for 1 min oradebug dump systemstate 266; --wait for 1 min oradebug dump systemstate 266; oradebug tracefile_name; --hanganalyze oradebug setmypid oradebug unlimit; oradebug dump hanganalyze 3 --wait for 1 min oradebug dump hanganalyze 3 --wait for 1 min oradebug dump hanganalyze 3 oradebug tracefile_name
--kill_sess set line 199 col event format a35 --殺某個SID會話 SELECT /*+ rule */ sid, s.serial#, 'kill -9 '||spid, event, blocking_session b_sess FROM v$session s, v$process p WHERE sid='&sid' AND s.paddr = p.addr order by 1; --根據SQL_ID殺會話 SELECT /*+ rule */ sid, s.serial#, 'kill -9 '||spid, event, blocking_session b_sess FROM v$session s, v$process p WHERE sql_id='&sql_id' AND s.paddr = p.addr order by 1; --根據等待事件殺會話 SELECT /*+ rule */ sid, s.serial#, 'kill -9 '||spid, event, blocking_session b_sess FROM v$session s, v$process p WHERE event='&event' AND s.paddr = p.addr order by 1; --根據用戶殺會話 SELECT /*+ rule */ sid, s.serial#, 'kill -9 '||spid, event, blocking_session b_sess FROM v$session s, v$process p WHERE username='&username' AND s.paddr = p.addr order by 1; --kill所有LOCAL=NO進程 ps -ef|grep LOCAL=NO|grep $ORACLE_SID|grep -v grep|awk '{print $2}' | xargs kill -9
感謝各位的閱讀,以上就是“ORACLE問題處理的腳本是什么”的內容了,經過本文的學習后,相信大家對ORACLE問題處理的腳本是什么這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。