17 Copyright © 2004, Oracle. All rights reserved. Automating Tasks with the Scheduler.

Slides:



Advertisements
Similar presentations
10 Copyright © 2005, Oracle. All rights reserved. Dimensions.
Advertisements

Module 12: Auditing SQL Server Environments
17 Copyright © 2005, Oracle. All rights reserved. Performing Flashback.
Week 6: Chapter 6 Agenda Automation of SQL Server tasks using: SQL Server Agent Scheduling Scripting Technologies.
CNT 4603: Managing/Maintaining Server 2008 – Part 3 Page 1 Dr. Mark Llewellyn © CNT 4603: System Administration Spring 2014 Managing And Maintaining Windows.
18 Copyright © 2005, Oracle. All rights reserved. Moving Data.
Lesson 17: Configuring Security Policies
12 Copyright © 2005, Oracle. All rights reserved. Proactive Maintenance.
Manage Run Activities Cognos 8 BI. Objectives  At the end of this course, you should be able to:  manage current, upcoming and past activities  manage.
10 Copyright © 2009, Oracle. All rights reserved. Managing Undo Data.
9 Copyright © Oracle Corporation, All rights reserved. Oracle Recovery Manager Overview and Configuration.
Module 13 Automating SQL Server 2008 R2 Management.
12 Copyright © 2007, Oracle. All rights reserved. Database Maintenance.
CHAPTER 21 Automating Jobs. Introduction to Automating Jobs DBAs rely heavily on automating jobs. DBAs cannot be effective without automation. Listed.
Workflow Manager and General Tuning Tips. Topics to discuss… Working with Workflows Working with Tasks General Tuning Tips.
Chapter 6 Additional Database Objects
5 Copyright © 2004, Oracle. All rights reserved. Using Recovery Manager.
9 Copyright © 2005, Oracle. All rights reserved. Administering User Security.
Week 6 Lecture 2 System and Object Privileges. Learning Objectives  Identify and manage system and object privileges  Grant and revoke privileges to.
Copyright © 2007, Oracle. All rights reserved. Managing Concurrent Requests.
9 Copyright © 2004, Oracle. All rights reserved. Flashback Database.
Chapter 6 Additional Database Objects Oracle 10g: SQL.
IT 456 Seminar 5 Dr Jeffrey A Robinson. Overview of Course Week 1 – Introduction Week 2 – Installation of SQL and management Tools Week 3 - Creating and.
Module 14 Configuring Security for SQL Server Agent.
18 Copyright © Oracle Corporation, All rights reserved. Workshop.
17 Copyright © Oracle Corporation, All rights reserved. Recovery Catalog Creation and Maintenance.
1 Chapter Overview Preparing to Upgrade Performing a Version Upgrade from Microsoft SQL Server 7.0 Performing an Online Database Upgrade from SQL Server.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
14 Copyright © 2006, Oracle. All rights reserved. Automating Tasks with the Scheduler.
37 Copyright © 2007, Oracle. All rights reserved. Module 37: Executing Workflow Processes Siebel 8.0 Essentials.
3 Copyright © 2004, Oracle. All rights reserved. Controlling Access to the Oracle Listener.
Get Rid of Cron Scripts Using Events Sheeri Cabral Senior DB Admin/Architect,
1 Chapter Overview Defining Operators Creating Jobs Configuring Alerts Creating a Database Maintenance Plan Creating Multiserver Jobs.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
13 Copyright © Oracle Corporation, All rights reserved. Maintaining Data Integrity.
3 Copyright © 2006, Oracle. All rights reserved. Using Recovery Manager.
9 Copyright © 2009, Oracle. All rights reserved. Deploying and Reporting on ETL Jobs.
C Copyright © 2006, Oracle. All rights reserved. Services.
20 Copyright © 2008, Oracle. All rights reserved. Cache Management.
2 Copyright © 2006, Oracle. All rights reserved. Configuring Recovery Manager.
30 Copyright © 2009, Oracle. All rights reserved. Using Oracle Business Intelligence Delivers.
3 Copyright © 2007, Oracle. All rights reserved. Using the RMAN Recovery Catalog.
Module 6: Administering Reporting Services. Overview Server Administration Performance and Reliability Monitoring Database Administration Security Administration.
1 Copyright © 2009, Oracle. All rights reserved. Controlling User Access.
15 Copyright © 2004, Oracle. All rights reserved. Debugging Triggers.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
9 Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Scheduling and Bursting Reports.
1 11g NEW FEATURES ByVIJAY. 2 AGENDA  RESULT CACHE  INVISIBLE INDEXES  READ ONLY TABLES  DDL WAIT OPTION  ADDING COLUMN TO A TABLE WITH DEFAULT VALUE.
6 Copyright © 2007, Oracle. All rights reserved. Managing Security and Metadata.
14 Copyright © 2004, Oracle. All rights reserved. Using Materialized Views.
 CONACT UC:  Magnific training   
8 Copyright © 2005, Oracle. All rights reserved. Managing Schema Objects.
13 Copyright © 2007, Oracle. All rights reserved. Using the Data Recovery Advisor.
20 Copyright © 2006, Oracle. All rights reserved. Best Practices and Operational Considerations.
3 Copyright © 2006, Oracle. All rights reserved. Building an Analytic Workspace.
CONTROL-M Training At Global Online Trainings IND: Skype: Global.onlinetrainings USA:
11 Copyright © 2004, Oracle. All rights reserved. Performing a Migration Using Oracle Migration Workbench (Part II)
17 Copyright © 2006, Oracle. All rights reserved. Information Publisher.
4 Copyright © 2004, Oracle. All rights reserved. Managing the Oracle Instance.
9 Copyright © 2004, Oracle. All rights reserved. Getting Started with Oracle Migration Workbench.
23 Copyright © 2004, Oracle. All rights reserved. Preferring the Past: Flashback.
5 Copyright © 2005, Oracle. All rights reserved. Managing the Oracle Instance.
9 Copyright © 2006, Oracle. All rights reserved. Summary Management.
2 Copyright © 2009, Oracle. All rights reserved. Managing Schema Objects.
Automating Tasks with the Scheduler
Scheduler Enhancements
SCHEDULING IN ORACLE DATABASE 10G
Automating Tasks with the Scheduler
Workshop.
DBMS_SCHEDULER: The How, What and Why
Presentation transcript:

17 Copyright © 2004, Oracle. All rights reserved. Automating Tasks with the Scheduler

Copyright © 2004, Oracle. All rights reserved Objectives After completing this lesson, you should be able to: Simplify management tasks by using the Scheduler Create a job, program, schedule, and window Reuse Scheduler components for similar tasks View information about job executions and job instances

Copyright © 2004, Oracle. All rights reserved Scheduling Needs Create month-end report on the last day of each month Compute table and index statistics twice a day Replicate table data via materialized view refreshes Generate daily report on invalid server access attempts Start the batch load at 4:00 a.m. Check for queued events every 10 minutes Run daily job to backup database

Copyright © 2004, Oracle. All rights reserved Scheduler Concepts JobProgram Arguments Schedule Job class Window Resource plan Window group Resource Consumer Group

Copyright © 2004, Oracle. All rights reserved. 17-5

Copyright © 2004, Oracle. All rights reserved Privileges for Scheduler Components CREATE [ANY] JOB EXECUTE ANY PROGRAM EXECUTE ANY CLASS MANAGE SCHEDULER EXECUTE ON ALTER ON ALL ON System and object privileges SCHEDULER_ADMIN role CREATE JOB CREATE ANY JOB EXECUTE ANY PROGRAM EXECUTE ANY CLASS MANAGE SCHEDULER

Copyright © 2004, Oracle. All rights reserved. 17-7

Copyright © 2004, Oracle. All rights reserved Creating a Scheduler Job There are many ways to create a job: Specifying the components in-line as part of the CREATE_JOB procedure Specifying the task directly and using a saved schedule Calling a saved program and a saved schedule Calling a saved program and specifying the schedule directly

Copyright © 2004, Oracle. All rights reserved Creating a Scheduler Job: Example Create a job that calls a backup script every night at 23:00 (starting tonight). BEGIN DBMS_SCHEDULER.CREATE_JOB( job_name=>'HR.DO_BACKUP', job_type => 'EXECUTABLE', job_action =>'/home/usr/dba/rman/nightly_incr.sh', start_date=>TRUNC(SYSDATE)+23/24, repeat_interval=>'TRUNC(SYSDATE+1)+23/24', /* next night at 11:00 PM */ comments => 'Nightly incremental backups'); END; /

Copyright © 2004, Oracle. All rights reserved Setting the Repeat Interval for a Job Using a calendaring expression: Using a datetime expression: repeat_interval=> 'FREQ=HOURLY; INTERVAL=4' repeat_interval=> 'FREQ=DAILY' repeat_interval=> 'FREQ=MINUTELY; INTERVAL=15' repeat_interval=> 'FREQ=YEARLY; BYMONTH=MAR,JUN,SEP,DEC; BYMONTHDAY=15' repeat_interval=> 'SYSDATE + 36/24' repeat_interval=> 'SYSDATE + 1' repeat_interval=> 'SYSDATE + 15/(24*60)'

Copyright © 2004, Oracle. All rights reserved Calendaring Expressions YEARLY MONTHLY WEEKLY DAILY HOURLY MINUTELY SECONDLY INTERVAL (1-999) BYMONTH BYWEEKNO BYYEARDAY BYMONTHDAY BYDAY BYHOUR BYMINUTE BYSECOND Frequency Interval Specifiers

Copyright © 2004, Oracle. All rights reserved Using Scheduler Programs BEGIN DBMS_SCHEDULER.CREATE_PROGRAM( program_name => 'CALC_STATS2', program_action => 'HR.UPDATE_SCHEMA_STATS', program_type => 'STORED_PROCEDURE', enabled => TRUE); DBMS_SCHEDULER.CREATE_JOB( job_name=>'HR.GET_STATS2', program_name=>'HR.CALC_STATS2', start_date=>'20-DEC AM Greenwich', repeat_interval=> 'FREQ=HOURLY;INTERVAL=2', end_date => '20-DEC AM Greenwich', comments => 'Explicitly scheduled job'); END; /

Copyright © 2004, Oracle. All rights reserved Creating a Program Using EM

Copyright © 2004, Oracle. All rights reserved Specifying Schedules for a Job Example schedules: Wednesday, December 26, 2002, at 2:00 p.m. Every fourth Thursday Every Monday at 8:00 a.m., starting on January 29, 2004, and ending on March 31, 2004 Schedule Start time End time or limit One Time job Repeating job

Copyright © 2004, Oracle. All rights reserved Creating and Using Schedules BEGIN DBMS_SCHEDULER.CREATE_SCHEDULE( schedule_name => 'stats_schedule', start_date => SYSTIMESTAMP, end_date => SYSTIMESTAMP + 30, repeat_interval => 'FREQ=HOURLY;INTERVAL=4', comments => 'Every 4 hours'); DBMS_SCHEDULER.CREATE_JOB( job_name => 'HR.GET_STATS', program_name => 'HR.CALC_STATS2', schedule_name => 'STATS_SCHEDULE'); END; /

Copyright © 2004, Oracle. All rights reserved Using EM to Create Schedules

Copyright © 2004, Oracle. All rights reserved Advanced Scheduler Concepts JobProgram Arguments Schedule Job class Window Resource plan Window group Resource Consumer Group

Copyright © 2004, Oracle. All rights reserved Creating a Job Class

Copyright © 2004, Oracle. All rights reserved Creating a Job Class EXECUTE DBMS_SCHEDULER.CREATE_JOB_CLASS( - job_class_name => 'ADMIN_JOBS', - resource_consumer_group => 'DAYTIME_JOBS', - logging_level => DBMS_SCHEDULER.LOGGING_OFF); Job Class Resource Consumer Group Service Log History Logging Level

Copyright © 2004, Oracle. All rights reserved Job Logging By default, all job runs are logged. The amount of information logged can be controlled at the job class level. EXECUTE DBMS_SCHEDULER.CREATE_JOB_CLASS( - job_class_name => 'ADMIN_JOBS', - resource_consumer_group => 'DAYTIME_JOBS', - logging_level => DBMS_SCHEDULER.LOGGING_RUNS, - log_history => 30);

Copyright © 2004, Oracle. All rights reserved Creating a Window Create a window for the month of December that uses the END_OF_YEAR resource plan and is active every night from 6:00 p.m. to 6:00 a.m. Eastern Standard Time (EST). BEGIN DBMS_SCHEDULER.CREATE_WINDOW( window_name => 'DEC_NIGHTS', resource_plan => 'END_OF_YEAR', start_date => '01-DEC PM EST', repeat_interval => 'FREQ=DAILY; BYHOUR=18', duration => '0 12:00:00', end_date => '31-DEC AM EST', comments => 'Every day at 6:00 PM'); END; /

Copyright © 2004, Oracle. All rights reserved

Copyright © 2004, Oracle. All rights reserved Prioritizing Jobs Within a Window Daytime Window APPL_JOBS Job1Job2 ADMIN_JOBS Job4Job5 OTHER Job3 JobPriority Job11 Job25 Job33 Job44 Job52

Copyright © 2004, Oracle. All rights reserved

Copyright © 2004, Oracle. All rights reserved Enabling and Disabling Scheduler Components Enable the CALC_STATS2 program: Disable the GET_STATS job: EXEC DBMS_SCHEDULER.ENABLE('HR.CALC_STATS2'); EXEC DBMS_SCHEDULER.DISABLE('HR.GET_STATS');

Copyright © 2004, Oracle. All rights reserved Managing Jobs Run a job: Stop a job: Drop a job, even if it is currently running: DBMS_SCHEDULER.RUN_JOB('HR.JOB1'); DBMS_SCHEDULER.STOP_JOB('HR.JOB2'); DBMS_SCHEDULER.DROP_JOB('HR.JOB1,HR.JOB2, SYS.JOBCLASS1');

Copyright © 2004, Oracle. All rights reserved Managing Programs Enabling a program: Disabling a program: Dropping a program: EXECUTE DBMS_SCHEDULER.DROP_PROGRAM( - program_name => 'HR.PROG1', - force => FALSE ); EXECUTE DBMS_SCHEDULER.ENABLE( - 'HR.PROG1,HR.PROG2'); EXECUTE DBMS_SCHEDULER.DISABLE( - 'HR.PROG1,HR.PROG2');

Copyright © 2004, Oracle. All rights reserved Managing Programs with EM

Copyright © 2004, Oracle. All rights reserved Managing Schedules CREATE_SCHEDULE SET_ATTRIBUTE (to alter a schedule) DROP_SCHEDULE EXEC DBMS_SCHEDULER.DROP_SCHEDULE( - schedule_name => 'HR.STATS_SCHEDULE'); EXEC DBMS_SCHEDULER.SET_ATTRIBUTE( - name => 'HR.STATS_SCHEDULE', - attribute => 'START_DATE', - value => '01-JAN :00:00 US/Pacific');

Copyright © 2004, Oracle. All rights reserved Managing Windows DBMS_SCHEDULER.OPEN_WINDOW( window_name =>'DEC_NIGHTS', duration => '1 0:00:00' ); DBMS_SCHEDULER.CLOSE_WINDOW('DEC_NIGHTS'); DBMS_SCHEDULER.DROP_WINDOW( window_name =>'DEC_NIGHTS, DEC_DAYS', force => TRUE); DBMS_SCHEDULER.DISABLE( name => 'SYS.DEC_NIGHTS', force=>TRUE);

Copyright © 2004, Oracle. All rights reserved

Copyright © 2004, Oracle. All rights reserved Window Priority An order of precedence applies for when windows overlap: The window with the highest priority opens first If windows have same priority, then the window that is active remains open If at the end of a window there are multiple windows defined, the window that has the highest percentage of time remaining, opens An open window that is dropped is automatically closed 8 a.m6 a.m10 a.m12 p.m.2 p.m W1 W2 W3

Copyright © 2004, Oracle. All rights reserved Managing Attributes of Scheduler Components Change an attribute for a job: Remove a program comment by setting it to NULL : BEGIN DBMS_SCHEDULER.SET_ATTRIBUTE( name => 'HR.GET_STATS', attribute => 'MAX_FAILURES', value => 3); END; / EXEC DBMS_SCHEDULER.SET_ATTRIBUTE_NULL( - 'HR.CALC_STATS2','COMMENTS');

Copyright © 2004, Oracle. All rights reserved Managing Attributes of Scheduler Components Retrieve attribute values for the GET_STATS job created by the HR user: SELECT max_failures MAX_FAIL, job_priority, schedule_limit SCHED_LIMIT, logging_level FROM user_scheduler_jobs WHERE job_name = 'GET_STATS' AND job_creator = 'HR'; MAX_FAIL JOB_PRIOR SCHED_LIMIT LOGGING_LEVEL LOW

Copyright © 2004, Oracle. All rights reserved Managing Attributes of the Scheduler You can set three attribute values at the global level, affecting all Scheduler components: default_timezone max_job_slave_processes log_history EXEC DBMS_SCHEDULER.SET_SCHEDULER_ATTRIBUTE( - attribute => 'log_history', - value => '14');

Copyright © 2004, Oracle. All rights reserved Viewing Job Execution Details The DBA_SCHEDULER_JOB_RUN_DETAILS view has a row for each job instance. Each row contains information about the job execution for that instance. SELECT job_name, status, error#, run_duration FROM USER_SCHEDULER_JOB_RUN_DETAILS; JOB_NAME STATUS ERROR# RUN_DURATION GATHER_STATS_JOB SUCCESS :08:20 PART_EXCHANGE_JOB FAILURE :00:00

Copyright © 2004, Oracle. All rights reserved Viewing Job Logs The DBA_SCHEDULER_JOB_LOG view has a row for each job operation or modification. SELECT job_name, operation, owner FROM ALL_SCHEDULER_JOB_LOG; JOB_NAME OPERATION OWNER GET_STATS2 ALTER HR TESTJOB RUN HR TESTJOB RETRY_RUN HR TESTJOB FAILED HR TESTJOB DROP HR COMPUTE_STATS CREATE HR

Copyright © 2004, Oracle. All rights reserved Purging Job Logs You can purge the job logs: Automatically, through the PURGE_LOG job using default values Using the PURGE_LOG job, but modifying the conditions that determine when entries are purged On demand, by calling the DBMS_SCHEDULER.PURGE_LOG procedure EXECUTE DBMS_SCHEDULER.PURGE_LOG( - log_history => 1, - job_name => 'TESTJOB');

Copyright © 2004, Oracle. All rights reserved

Copyright © 2004, Oracle. All rights reserved Data Dictionary Views [DBA | ALL | USER]_SCHEDULER_JOBS [DBA | ALL | USER]_SCHEDULER_JOB_ARGS [DBA | ALL | USER]_SCHEDULER_RUNNING_JOBS [DBA | ALL | USER]_SCHEDULER_JOB_LOG [DBA | ALL | USER]_SCHEDULER_JOB_RUN_DETAILS [DBA | ALL | USER]_SCHEDULER_PROGRAMS [DBA | ALL | USER]_SCHEDULER_PROGRAM_ARGS [DBA | ALL | USER]_SCHEDULER_SCHEDULES [DBA | ALL]_SCHEDULER_JOB_CLASSES [DBA | ALL ]_SCHEDULER_WINDOWS [DBA | ALL ]_SCHEDULER_WINDOW_DETAILS [DBA | ALL ]_SCHEDULER_WINDOW_LOG

Copyright © 2004, Oracle. All rights reserved Summary In this lesson, you should have learned how to: Simplify management tasks by using the Scheduler Create a job, program, schedule, and window Reuse Scheduler components for similar tasks View information about job executions and job instances

Copyright © 2004, Oracle. All rights reserved Practice 17 Overview: Automating Tasks with the Scheduler This practice covers the following topics: Creating a job that runs a program outside of the database Creating a program and a schedule Creating a job that uses a program and a schedule Altering the program and schedule for the job and observing the behavior change of the job Monitoring job runs

Copyright © 2004, Oracle. All rights reserved Practice 17: Using the Scheduler

Copyright © 2004, Oracle. All rights reserved Practice 17: Using the Scheduler

Copyright © 2004, Oracle. All rights reserved Practice 17: Using the Scheduler

Copyright © 2004, Oracle. All rights reserved