简体   繁体   English

Oracle DBMS 作业未运行

[英]Oracle DBMS Job not running

I defined a job to run from Tuesday to Sundays every 5 min.我定义了一个从周二到周日每 5 分钟运行一次的工作。 from 9:00 am to 22:00 pm上午 9:00 至下午 22:00

BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'GET_INVOICES_JOB',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN LOPES.GET_INVOICES; END;',
repeat_interval =>'FREQ=MINUTELY; INTERVAL=5; BYHOUR=9,22; BYDAY=TUE,WED,THU,FRI,SAT,SUN', 
enabled => TRUE,
comments => 'GET_INVOICES');
END;
/

But the job does not run cheking但这项工作并没有运行检查

SELECT *
FROM USER_SCHEDULER_JOB_RUN_DETAILS 
ORDER BY LOG_DATE DESC

Checking the Job it seems to be OK:检查工作似乎没问题:

在此处输入图片说明

and running the job manually it execute the procedure but only once not every 5 minutes并手动运行作业它会执行该过程,但不是每 5 分钟只执行一次

This is one of the most common Scheduler questions asked.这是调度程序最常见的问题之一。 Here we list some of the common problems and their solutions.在这里,我们列出了一些常见问题及其解决方案。

1) job_queue_processes may be too low (this is the most common problem) 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. 1)job_queue_processes 可能太低(这是最常见的问题) job_queue_processes 的值限制了在给定时间可以运行的dbms_scheduler 和dbms_job 作业的总数。 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';要检查是否是这种情况,请使用 SQL> select value from v$parameter where name='job_queue_processes'; 检查 job_queue_processes 的当前值。 Then check the number of running jobs SQL> select count( ) from dba_scheduler_running_jobs;然后检查正在运行的作业数 SQL> select count( ) from dba_scheduler_running_jobs; SQL> select count( ) from dba_jobs_running; 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;如果这是问题,您可以使用 SQL> alter system set job_queue_processes=1000; 增加参数。

2) max_job_slave_processes may be too low If this parameter is not NULL then it limits how many dbms_scheduler jobs can be running at a time. 2) max_job_slave_processes 可能太低如果此参数不为NULL,则它限制了一次可以运行的dbms_scheduler 作业的数量。 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';要检查这是否是问题,请使用 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;然后检查正在运行的作业数 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)如果这是问题,您可以使用 SQL> exec dbms_scheduler.set_scheduler_attribute('max_job_slave_processes',null) 增加数字或将其设为 NULL

3) sessions may be too low This parameter limits the number of sessions at any time. 3) 会话数可能太低 此参数随时限制会话数。 Every Scheduler job requires 2 sessions.每个调度程序作业需要 2 个会话。 To check whether this is the problem, check the current valule using SQL> select value from v$parameter where name='sessions';要检查这是否是问题,请使用 SQL> select value from v$parameter where name='sessions'; 检查当前值。 Then check the current number of sessions using SQL> select count(*) from v$session ;然后使用 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;如果数字太接近,您可以使用 SQL> alter system set job_queue_processes=200; 增加最大值。

4) Have you recently applied a timezone update patch or upgraded the database to a version with newer timezone information ? 4) 您最近是否应用了时区更新补丁或将数据库升级到具有更新时区信息的版本? 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;要检查是否是这种情况,请尝试执行 SQL> select * from sys.scheduler$_job; and SQL> select * from sys.scheduler$_window;和 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 ? 5) 数据库是否在受限模式下运行? 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).如果数据库在受限模式下运行,则不会运行任何作业(除非您使用 11g 并使用 ALLOW_RUNS_IN_RESTRICTED_MODE 属性)。 To check this use SQL> select logins from v$instance ;要检查这个使用 SQL> select logins from v$instance ;

If logins is restricted you can disable the restricted mode using SQL> ALTER SYSTEM DISABLE RESTRICTED SESSION;如果登录受限,您可以使用 SQL> ALTER SYSTEM DISABLE RESTRICTED SESSION; 禁用受限模式。

6) Is the job scheduled to run on an instance which is down ? 6) 作业是否计划在停机的实例上运行?

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.您可以通过查看是否为作业设置了 instance_id 来检查这一点(检查 dba_scheduler_jobs 视图),如果是,您应该检查该实例是否已启动。

7) Is the job scheduled to run on a service which has not been started on any instances ? 7) 作业是否计划在尚未在任何实例上启动的服务上运行?

You can check this by checking what job_class a job points to and then checking whether that class points to a service.您可以通过检查作业指向的 job_class 然后检查该类是否指向服务来检查这一点。 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.您可以使用 dbms_service.start_service 在实例上启动服务。

8) Is the Resource Manager in effect with a restrictive resource plan ? 8) 资源经理是否实施了限制性资源计划?

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 ; SQL> 从 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.如果没有有效的计划或有效的计划是 INTERNAL_PLAN,则资源管理器无效。 If the resource manager is in effect you can disable it by doing如果资源管理器有效,您可以通过执行以下操作禁用它

SQL>alter system set resource_manager_plan = ''; SQL>alter system set resource_manager_plan = '';

9) Has the Scheduler been disabled ? 9) 调度程序是否被禁用? This is not a supported action 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'要检查这个做 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');如果此查询返回 TRUE,则您可以使用 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 ; 1)首先要检查作业调度的时区 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.如果 next_run_date 使用绝对时区偏移量(如 +08:00)而不是命名时区(如 US/PACIFIC),那么如果夏令时生效,作业可能不会按预期运行 - 它们可能会提前或晚运行一个小时.

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. 2) 可能在作业计划运行时,临时达到了上述几个限制之一,导致作业延迟。 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. 3) 可能达到上述限制之一的一个可能原因是维护窗口可能已经生效。 Maintenance windows are Oracle Scheduler windows that belong to the window group named MAINTENANCE_WINDOW_GROUP.维护窗口是属于名为 MAINTENANCE_WINDOW_GROUP 的窗口组的 Oracle 调度程序窗口。 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).有关更多信息,请参阅管理指南(第 24 章)。

To get a list of maintenance windows use SQL> select * from dba_scheduler_wingroup_members;要获取维护时段列表,请使用 SQL> select * from dba_scheduler_wingroup_members;

To see when the windows run use SQL> select * from dba_scheduler_windows;要查看 Windows 何时运行,请使用 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. 1) 检查警报日志中是否有任何错误。 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';您可以使用 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. 2) 检查是否有作业协调器跟踪文件,如果有,检查它是否包含任何错误。 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 .如果存在,它将位于您可以在上面找到的“background_dump_dest”目录中,并且看起来像 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. 3) 如果上述任一情况表明 SYSAUX 表空间(调度程序存储其日志表的位置)已满,您可以使用 dbms_scheduler.purge_log 过程清除旧的日志条目。

4) See if there is a window currently open. 4) 查看当前是否有窗口打开。 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 5)尝试运行一个简单的运行一次作业,看看它是否运行

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. 6) 如果一个简单的 run-once 作业没有运行,您可以尝试重新启动调度程序,如下所示。

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');

在多租户环境中,容器还必须具有正确的 job_queue_processes 值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM