job 适用 oracle,oracle job 未自动执行

ANSWERS TO "WHY ARE MY JOBS NOT RUNNING ?"

This is one of the most common Scheduler questions asked.

Here we list some of the common problems and their solutions. >>下面列出了常见的可能导致oracle job不自动执行的原因,及解决方法:

1)job_queue_processes may be too low (this is the most common problem) >>适用于DBMS_SCHEDULER.CREATE_JOB和dbms_job

The value of job_queue_processes limits the total number of dbms_scheduler

and dbms_job jobs that can be running at a given time.

To check whether this is the case check the current value of

job_queue_processes with

sql> select value from v$parameter where name='job_queue_processes';

Then check the number of running jobs

sql> select count(*) from dba_scheduler_running_jobs;

sql> select count(*) from dba_jobs_running;

If this is the problem you can increase the parameter using

sql> alter system set job_queue_processes=1000;

2)max_job_slave_processes may be too low >>适用于DBMS_SCHEDULER.CREATE_JOB和dbms_job

If this parameter is not NULL then it limits how many dbms_scheduler jobs can

be running at a time. To check whether this is the problem,check the current

value using

sql> select value from dba_scheduler_global_attribute

where attribute_name='MAX_JOB_SLAVE_PROCESSES';

Then check the number of running jobs

sql> select count(*) from dba_scheduler_running_jobs;

If this is the problem you can increase the number or just NULL it out using

sql> exec dbms_scheduler.set_scheduler_attribute('max_job_slave_processes',null)

3)sessions may be too low >>适用于DBMS_SCHEDULER.CREATE_JOB和dbms_job

This parameter limits the number of sessions at any time. Every Scheduler job

requires 2 sessions. To check whether this is the problem,check the current

valule using

sql> select value from v$parameter where name='sessions';

Then check the current number of sessions using

sql> select count(*) from v$session ;

If the numbers are too close you can increase the maximum using

sql> alter system set job_queue_processes=200;

4)Have you recently applied a timezone update patch or upgraded the database >>使用于DBMS_SCHEDULER.CREATE_JOB和dbms_job

to a version with newer timezone information ? If you skipped any steps when

updating the timezone information,jobs may not run. To check whether this

is the case try doing

sql> select * from sys.scheduler$_job;

and

sql> select * from sys.scheduler$_window;

and make sure they finish without errors.

If it throws a timezone warning,reapply the upgrade or

timezone patch making sure to follow all the steps.

5)Is the database running in restricted mode ? >>适用于DBMS_SCHEDULER.CREATE_JOB和dbms_job

If the database is running in restricted mode then no jobs will run (unless

you are using 11g and use the ALLOW_RUNS_IN_RESTRICTED_MODE attribute).

To check this use

sql> select logins from v$instance ;

If logins is restricted you can disable the restricted mode using

sql> ALTER SYSTEM DISABLE RESTRICTED SESSION;

6)Is the job scheduled to run on an instance which is down ? >>适用于DBMS_SCHEDULER.CREATE_JOB和dbms_job

You can check this by seeing whether instance_id is set for the job (check the dba_scheduler_jobs view),and if so you should check whether that instance is up.

7)Is the job scheduled to run on a service which has not been started on any instances ? >>适用于DBMS_SCHEDULER.CREATE_JOB和dbms_job

You can check this by checking what job_class a job points to and then checking whether that class points to a service. If it does,make sure the service has been started on at least one running instance. You can start a service on an instance using dbms_service.start_service.

8)Is the Resource Manager in effect with a restrictive resource plan ? >>适用于DBMS_SCHEDULER.CREATE_JOB和dbms_job

If a restrictive resource plan is in effect,scheduler jobs may not have sufficient resources allocated so they may not run. You can check what resource plan is in effect by doing

sql> select name from V$RSRC_PLAN ;

If no plan is in effect or the plan in effect is INTERNAL_PLAN then the resource manager is not in effect. If the resource manager is in effect you can disable it by doing

sql>alter system set resource_manager_plan = '';

9)Has the Scheduler been disabled ? This

is not a supported action 适用于DBMS_SCHEDULER.CREATE_JOB和dbms_job

but it is possible that someone has done it anyway. To check this do

sql> select value from dba_scheduler_global_attribute where attribute_name='SCHEDULER_DISABLED'

If this query returns TRUE then you can fix this using

sql> exec dbms_scheduler.set_scheduler_attribute('scheduler_disabled','false');

Reasons why jobs may run late

1)The first thing to check is the timezone that the job is scheduled with

sql> select owner,job_name,next_run_date from dba_scheduler_jobs ;

If the jobs are in the wrong timezone they may not run at the expected

time. If the next_run_date is using an absolute timezone offset (like

+08:00) instead of a named timezone (like US/PACIFIC) then the jobs may not

run as expected if daylight savings is in effect - they may run an hour

early or late.

2)It may be that at the time the job was scheduled to run,one of the several

limits above may have been temporarily reached causing the job to be delayed.

Check if the limits above are high enough and if possible check them during

the time that the job is being delayed.

3)One possible reason that one of the above limits may be hit is that a

maintenance window may have come into effect. Maintenance windows are Oracle

Scheduler windows that belong to the window group named

MAINTENANCE_WINDOW_GROUP. During a scheduled maintenance window,several

maintenance tasks are run using jobs. This may cause one of the limits listed

above to be hit and user jobs to be delayed. See the admin guide for more info

about this (chapter 24).

To get a list of maintenance windows use

sql> select * from dba_scheduler_wingroup_members;

To see when the windows run use

sql> select * from dba_scheduler_windows;

To fix this you can either increase the limits or reschedule the maintenance

windows to run at more convenient times.

Diagnosing other Problems

If none of this works,here are some further steps you can take to try to

figure out what is going on.

1)Check whether there are any errors in the alert log. If the database is

having trouble allocating memory or has run out of disk space or any other

catastrophic errors have occurred,you should resolve those first. You can

find the location of the alert log by using

sql> select value from v$parameter where name = 'background_dump_dest';

The alert log will be in this directory with a name starting with "alert".

2)Check whether if a job coordinator trace file and if it does,check if it

contains any errors. If this exists,it will be located in the

'background_dump_dest' directory which you can find as above and will look

something like SID-cjq0_nnnn.trc . If there are any errors here they may

hint at why jobs are not running.

3)If either of the above indicates that the SYSAUX tablespace (where the scheduler stores its logging tables) is full,you can use the dbms_scheduler.purge_log procedure to clear out old log entries.

4)See if there is a window currently open. If there is,you can try closing it to see if that helps .

sql> select * from DBA_SCHEDULER_GLOBAL_ATTRIBUTE where

attribute_name='CURRENT_OPEN_WINDOW';

sql> exec DBMS_SCHEDULER.close_window ('WEEKNIGHT_WINDOW');

5)try running a simple run-once job and see if it runs

sql>begin

dbms_scheduler.create_job (

job_name => 'test_job',

job_type => 'plsql_block',

job_action => 'null;',

enabled => true);

end;

/

sql> -- wait a while

sql> select * from user_scheduler_job_run_details where job_name='TEST_JOB';

6)If a simple run-once job doesn't run,you can try restarting the scheduler as follows. >>终极大招,如果上面的检查都正常后,尝试下面方法

sql> exec dbms_scheduler.set_scheduler_attribute('SCHEDULER_DISABLED','TRUE');

sql> alter system set job_queue_processes=0;

sql> exec dbms_ijob.set_enabled(FALSE);

sql>

sql> alter system flush shared_pool;

sql> alter system flush shared_pool;

sql>

sql> exec dbms_ijob.set_enabled(TRUE);

sql> alter system set job_queue_processes=99;

sql> exec dbms_scheduler.set_scheduler_attribute('SCHEDULER_DISABLED','FALSE');

参考:

https://community.oracle.com/thread/648581

IF: Jobs Do Not Run Automatically (Doc ID 2084527.1)

Jobs Not Executing Automatically (Doc ID 313102.1)

总结

以上是编程之家为你收集整理的oracle job 未自动执行全部内容,希望文章能够帮你解决oracle job 未自动执行所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值