|
1Z0-053第17章
1Z0-052共19章(上完13章),1Z0-053共21章(上完15章)和1Z0-063多租户部分共9章(上完0章)
总共上完全部49章中的28章
服务器端要做:
- [root@station26 ~]# su - oracle
- [oracle@station26 ~]$ lsnrctl services
- LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 24-OCT-2017 21:20:13
- Copyright (c) 1991, 2014, Oracle. All rights reserved.
- Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
- Services Summary...
- Service "+ASM" has 1 instance(s).
- Instance "+ASM", status READY, has 1 handler(s) for this service...
- Handler(s):
- "DEDICATED" established:5505 refused:0 state:ready
- LOCAL SERVER
- Service "cdb1" has 1 instance(s).
- Instance "cdb1", status READY, has 1 handler(s) for this service...
- Handler(s):
- "DEDICATED" established:8037 refused:0 state:ready
- LOCAL SERVER
- Service "cdb1XDB" has 1 instance(s).
- Instance "cdb1", status READY, has 1 handler(s) for this service...
- Handler(s):
- "D000" established:0 refused:0 current:0 max:1022 state:ready
- DISPATCHER <machine: station26.example.com, pid: 10924>
- (ADDRESS=(PROTOCOL=tcp)(HOST=station26.example.com)(PORT=46517))
- Service "orcl" has 1 instance(s).
- Instance "orcl", status READY, has 1 handler(s) for this service...
- Handler(s):
- "DEDICATED" established:19901 refused:0 state:ready
- LOCAL SERVER
- Service "orcl2" has 1 instance(s).
- Instance "orcl2", status READY, has 1 handler(s) for this service...
- Handler(s):
- "DEDICATED" established:20960 refused:0 state:ready
- LOCAL SERVER
- Service "orcl2XDB" has 1 instance(s).
- Instance "orcl2", status READY, has 1 handler(s) for this service...
- Handler(s):
- "D000" established:0 refused:0 current:0 max:1022 state:ready
- DISPATCHER <machine: station26.example.com, pid: 13973>
- (ADDRESS=(PROTOCOL=tcp)(HOST=station26.example.com)(PORT=19539))
- Service "orclXDB" has 1 instance(s).
- Instance "orcl", status READY, has 1 handler(s) for this service...
- Handler(s):
- "D000" established:0 refused:0 current:0 max:1022 state:ready
- DISPATCHER <machine: station26.example.com, pid: 13328>
- (ADDRESS=(PROTOCOL=tcp)(HOST=station26.example.com)(PORT=27200))
- Service "pdb1_1" has 1 instance(s).
- Instance "cdb1", status READY, has 1 handler(s) for this service...
- Handler(s):
- "DEDICATED" established:8037 refused:0 state:ready
- LOCAL SERVER
- The command completed successfully
- [oracle@station26 ~]$ sqlplus /nolog
- SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 24 21:20:20 2017
- Copyright (c) 1982, 2014, Oracle. All rights reserved.
- SQL> conn / as sysdba
- Connected.
- SQL> show parameter dispa
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- dispatchers string (PROTOCOL=TCP) (SERVICE=orclXD
- B)
- max_dispatchers integer
- SQL> alter system set dispatchers='(PROTOCOL=TCP) (dispatchers=3)';
- System altered.
- SQL> show parameter shared_ser
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- max_shared_servers integer
- shared_server_sessions integer
- shared_servers integer 1
- SQL> alter system set shared_servers=3 ;
- System altered.
- SQL> exit
- Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
- With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
- [oracle@station26 ~]$ lsnrctl services
- LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 24-OCT-2017 21:21:24
- Copyright (c) 1991, 2014, Oracle. All rights reserved.
- Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
- Services Summary...
- Service "+ASM" has 1 instance(s).
- Instance "+ASM", status READY, has 1 handler(s) for this service...
- Handler(s):
- "DEDICATED" established:5505 refused:0 state:ready
- LOCAL SERVER
- Service "cdb1" has 1 instance(s).
- Instance "cdb1", status READY, has 1 handler(s) for this service...
- Handler(s):
- "DEDICATED" established:8038 refused:0 state:ready
- LOCAL SERVER
- Service "cdb1XDB" has 1 instance(s).
- Instance "cdb1", status READY, has 1 handler(s) for this service...
- Handler(s):
- "D000" established:0 refused:0 current:0 max:1022 state:ready
- DISPATCHER <machine: station26.example.com, pid: 10924>
- (ADDRESS=(PROTOCOL=tcp)(HOST=station26.example.com)(PORT=46517))
- Service "orcl" has 1 instance(s).
- Instance "orcl", status READY, has 4 handler(s) for this service...
- Handler(s):
- "DEDICATED" established:19902 refused:0 state:ready
- LOCAL SERVER
- "D001" established:0 refused:0 current:0 max:1022 state:ready
- DISPATCHER <machine: station26.example.com, pid: 10545>
- (ADDRESS=(PROTOCOL=tcp)(HOST=station26.example.com)(PORT=52095))
- "D000" established:0 refused:0 current:0 max:1022 state:ready
- DISPATCHER <machine: station26.example.com, pid: 13328>
- (ADDRESS=(PROTOCOL=tcp)(HOST=station26.example.com)(PORT=27200))
- "D002" established:0 refused:0 current:0 max:1022 state:ready
- DISPATCHER <machine: station26.example.com, pid: 10547>
- (ADDRESS=(PROTOCOL=tcp)(HOST=station26.example.com)(PORT=49550))
- Service "orcl2" has 1 instance(s).
- Instance "orcl2", status READY, has 1 handler(s) for this service...
- Handler(s):
- "DEDICATED" established:20963 refused:0 state:ready
- LOCAL SERVER
- Service "orcl2XDB" has 1 instance(s).
- Instance "orcl2", status READY, has 1 handler(s) for this service...
- Handler(s):
- "D000" established:0 refused:0 current:0 max:1022 state:ready
- DISPATCHER <machine: station26.example.com, pid: 13973>
- (ADDRESS=(PROTOCOL=tcp)(HOST=station26.example.com)(PORT=19539))
- Service "orclXDB" has 1 instance(s).
- Instance "orcl", status READY, has 0 handler(s) for this service...
- Service "pdb1_1" has 1 instance(s).
- Instance "cdb1", status READY, has 1 handler(s) for this service...
- Handler(s):
- "DEDICATED" established:8038 refused:0 state:ready
- LOCAL SERVER
- The command completed successfully
- [oracle@station26 ~]$
复制代码
- [oracle@station26 ~]$ netstat -lntp | grep :8888
- (Not all processes could be identified, non-owned process info
- will not be shown, you would have to be root to see it all.)
- [oracle@station26 ~]$ sqlplus /nolog
- SQL*Plus: Release 12.1.0.2.0 Production on Tue Oct 24 21:27:55 2017
- Copyright (c) 1982, 2014, Oracle. All rights reserved.
- SQL> conn / as sysdba
- Connected.
- SQL> exec DBMS_XDB.SETHTTPPORT(8888);
- PL/SQL procedure successfully completed.
- SQL> exit
- Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
- With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
- [oracle@station26 ~]$ netstat -lntp | grep :8888
- (Not all processes could be identified, non-owned process info
- will not be shown, you would have to be root to see it all.)
- tcp 0 0 :::8888 :::* LISTEN 13005/tnslsnr
复制代码- BEGIN
- DBMS_SCHEDULER.SET_AGENT_REGISTRATION_PASS('mypassword');
- END;
- SELECT DBMS_XDB.GETHTTPPORT() FROM DUAL;
复制代码
客户端要做:
- DECLARE
- versionnum VARCHAR2(30);
- BEGIN
- versionnum := DBMS_SCHEDULER.GET_AGENT_VERSION('192.168.0.199');
- DBMS_OUTPUT.PUT_LINE(versionnum);
- END;
- DECLARE
- versionnum VARCHAR2(30);
- BEGIN
- versionnum := DBMS_SCHEDULER.GET_AGENT_VERSION('192.168.0.39');
- DBMS_OUTPUT.PUT_LINE(versionnum);
- END;
复制代码- grant all on station199 to hr;
- grant all on station39 to hr;
复制代码 Windows版本(有bug,一直running)
- BEGIN
- sys.dbms_scheduler.create_job(
- job_name => '"HR"."JOB11"',
- job_type => 'EXECUTABLE',
- job_action => 'c:\Users\oracle\c1.bat',
- start_date => systimestamp at time zone 'Asia/Shanghai',
- job_class => '"DEFAULT_JOB_CLASS"',
- comments => 'job11',
- auto_drop => FALSE,
- enabled => FALSE);
- DBMS_SCHEDULER.SET_ATTRIBUTE(name => '"HR"."JOB11"', attribute => 'destination', value => 'station199' );
- DBMS_SCHEDULER.SET_ATTRIBUTE(name => '"HR"."JOB11"', attribute => 'credential_name', value => '"SYS"."CRED1"' );
- sys.dbms_scheduler.enable( '"HR"."JOB11"' );
- END;
复制代码 Linux版本没问题:
-
-
- BEGIN
- sys.dbms_scheduler.create_job(
- job_name => '"HR"."JOB111"',
- job_type => 'EXECUTABLE',
- job_action => '/home/oracle/c1.sh',
- repeat_interval => 'FREQ=SECONDLY;INTERVAL=30',
- start_date => systimestamp at time zone 'Asia/Shanghai',
- end_date => to_timestamp_tz('2017-10-26 19:55:00 Asia/Shanghai', 'YYYY-MM-DD HH24:MI:SS TZR'),
- job_class => '"DEFAULT_JOB_CLASS"',
- comments => 'job111',
- auto_drop => FALSE,
- enabled => FALSE);
- DBMS_SCHEDULER.SET_ATTRIBUTE(name => '"HR"."JOB111"', attribute => 'destination', value => 'station39' );
- DBMS_SCHEDULER.SET_ATTRIBUTE(name => '"HR"."JOB111"', attribute => 'credential_name', value => '"SYS"."CRED1"' );
- sys.dbms_scheduler.enable( '"HR"."JOB111"' );
- END;
复制代码
远程外部作业(文件的时间属性是格林威志时间):
- --SYS:
- 创建远程credential
- begin
- dbms_scheduler.create_credential(
- credential_name => 'credential2',
- username => 'oracle',
- password => 'oracle');
- end;
- grant execute on credential2 to hr;
- select * from dba_scheduler_external_dests;
- --查到STATION41
- begin
- dbms_scheduler.create_file_watcher(
- file_watcher_name => 'filewatcher2',
- directory_path => '/home/oracle/yourfile',
- file_name => 'botang*.txt',
- credential_name => 'credential2',
- destination => 'STATION41');
- end;
- begin
- DBMS_SCHEDULER.enable('filewatcher2');
- end;
- --em界面做也可以
- By default, file watchers only check for the arrival of files every 10 minutes, but this default interval can be changed by issuing the following statement.
- BEGIN
- DBMS_SCHEDULER.set_attribute(
- 'file_watcher_schedule',
- 'repeat_interval',
- 'freq=minutely; interval=1');
- END;
- /
-
- select * from dba_scheduler_file_watchers;
- grant execute on filewatcher2 to hr;
- --HR:
- create table hr.tfilewatcher2( a varchar2(200) ) ;
- create or replace procedure hr.procfilewatcher2( p_1 SYS.SCHEDULER_FILEWATCHER_RESULT)
- is
- begin
- insert into hr.tfilewatcher2 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.program12',
- program_type => 'STORED_PROCEDURE',
- program_action => 'HR.procfilewatcher2',
- number_of_arguments => 1,
- enabled => false);
- end;
- begin
- dbms_scheduler.define_metadata_argument(
- program_name => 'HR.program12',
- metadata_attribute => 'event_message',argument_position => 1 ) ;
- end;
- begin
- dbms_scheduler.enable('HR.program12');
- end;
- BEGIN
- DBMS_SCHEDULER.CREATE_JOB(
- jOB_NAME=> 'hr.job12',
- PROGRAM_NAME=> 'hr.program12',
- EVENT_CONDITION => 'tab.user_data.file_size > 10',
- QUEUE_SPEC=> 'filewatcher2',
- AUTO_DROP=> FALSE,
- ENABLED=> true);
- END;
- begin
- dbms_scheduler.set_attribute('hr.job12','parallel_instances',true);
- end;
- select * from hr.tfilewatcher2;
复制代码 远程数据库作业(12c有bug):
- select * from dba_scheduler_dests;
- select * from dba_scheduler_external_dests;
- select * from dba_scheduler_db_dests;
- begin
- dbms_scheduler.drop_agent_destination('STATION199');
- end;
- begin
- dbms_scheduler.create_credential('cred2','hr','oracle_4U');
- end;
- grant execute on cred2 to hr;
- select * from dba_scheduler_credentials;
- begin
- dbms_scheduler.create_database_destination(
- destination_name => 'remotedb39',
- agent => 'station39',tns_name => 'pdb1_1');
- end;
- grant all on remotedb39 to hr;
- select * from dba_Tab_privs t where t.grantee='HR';
- BEGIN
- sys.dbms_scheduler.create_job(
- job_name => 'hr.job131',
- job_type => 'PLSQL_BLOCK',
- job_action => 'begin
- update employees set salary=salary+1 where employee_id=100;
- commit;
- end;',
- start_date => systimestamp at time zone 'Asia/Shanghai',
- job_class => '"DEFAULT_JOB_CLASS"',
- comments => 'JOB131',
- auto_drop => FALSE,
- credential_name =>'"SYS"."CRED2"' ,destination_name =>'sys.remotedb39' ,
- enabled => true);
- END;
复制代码
作业组:
- select * from dba_scheduler_groups;
- select * from dba_scheduler_group_members;
- ----
- BEGIN
- DBMS_SCHEDULER.create_group(
- group_name => 'hr.group1',
- group_type => 'EXTERNAL_DEST',
- member => 'sys.cred1@LOCAL,sys.cred1@sys.station39'
- );
- END;
- ---
- select * from dba_scheduler_groups g where g.group_name='GROUP1';
- select * from dba_scheduler_group_members gm where gm.group_name='GROUP1';
- ----
- BEGIN
- DBMS_SCHEDULER.CREATE_JOB (
- job_name => 'hr.JOB14',
- job_type => 'executable',
- job_action => '/home/oracle/job2.sh',
- start_date => SYSTIMESTAMP,
- repeat_interval => 'freq=minutely; bysecond=0',
- end_date => SYSTIMESTAMP + 1/24,
- credential_name => 'sys.cred1',
- destination_name => 'group1',
- enabled => TRUE);
- END;
复制代码
|
|