博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
limit active sessions
阅读量:2495 次
发布时间:2019-05-11

本文共 3961 字,大约阅读时间需要 13 分钟。

Normal07.8 磅02falsefalsefalseMicrosoftInternetExplorer4

我们每个库的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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/668365/viewspace-1029729/

你可能感兴趣的文章
文件拷贝(IFileOperation::CopyItem)
查看>>
MapReduce的 Speculative Execution机制
查看>>
大数据学习之路------借助HDP SANDBOX开始学习
查看>>
Hadoop基础学习:基于Hortonworks HDP
查看>>
为什么linux安装程序 都要放到/usr/local目录下
查看>>
Hive安装前扫盲之Derby和Metastore
查看>>
永久修改PATH环境变量的几种办法
查看>>
大数据学习之HDP SANDBOX开始学习
查看>>
Hive Beeline使用
查看>>
Centos6安装图形界面(hdp不需要,hdp直接从github上下载数据即可)
查看>>
CentOS7 中把yum源更换成163源
查看>>
关于yum Error: Cannot retrieve repository metadata (repomd.xml) for repository:xxxxxx.
查看>>
linux下载github中的文件
查看>>
HDP Sandbox里面git clone不了数据(HTTP request failed)【目前还没解决,所以hive的练习先暂时搁置了】
查看>>
动态分区最佳实践(一定要注意实践场景)
查看>>
HIVE—索引、分区和分桶的区别
查看>>
Hive进阶总结(听课总结)
查看>>
大数据领域两大最主流集群管理工具Ambari和Cloudera Manger
查看>>
Sqoop往Hive导入数据实战
查看>>
Mysql到HBase的迁移
查看>>