limit active sessions
我們每個庫的active sessions都是基本固定的,如果突然上升,一般都是有問題。結果是LOAD上升,某些引數達到臨界值,如share_pool,開啟檔案數等等。最終DB掛掉。
也許是DB有其他問題導致active sessions上升,這個上升只是一個結果,但如果能夠限制了active數量,可以防止結果惡化。
Active Session Pool
As new transactions start in a specific consumer group they take a share of the available resources. If too many transactions are active at once performance can suffer.The new Active Session Pool feature allows a maximum number of active sessions to be set for each resource consumer group. Once this figure is reached, all subsequent requests are queued until an active session completes or becomes inactive.
The active session pool currently works on the First-In-First-Out (FIFO) basis, with a timeout period. If the request times out an error is issued that can be trapped by an application. Parallel operations are counted as single sessions by resource manager.
If there are multiple resource plan directives that refer to the same consumer group, the active session pool is the sum of all the incoming values. In this case the queue timeout is the minimum of all incoming timeout values.
The active session pool is defined using the following parameters of the CREATE_PLAN_DIRECTIVE and UPDATE_PLAN_DIRECTIVE procedures in the DBMS_RESOURCE_MANAGER package:
[NEW_]ACTIVE_SESSION_POOL_P1 - Defines the active session pool limit.* [NEW_]QUEUING_P1 - Defines the timeout period in seconds.[@more@]
- 測試步驟(這是在10g上的測試):
1、建個PLAN
BEGIN
DBMS_RESOURCE_MANAGER.CREATE_SIMPLE_PLAN(SIMPLE_PLAN => 'simple_plan1',
CONSUMER_GROUP1 => 'mygroup1');
END;
2、給使用者授權
BEGIN
DBMS_RESOURCE_MANAGER_PRIVS.GRANT_SWITCH_CONSUMER_GROUP (
GRANTEE_NAME => 'test',
CONSUMER_GROUP => 'mygroup1',
GRANT_OPTION => TRUE);
END;
3、設定使用者session
exec dbms_resource_manager.create_pending_area;
BEGIN
DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING
(DBMS_RESOURCE_MANAGER.ORACLE_USER, 'test', 'mygroup1');
END;
/
EXEC DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA;
exec dbms_resource_manager.set_initial_consumer_group(user => 'test', consumer_group=>'mygroup1');
4、修改active_sess_pool_p1
exec dbms_resource_manager.create_pending_area;
EXEC DBMS_RESOURCE_MANAGER.UPDATE_PLAN_DIRECTIVE (PLAN => 'simple_plan1', -
GROUP_OR_SUBPLAN => 'mygroup1', NEW_active_sess_pool_p1 => 5);
EXEC DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA;
5、使生效
ALTER SYSTEM SET RESOURCE_MANAGER_PLAN = 'simple_plan1';
6、測試完成後
ALTER SYSTEM SET RESOURCE_MANAGER_PLAN = ;
管理---------
檢視active_sess_pool_p1設定值
SQL> select plan,active_sess_pool_p1 from DBA_RSRC_PLAN_DIRECTIVES;
PLAN ACTIVE_SESS_POOL_P1
------------------------------ -------------------
SYSTEM_PLAN
SYSTEM_PLAN
SYSTEM_PLAN
INTERNAL_QUIESCE
INTERNAL_QUIESCE 0
INTERNAL_PLAN
SIMPLE_PLAN1
SIMPLE_PLAN1
SIMPLE_PLAN1 5
9 rows selected.
檢視達到限制的次數及被kill的次數。
SQL> select name,ACTIVE_SESSIONS,ACTIVE_SESSION_LIMIT_HIT,QUEUE_LENGTH,ACTIVE_SESSIONS_KILLED from V$RSRC_CONSUMER_GROUP;
NAME ACTIVE_SESSIONS ACTIVE_SESSION_LIMIT_HIT QUEUE_LENGTH ACTIVE_SESSIONS_KILLED
-------------------------------- --------------- ------------------------ ------------ ----------------------
SYS_GROUP 1 0 0 0
OTHER_GROUPS 0 0 0 0
MYGROUP1 2 19 0 0
這裡19次達到了5個以上active session,我們可以監控QUEUE_LENGTH,當session在佇列裡時,說明達到limit並排隊了,判斷如果是正常session,此時可以很方便地取消限制
ALTER SYSTEM SET RESOURCE_MANAGER_PLAN =;然後再修改limit值。
SQL> select sequence# seq, name, cpu_wait_time, cpu_waits,consumed_cpu_time from V$RSRC_CONS_GROUP_HISTORY;
SELECT sequence# seq, name plan_name,
to_char(start_time, 'DD-MON-YY HH24:MM') start_time,
to_char(end_time, 'DD-MON-YY HH24:MM') end_time, window_name
FROM v$rsrc_plan_history;
SELECT se.sid sess_id, co.name consumer_group,
se.state, se.consumed_cpu_time cpu_time, se.cpu_wait_time, se.queued_time
FROM v$rsrc_session_info se, v$rsrc_consumer_group co
WHERE se.current_consumer_group_id = co.id;
詳細瞭解
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/668365/viewspace-1029729/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- monitor PX limits from Resource Manager for active sessions (文件 ID 240877.1)MITSession
- Kill SessionsSession
- SESSIONS, PROCESSES, TRANSACTIONSSession
- Sessions & Processes parameterSession
- MySQL LIMIT 如何改寫成Oracle limitMySqlMITOracle
- 會話控制利器 gorilla/sessions會話GoSession
- Inhomogeneous deployment for replicated sessions is not allowed.Session
- How to get complete sessions informationSessionORM
- sessions,processes的監控方法Session
- Kill all sessions of a specified user nameSession
- Connections and Sessions (110)Session
- limit優化MIT優化
- RESOURCE_LIMITMIT
- 極限limitMIT
- active sqlSQL
- How To Automate Disconnection of Idle SessionsSession
- oracle profile sessions_per_user的用法OracleSession
- sessions 與 processes 的計算關係Session
- [Active Learning] Multi-Criteria-based Active Learning
- set_time_limitMIT
- Mysql LIMIT的用法MySqlMIT
- linux limit限制LinuxMIT
- v$resource_limitMIT
- day limit in terms of paymentMIT
- spring.profiles.active=@profiles.active@的含義Spring
- ORA-00018:maximum number of sessions exceedeSession
- ORA-00018: maximum number of sessions exceededSession
- DIFFERENCES BETWEEN PROCESSES, SESSIONS AND CONNECTIONS(asktom)Session
- ORA-00018 maximum number of sessions exceededSession
- DMSQL LIMIT限定條件SQLMIT
- MySQL中limit的用法MySqlMIT
- oracle實現"limit"功能OracleMIT
- AIX中的limit值AIMIT
- Oracle Active database duplicationOracleDatabase
- Active Session History (ASH)Session
- Duplicating an Active DatabaseDatabase
- Removing Sessions in Killed Status on Unix (文件 ID 274216.1)REMSession
- 自動清理Dead Connections And INACTIVE SessionsSession