How to quickly kill Oracle session

zhaozj2021-02-16  53

First, the question is proposed

When we quickly killed some sessions of Oralcle, the reason is generally as follows:

1, some time, because our data volume is very large, the corresponding transaction is large and more, will take a lot of time when doing Shutdown Immediate, but we want to use Shutdown Immediate's way, and to quickly shutddown Down.

2, our application may use session control, that is, the number of connections to some users is controlled at the application level. However, sometimes the transients that may occur in the network, thereby producing some dead processes, their status is inactive. When we cleared with Alter System Kill Session 'SID, Serial #', these session becomes Killed, which is slowly cleared by the PMON process, and you are just an urgent temper.

3, the system suddenly slowed down, you found a session in strange, I want to quickly end it quickly.

Second, the treatment method

In fact, it is very simple, it is called "murder" by some people. Because a session will correspond to a process in the operating system, we don't use the ALTER SYSTEM KILL Session. Instead, it is a Kill method. When the session's background process is killed, it will cause lazy The PMON process quickly cleans up.

1, do an example with a session,

a, find the session you want to kill, and write down PADDR

b, find the SPID corresponding to this session

c, kill the process identified by the SPID

♀ If your Oracle is on the UNIX platform, you can use Kill.

$ Kill 13824

♀ If your Oracle is on the Windown platform, there are some differences, because Windown is replaced by THEAD, you need to use the SID and SPID two values, the commands used are replaced by Kill to Orakill, the format is: Orakill SID SPID

C: /> Orakill 941 13824

D, check again v $ session, watch the session is not there.

2. How to mur out all the processes of all Oracle users?

A, Windows environment, execute SQL in the following figure, and store the result .bat file, such as kill.bat, execute kill.bat.

B, UNIX environment is relatively simple, and it is possible to execute the following command.

$ PS-EF | GREP $ ORACLE_SID | GREP -V ORA_ | GREP LOCAL = No | awk '{print $ 2}' | xargs kill

Then you have shortdown immediate very quickly.

转载请注明原文地址:https://www.9cbs.com/read-26810.html

New Post(0)