打杂
全部博文(524)
分类: Oracle
2015-02-13 15:49:22
原文地址:如何快速杀死占用过多资源(CPU,内存)的数据库进程 作者:liyf0371
alter system kill session 'sid,serial#'; |
[oracle@danaly ~]$ sqlplus "/ as sysdba" SQL*Plus: Release 10.2.0.1.0 - Production on Thu Oct 27 11:09:50 2005 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options SQL> select sid,username,status from v$session; SID USERNAME STATUS ---------- ------------------------------ -------- .... 154 SCOTT KILLED ... 30 rows selected. |
SQL> select 'kill -9 '||spid from v$process where addr = (select paddr from v$session where sid=&sid); Enter value for sid: 154 old 1: select 'kill -9 '||spid from v$process where addr = (select paddr from v$session where sid=&sid) new 1: select 'kill -9 '||spid from v$process where addr = (select paddr from v$session where sid=154) 'KILL-9'||SPID -------------------- kill -9 22702 SQL> ! |
[oracle@danaly ~]$ ps -ef|grep 22702 oracle 22702 1 0 Oct25 ? 00:00:02 oracledanaly (LOCAL=NO) oracle 12082 12063 0 11:12 pts/1 00:00:00 grep 22702 [oracle@danaly ~]$ kill -9 22702 [oracle@danaly ~]$ ps -ef|grep 22702 oracle 12088 12063 0 11:12 pts/1 00:00:00 grep 22702 [oracle@danaly ~]$ exit exit SQL> select sid,username,status from v$session; SID USERNAME STATUS ---------- ------------------------------ -------- ... 154 SCOTT KILLED ... 30 rows selected. SQL> select sid,serial#,username from v$session where sid=154; SID SERIAL# USERNAME ---------- ---------- ------------------------------ 154 56090 SCOTT |
SQL> alter system kill session '154,56090' immediate; System altered. SQL> select sid,serial#,username from v$session where sid=154; no rows selected |