Resolves an issue in which Oracle 11GR2 idle connections that cause a full number of connections

Source: Internet
Author: User

Today, I have encountered the problem of 11GR2 connection, before, because the application there is no in-depth inspection, did not find specific reasons, think of this version of the Oracle bug it.

The last approach is to use the shell script to kill v$session.status= ' INACTIVE ' connection in the system, but this site does not deploy scripts in the operating system permissions, had to do in the database processing, fortunately we have full access to the database. This time using the Profile+job timed alter system kill ' sid,seral# ' immediate way. The specific script is as follows:

    1. CREATE profile Killidle LIMIT idle_time 30;

    2. SELECT * from Dba_profiles WHERE profile= ' Killidle ';

    3. ALTER USER Test_user profile Killidle;

    4. SELECT username,profile from Dba_users WHERE username= ' Test_user ';

    5. ALTER SYSTEM SET resource_limit=true;






    6. CREATE OR REPLACE PROCEDURE sp_kill_idlesession

    7. /**********************************

    8. Clears the idle timeout session process

    9. **********************************/

    10. As

    11. CURSOR C_kill_sqls

    12. Is SELECT ' alter system kill session ' | | s.sid| | ', ' | | s.serial#| | ' immediate ' SQLSTR from v$session s WHERE s.status= ' sniped ';

    13. BEGIN

    14. For V_sql in C_kill_sqls

    15. LOOP

    16. EXECUTE IMMEDIATE V_sql.sqlstr;

    17. END LOOP;

    18. END;





    19. --add job to periodically clean out expired sessions

    20. DECLARE jobnum Number: = 661;

    21. BEGIN

    22. Dbms_job.submit (Job = Jobnum,

    23. what = ' sp_kill_idlesession; ',

    24. Next_date = To_date (' 30-04-2014 18:00:00 ', ' dd-mm-yyyy hh24:mi:ss '),

    25. Interval = ' sysdate + 1/144 ');

    26. Commit

    27. END;







    28. --If the 30-minute expiration time is too short to have an impact on database access performance, you can adjust

    29. ALTER profile Killidle LIMIT idle_time 30;

Resolves an issue in which Oracle 11GR2 idle connections that cause a full number of connections

Related Article

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.