|
默认的Filewatcher作业其实是一个queue:
当我们创建自己的Filewatcher时,其实就是上面这个Filewatcher的一个实例。
间隔性地进行Filewatcher:
- BEGIN
- sys.dbms_scheduler.set_attribute( name => '"SYS"."FILE_WATCHER_SCHEDULE"', attribute => 'repeat_interval', value => 'FREQ=MINUTELY;INTERVAL=2');
- END;
复制代码
在64为Linux上,首先要做:
[root@station90 lib64]# ls -l libpam.so*
lrwxrwxrwx 1 root root 16 8月 4 15:48 libpam.so -> libpam.so.0.82.2
lrwxrwxrwx. 1 root root 16 7月 17 04:41 libpam.so.0 -> libpam.so.0.82.2
-rwxr-xr-x. 1 root root 55280 7月 10 2017 libpam.so.0.82.2
-----------------------------------------------------------------------------------------
- begin
- dbms_scheduler.create_file_watcher(
- file_watcher_name => 'filewatcher1',
- directory_path => '/home/oracle/myfile',
- file_name => 'botang*.txt',
- credential_name => 'credential1');
- end;
复制代码- select j.state, j.next_run_date
- from dba_scheduler_jobs j where j.job_name='FILE_WATCHER';
复制代码 | STATE | NEXT_RUN_DATE | 1 | SCHEDULED | 16-AUG-18 08.00.24.578708 PM PRC |
- select * from dba_scheduler_file_watchers;
复制代码 | OWNER | FILE_WATCHER_NAME | ENABLED | DESTINATION_OWNER | DESTINATION | DIRECTORY_PATH | FILE_NAME | CREDENTIAL_OWNER | CREDENTIAL_NAME | MIN_FILE_SIZE | STEADY_STATE_DURATION | LAST_MODIFIED_TIME | COMMENTS | 1 | SYS | FILEWATCHER1 | TRUE | | | /home/oracle/myfile | botang*.txt | SYS | CREDENTIAL1 | 0 | | 16-AUG-18 07.50.24.582733 PM +08:00 | |
- grant execute on filewatcher1 to hr;
- grant execute on SYS.SCHEDULER_FILEWATCHER_RESULT to hr;
- create table hr.tfilewatcher1 ( a varchar2(200) ) ;
- create or replace procedure hr.procfilewatcher ( p_1 SYS.SCHEDULER_FILEWATCHER_RESULT)
- is
- begin
- insert into hr.tfilewatcher1 values ( to_char( p_1.file_timestamp,'YYYY-MM-DD:HH24:MI:SS') ||' '
- ||p_1.directory_path||' '
- ||p_1.actual_file_name||' '
- ||p_1.file_size ) ;
- commit;
- end;
- begin
- dbms_scheduler.create_program(
- program_name => 'HR.program10',
- program_type => 'STORED_PROCEDURE',
- program_action => 'HR.procfilewatcher',
- number_of_arguments => 1,
- enabled => false);
- end;
- begin
- dbms_scheduler.define_metadata_argument(
- program_name => 'HR.program10',
- metadata_attribute => 'event_message',argument_position => 1 ) ;
- end;
- begin
- dbms_scheduler.enable('HR.program10');
- end;
- BEGIN
- DBMS_SCHEDULER.CREATE_JOB(
- jOB_NAME=> 'hr.job10',
- PROGRAM_NAME=> 'hr.program10',
- EVENT_CONDITION => 'tab.user_data.file_size > 10',
- QUEUE_SPEC=> 'filewatcher1',
- AUTO_DROP=> FALSE,
- ENABLED=> true);
- END;
- begin
- dbms_scheduler.set_attribute('hr.job10','parallel_instances',true);
- end;
- select * from hr.tfilewatcher1;
复制代码- BEGIN
- dbms_resource_manager.clear_pending_area();
- dbms_resource_manager.create_pending_area();
- dbms_resource_manager.create_plan( plan => 'PLAN2',
- comment => 'PLAN2',
- cpu_mth => 'RATIO' );
- dbms_resource_manager.create_plan_directive(
- plan => 'PLAN2',
- group_or_subplan => 'SYS_GROUP',
- comment => 'SYS_GROUP',
- mgmt_p1 => 50
- );
- dbms_resource_manager.create_plan_directive(
- plan => 'PLAN2',
- group_or_subplan => 'GROUP1',
- comment => 'GROUP1',
- mgmt_p1 => 30
- );
- dbms_resource_manager.create_plan_directive(
- plan => 'PLAN2',
- group_or_subplan => 'GROUP2',
- comment => 'GROUP2',
- mgmt_p1 => 15
- );
- dbms_resource_manager.create_plan_directive(
- plan => 'PLAN2',
- group_or_subplan => 'OTHER_GROUPS',
- comment => 'OTHER_GROUPS',
- mgmt_p1 => 5
- );
- dbms_resource_manager.submit_pending_area();
- end;
- select p.plan, p.cpu_method,p.active_sess_pool_mth,
- p.parallel_degree_limit_mth , p.queueing_mth
- from dba_rsrc_plans p
- where p.plan like 'PLAN%';
复制代码 | PLAN | CPU_METHOD | ACTIVE_SESS_POOL_MTH | PARALLEL_DEGREE_LIMIT_MTH | QUEUEING_MTH | 1 | PLAN2 | RATIO | ACTIVE_SESS_POOL_ABSOLUTE | PARALLEL_DEGREE_LIMIT_ABSOLUTE | FIFO_TIMEOUT | 2 | PLAN1 | EMPHASIS | ACTIVE_SESS_POOL_ABSOLUTE | PARALLEL_DEGREE_LIMIT_ABSOLUTE | FIFO_TIMEOUT |
子计划出现在哪里:
- begin
- dbms_resource_manager.create_simple_plan(simple_plan => 'PLAN3',
- consumer_group1 => 'group1',
- group1_cpu => 80,
- consumer_group2 => 'group2',
- group2_cpu => 20);
- end;
复制代码- select p.plan, p.cpu_method,p.active_sess_pool_mth,
- p.parallel_degree_limit_mth , p.queueing_mth
- from dba_rsrc_plans p
- where p.plan like 'PLAN%';
复制代码 | PLAN | CPU_METHOD | ACTIVE_SESS_POOL_MTH | PARALLEL_DEGREE_LIMIT_MTH | QUEUEING_MTH | 1 | PLAN1 | EMPHASIS | ACTIVE_SESS_POOL_ABSOLUTE | PARALLEL_DEGREE_LIMIT_ABSOLUTE | FIFO_TIMEOUT | 2 | PLAN3 | EMPHASIS | ACTIVE_SESS_POOL_ABSOLUTE | PARALLEL_DEGREE_LIMIT_ABSOLUTE | FIFO_TIMEOUT | 3 | PLAN2 | RATIO | ACTIVE_SESS_POOL_ABSOLUTE | PARALLEL_DEGREE_LIMIT_ABSOLUTE | FIFO_TIMEOUT |
- select pd.mgmt_p1,
- pd.mgmt_p2,
- pd.mgmt_p3
- from dba_rsrc_plan_directives pd
- where pd.plan='PLAN3';
-
复制代码 | MGMT_P1 | MGMT_P2 | MGMT_P3 | 1 | 0 | 80 | 0 | 2 | 100 | 0 | 0 | 3 | 0 | 0 | 100 | 4 | 0 | 20 | 0 |
RATIO没有第二级:
测一下cpu:
---------------------------------------------------------------------------------------
并行度:
- select pd.group_or_subplan ,pd.parallel_degree_limit_p1
- from dba_rsrc_plan_directives pd
- where pd.plan='PLAN2';
复制代码 | GROUP_OR_SUBPLAN | PARALLEL_DEGREE_LIMIT_P1 | 1 | SYS_GROUP | | 2 | GROUP1 | 1 | 3 | GROUP2 | | 4 | OTHER_GROUPS | |
-----------------------------活跃会话池
|
|