### LOCAL=NO 세션 강제 종료 절차 (전체)
1) 백그라운드 프로세스 이외, 단순 서비스 접속 세션(LOCAL=NO) 조회
(SID 에 따른 oracle 프로세스 변경 사용 필수!)
aaa=`ps -ef|grep LOCAL=NO|grep oracle[SID]|grep -v grep|awk '{print $2}'`
2) kill 대상 세션 조회
echo $aaa
3) 세션 kill
kill -9 $aaa
### 불필요한 일부 세션 강제 종료 절차
1) 아래의 SQL 활용하여, 조건 수정해서 대상 선별
2) 결과값으로 서버에서 세션 kill 실행
(Sample SQL)
select distinct s.inst_id "ID", s.status "Status",p.spid, s.SID, s.serial#,
s.sql_id "Sql id", round(s.last_call_et) "els(Sec)", event,
s.username "DB User", s.osuser "Client User", s.machine "Machine", s.module "Module",
s.terminal "Terminal", s.program "Program", p.program "O.S. Program", lockwait "Lock Wait",
s.blocking_session_status "block ses stat", s.blocking_instance "block instance", s.blocking_session "block session",
s.logon_time "Connect Time",sysdate - (s.last_call_et / 86400) "Last Call"
from gv$session s, gv$process p
where s.paddr = p.addr(+) and s.inst_id = p.inst_id(+)
and s.type <> 'BACKGROUND'
and s.status = 'ACTIVE'
--and p.spid in (12133, 12100)
--and s.SID in (1749)
--and s.sql_id = ''
--and s.username = ''
--and s.osuser not in ('DBSNMP','SYSMAN')
--and s.blocking_session is not null
--and s.machine = ''
--and s.module like 'JDBC Thin Client%'
order by s.inst_id, "els(Sec)" desc
;
(kill SQL)
select 'kill -9 '||p.spid
from gv$session s, gv$process p
where s.paddr = p.addr(+) and s.inst_id = p.inst_id(+)
and s.type <> 'BACKGROUND'
and s.status = 'ACTIVE'
--and p.spid in (12133, 12100)
--and s.SID in (1749)
--and s.sql_id = 'ck17jd0fufztx'
--and s.username = ''
--and s.osuser not in ('','')
--and s.blocking_session is not null
--and s.machine = ''
--and s.module like 'JDBC Thin Client%'
;
'IT' 카테고리의 다른 글
[Linux] CPU 수량 정보 확인 명령어 (0) | 2023.03.03 |
---|---|
[Oracle] Temp Tablespace 관리를 위한 쿼리 (0) | 2023.03.02 |
[Oracle] ASM Size check (0) | 2023.02.28 |
[Oracle] DBMS_METADATA 패키지를 활용한 User 및 Tablespace DDL 추출하기 (0) | 2023.02.27 |
[Python]파이썬 온라인에서 작업하던 패키지 전체 오프라인 환경으로 이관하는 방법 (0) | 2023.02.25 |
댓글