ORACLE dbms_schedule JOB 分配机制
[toc]
问题概述
RAC 2 节点, scheduler job 的分配机制是什么样子的?Oracle19c RAC 两个节点,每个节点内存512G,节点1 的一个内存坏掉,剩余256G 内存,发现20个job 都在节点2上运行了。
问题原因
有两个参数可以控制 scheduler job 的 runing 机制: INSTANCE_ID
和INSTANCE_STICKINESS
,对应的默认值分别为空和TRUE
,也就是如果不设置的话,scheduler JOB 遵循负载均衡的算法将 job 分配到负载轻的实例上。
可以通过如下命令设置JOB在哪个节点运行:
1 | exec dbms_scheduler.set_attribute(name => 'OWNER.JOB_1' ,attribute=>'INSTANCE_ID', value=>'1'); |
1 | select OWNER,JOB_NAME,INSTANCE_STICKINESS,INSTANCE_ID from dba_scheduler_jobs where JOB_NAME like '%JOB%'; |
关于 >INSTANCE_ID 和 INSTANCE_STICKINESS 的解释如下:
INSTANCE_ID:
Valid only in an Oracle Real Application Clusters environment. Indicates the instance on which the job is to be run.
INSTANCE_STICKINESS:
This attribute should only be used for a database running in an Oracle Real Application Clusters (RAC) environment. By default, it is set to TRUE. If you set instance_stickiness to TRUE, jobs start running on the instance with the lightest load and the Scheduler thereafter attempts to run on the instance that it last ran on. If that instance is either down or so overloaded that it will not start new jobs for a significant period of time, another instance will run the job. If the interval between runs is large, instance_stickiness will be ignored an the job will be handled as if it were a non-sticky job.
If instance_stickiness is set to FALSE, each instance of the job runs on the first instance available.
For non-RAC environments, this attribute is not useful because there is only one instance.
知识总结
有两个参数可以控制 job 的 runing 机制: INSTANCE_ID
和INSTANCE_STICKINESS
,对应的默认值分别为空和TRUE
,也就是如果不设置遵循负载均衡的算法分配到负载轻的实例上。
参考文档
无
原文作者: liups.com
原文链接: http://liups.com/posts/115c0bfc/
许可协议: 知识共享署名-非商业性使用 4.0 国际许可协议