Kill Oracle sessions quickly

Source: Internet
Author: User

I. Question proposal
In many cases, we quickly kill some sessions of oralcle for the following reasons:

1. In some cases, due to the large data volume and large transaction volume, shutdown immediate takes a lot of time, but we want to use the shutdown immediate method, and we need to quickly shut down the database.

2. Our applications may use session control, which controls the number of connections of some users at the application level. But sometimes the network may be transient disconnected, resulting in some dead processes, whose status is inactive. When we use alter system kill session 'sid, serial # 'to clear the session, the status of these sessions becomes killed, and these sessions are cleared slowly by the pmon process, and you are just an impatient temper.

3. The system suddenly slows down. You find that a session is strange and you want to quickly end it.

Ii. Handling Methods
In fact, the solution is very simple. It is called "murder" by some people. Because a session corresponds to a process in the operating system, we do not use alter system kill session instead, when the background process of the session is killed, it will prompt the lazy pmon process to quickly clean up.

1. Use a session as an example,

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 yourOracleIt is on UNIX platform and can be killed.

$ Killed 13824

If yourOracleIt is on the mongown platform. There are some differences, because mongown uses thead to replace process. The SID and spid values need to be used, and the commands used are also replaced by kill with orakill, format: orakill Sid spid

C:/> orakill 941 13824

D. Check v $ session again to see if the session is absent.

2. How can we kill all Oracle user processes?

A. In a Windows environment, execute the SQL statement as shown in, and save the result as a. BAT file, such as kill. bat. Execute kill. bat.

 

 

B. the Unix environment is much simpler. Execute the following command.

$ PS-Ef | grep $ oracle_sid | grep-V ora _ | grep local = No | awk '{print $2}' | xargs kill

Then you can shut down immediate quickly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.