Workaround for ORA-02391 problem

The analysis and solution of ORA problems is actually a good way of learning. Catching every single ORA error, and then further analyzing some reasons, summarizing, there will always be different harvests. Again, there is a problem behind any problem. reason.

This morning, the development colleagues reported that an ORA error was thrown in the client.

ORA-02391: exceeded simultaneous SESSIONS_PER_USER limit

Hope we can help to see what is the reason and how to fix it.

This problem is actually relatively clear, that is, the corresponding session number limit will be defined in the profile we set. For example, if there is a user test and sessions_per_user is 50, then the test user can use up to 50 sessions.

The default profile is DEFAULT, after creating the database Basic initialization will be done, such as password expiration time, etc.

SQL> select *from DBA_PROFILES WHERE PROFILE='DEFAULT'
PROFILE RESOURCE_NAME RESOURCE LIMIT
--------------------- --------- -------------------------------- -------- - ---------------------------------------
DEFAULT COMPOSITE_LIMIT KERNEL UNLIMITED
DEFAULT                        SESSIONS_PER_USER                KERNEL  UNLIMITED
DEFAULT                        CPU_PER_SESSION                  KERNEL  UNLIMITED
DEFAULT                        CPU_PER_CALL                    KERNEL  UNLIMITED
DEFAULT                        LOGICAL_READS_PER_SESSION        KERNEL  UNLIMITED
DEFAULT                        LOGICAL_READS_PER_CALL          KERNEL  UNLIMITED
DEFAULT                        IDLE_TIME                        KERNEL  UNLIMITED
DEFAULT                        CONNECT_TIME                    KERNEL  UNLIMITED
DEFAULT                        PRIVATE_SGA                      KERNEL  UNLIMITED
The DEFAULT FAILED_LOGIN_ATTEMPTS PASSWORD UNLIMITED the
DEFAULT PASSWORD_LIFE_TIME PASSWORD UNLIMITED the
DEFAULT PASSWORD_REUSE_TIME PASSWORD UNLIMITED the
DEFAULT PASSWORD_REUSE_MAX PASSWORD UNLIMITED the
DEFAULT PASSWORD_VERIFY_FUNCTION PASSWORD NULL the
DEFAULT PASSWORD_LOCK_TIME PASSWORD UNLIMITED the
DEFAULT PASSWORD_GRACE_TIME PASSWORD UNLIMITED
default profile DEFAULT in sessions_per_user is Unlimited, but in practice we have to limit the use of resources, or will it self Defining a profile is actually based on profile DEFAULT
sql> select username,profile from dba_users where username=' USER_TEST';
USERNAME PROFILE
------------------------------ --- ---------------------------
USER_TEST APP_TEST At
this time, you can see that the corresponding maximum number of sessions is 20.
SQL> select * from dba_profiles where profile='APP_TEST';
PROFILE RESOURCE_NAME RESOURCE LIMIT
------------------ --------------- ----------------- -------- ------------------------- ---------------
APP_TEST COMPOSITE_LIMIT KERNEL DEFAULT
APP_TEST SESSIONS_PER_USER KERNEL 20
APP_TEST CPU_PER_SESSION KERNEL DEFAULT
APP_TEST    CPU_PER_CALL                    KERNEL  DEFAULT
APP_TEST    LOGICAL_READS_PER_SESSION        KERNEL  DEFAULT
APP_TEST    LOGICAL_READS_PER_CALL          KERNEL  DEFAULT
APP_TEST    IDLE_TIME                        KERNEL  DEFAULT
APP_TEST    CONNECT_TIME                    KERNEL  DEFAULT
APP_TEST    PRIVATE_SGA                      KERNEL  DEFAULT
APP_TEST    FAILED_LOGIN_ATTEMPTS            PASSWORD DEFAULT
APP_TEST    PASSWORD_LIFE_TIME              PASSWORD DEFAULT
APP_TEST    PASSWORD_REUSE_TIME              PASSWORD DEFAULT
APP_TEST    PASSWORD_REUSE_MAX              PASSWORD DEFAULT
APP_TEST    PASSWORD_VERIFY_FUNCTION        PASSWORD DEFAULT
APP_TEST PASSWORD_LOCK_TIME PASSWORD DEFAULT
APP_TEST PASSWORD_GRACE_TIME PASSWORD DEFAULT
basic knowledge is introduced.

If ora-02391 is thrown, we can solve it by alter user xxxxx profile xxxx sessions_per_user xxxx.
The problem is that this kind of error does not show up in the database log, so the DBA has no way of knowing, and can only wait for feedback, and then solve the problem after getting feedback.
We can change from passive to active.
Use the following monitor statement to check.
For example, we set the threshold to 90%, that is, the corresponding session of each user exceeds 90% of the value set in the profile, and the result will be returned.
select u.username||' with related profile '||p.profile||' has potential issue on '||p.resource_name ||' current value is '||s.cnt||' of '||p. limit ,
p.limit , s.cnt , p.profile
from dba_profiles p,
(select username,count(*) cnt from v$session where username is not null group by username) s,
dba_users u
where  p.RESOURCE_NAME = 'SESSIONS_PER_USER'
and p.profile=u.profile
and s.username=u.username
--and p.profile !='DEFAULT'
and s.cnt*100/decode(p.limit,'DEFAULT',999,p.limit)>=90;
返回结果类似下面的形式。
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 MPC with related profile DEFAULT has potential issue on SESSIONS_PER_USER current value is 5 of 100 100 5 DEFAULT
2 APCUSE with related profile DEFAULT has potential issue on SESSIONS_PER_USER current value is 5 of 100 100 5 DEFAULT
3 CLIFF with related profile DEFAULT has potential issue on SESSIONS_PER_USER current value is 16 of 100 100 16 DEFAULT
4 RPTMGR with related profile DEFAULT has potential issue on SESSIONS_PER_USER current value is 12 of 100 100 12 DEFAULT
5 M2P with related profile DEFAULT has potential issue on SESSIONS_PER_USER current value is 1 of 100 100 1 DEFAULT
6 GRACE with related profile SESSION_LIMIT3 has potential issue on SESSIONS_PER_USER current value is 30 of 120 120 30 SESSION_LIMIT3
7 RPTDB with related profile SESSION_LIMIT3 has potential issue on SESSIONS_PER_USER current value is 57 of 120 120 57 SESSION_LIMIT3

本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2015-08/122360.htm

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326739261&siteId=291194637