Home > Backend Development > PHP Tutorial > How to quickly kill database processes that take up too many resources (CPU, memory)_PHP Tutorial

How to quickly kill database processes that take up too many resources (CPU, memory)_PHP Tutorial

WBOY
Release: 2016-07-13 17:02:02
Original
750 people have browsed it

Many times due to exceptions or program errors, individual processes occupy a large amount of system resources, and these processes need to be terminated. You can usually use the following command to kill the process:
alter system kill session 'sid,serial#';

But This command releases resources very slowly. For details, please refer to: Research on Kill session in Oracle.
In order to release resources more quickly, we usually use the following steps to kill the process:
1. First kill the process at the operating system level
2. Kill session inside the database
This can usually quickly terminate the process and release resources.
I encountered such a case today. Other friends killed the session in the database, but it still had no effect for a long time:
[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.

Then follow the steps I mentioned earlier, first query the OS process number corresponding to the session:
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> !

Kill the process at the operating system level:
[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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631083.htmlTechArticleMany times due to exceptions or program errors, individual processes occupy a large amount of system resources. These processes need to be terminated. You can usually use The following command kills the process: alter system kill session...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template