[20211129]完善tpt killi.sql指令碼.txt
[20211129]完善tpt killi.sql指令碼.txt
--//原始指令碼僅僅kill單個例項的相關程式,修改可以工作在多個例項上的指令碼。
$ cp killi.sql killix.sql
$ cat killix.sql
-- Copyright 2018 Tanel Poder. All rights reserved. More info at
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
--------------------------------------------------------------------------------
--
-- File name: kill.sql
-- Purpose: Generates commands for killing selected sessions
--
-- Author: Tanel Poder
-- Copyright: (c)
--
-- Usage: @kill <filter expression> (example: @kill username='SYSTEM')
-- @kill sid=150
-- @kill username='SYSTEM'
-- @kill "username='APP' and program like 'sqlplus%'"
--
-- Other: This script doesnt actually kill any sessions
-- it just generates the ALTER SYSTEM KILL SESSION
-- commands, the user can select and paste in the selected
-- commands manually
--
--------------------------------------------------------------------------------
select 'alter system kill session '''||sid||','||serial#||',@'||inst_id||''' immediate -- '
||username||'@'||machine||' ('||program||');' commands_to_verify_and_run
from gv$session
where &1
and sid != (select sid from v$mystat where rownum = 1)
/
--//在測試環境測試看看:
1.環境:
SYS@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SYS@book> @ i
USERNAME INST_NAME HOST_NAME I# SID SERIAL# VERSION STARTED SPID OPID CPID SADDR PADDR
-------------------- -------------------- ------------------------- --- ----- -------- ---------- -------- ---------- ----- --------------- ---------------- ----------------
SYS book xxxxxdg4 1 44 49 11.2.0.4.0 20211129 57178 27 57177 000000008638EC10 000000008620F338
2.開啟新的會話:
SCOTT@book> @ killix "sid=44"
COMMANDS_TO_VERIFY_AND_RUN
----------------------------------------------------------------------------------------------
alter system kill session '44,49,@1' immediate -- SYS@xxxxxdg4 (sqlplus@xxxxxdg4 (TNS V1-V3));
SCOTT@book> alter system kill session '44,49,@1' immediate -- SYS@xxxxxdg4 (sqlplus@xxxxxdg4 (TNS V1-V3));
System altered.
--//切換回去,執行:
SYS@book> @ ver1
select dbms_utility.port_string port_string, version,v$version.* from v$instance,v$version where rownum<=1
*
ERROR at line 1:
ORA-03135: connection lost contact
Process ID: 57178
Session ID: 44 Serial number: 49
--//連線已經斷開。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2844582/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20211129]完善tpt tablist.sql指令碼.txtSQL指令碼
- [20220217]完善tpt gts.sql指令碼.txtSQL指令碼
- [20220510]完善tpt expandz.sql指令碼.txtSQL指令碼
- [20211130]完善tpt t.sql指令碼.txtSQL指令碼
- [20211126]完善tpt pr.sql指令碼.txtSQL指令碼
- [20231025]完善tpt的trans.sql指令碼.txtSQL指令碼
- [20220111]完善tpt ashash_index_helper指令碼.txtIndex指令碼
- [20220323]完善tpt get_trace.sql指令碼.txtSQL指令碼
- [20220823]完善tpt的ashtop.sql指令碼.txtSQL指令碼
- [20220129]完善tpt ash ash_index_helperx指令碼.txtIndex指令碼
- [20230302]建立完善tpt o2.sql指令碼.txtSQL指令碼
- [20220519]完善tpt dash_wait_chains2.sql指令碼.txtAISQL指令碼
- [20220317]補充完善TPT 顯示欄位列的指令碼.txt指令碼
- [20220422]完善tpt ash ash_index_helperx指令碼2.txtIndex指令碼
- [20211129]更新dpcawr1.sql指令碼.txtPCASQL指令碼
- [20210506]完善tix指令碼.txt指令碼
- [20201202]完善sosi指令碼.txt指令碼
- [20211223]tpt ash ash_index_helperx指令碼.txtIndex指令碼
- [20210623]完善清除aud指令碼.txt指令碼
- [20240313]使用tpt ashtop.sql指令碼的困惑.txtSQL指令碼
- [20231117]完善ashtt.sql指令碼.txtSQL指令碼
- [20211230]完善sql_id指令碼.txtSQL指令碼
- [20211122]完善descx.sql指令碼.txtSQL指令碼
- [20221012]完善spsw.sql指令碼.txtSQL指令碼
- [20221010]完善descz.sql指令碼.txtSQL指令碼
- [20221101]完善descz.sql指令碼.txtSQL指令碼
- [20221101]完善gts.sql指令碼.txtSQL指令碼
- [20230203]完善awr.sql指令碼.txtSQL指令碼
- [20230123]完善curheapz.sql指令碼.txtSQL指令碼
- [20210407]完善ti.sql指令碼.txtSQL指令碼
- [20210125]完善hide.sql指令碼.txtIDESQL指令碼
- [20231101]使用tpt seg2.sql指令碼問題.txtSQL指令碼
- [20221126]tpt pr.sql指令碼執行問題.txtSQL指令碼
- [20191111]完善bind_cap.sql指令碼.txtSQL指令碼
- [20211202]完善d_buffer.sql指令碼.txtSQL指令碼
- [20230414]完善seg2.sql指令碼.txtSQL指令碼
- [20230210]建立完善swcnm.sql指令碼.txtSQL指令碼
- [20221208]完善bind_cap.sql指令碼.txtSQL指令碼