开发者

Is this a valid way to use the Oracle Recovery Manager with the Oracle Job Scheduler?

First, I am creating an executable job:

BEGIN
  DBMS_SCHEDULER.CREATE_JOB(job_name => 'PIPE_JOB', job_type => 'EXECUTABLE', job_action => 'RMAN PIPE TEST_PIPE_1 target / TIMEOUT = 60');
END;

Next, I am trying to execute the job with this series of Oracle commands:

DECLARE
  pipename CONSTANT VARCHAR2(100) := 'TEST_PIPE_1';
  create_result INTEGER;
  send_re开发者_StackOverflow中文版sult INTEGER;
BEGIN
  create_result := DBMS_PIPE.CREATE_PIPE(pipename);
  DBMS_PIPE.PACK_MESSAGE('BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DEVICE TYPE DISK DATABASE INCLUDE CURRENT CONTROLFILE;');
  send_result := DBMS_PIPE.SEND_MESSAGE(pipename);
  DBMS_SCHEDULER.RUN_JOB(job_name => 'PIPE_JOB', use_current_session => false);
END;

Now, when I make the call to RUN_JOB, the RMAN executable fires up on the server, but then immediately exits, presumably because it never receives the commands that I am attempting to pack into the pipe.

How can I use pipes correctly to make RMAN receive the commands I am trying to send it?


I don't think you can use DBMS_PIPE for this. It is a PL/SQL 'thing' and not something RMAN can deal with, and not like unix pipes to STDIN.

You can do parameters with DBMS_SCHEDULER though. You may need an intervening shell script.

[Added] I'd have a shell script that takes one or more parameters

dbms_scheduler.create_job
(
job_name => 'job1',
job_type => 'EXECUTABLE',
job_action => '/somewhere/rman_script.sh',
enabled => false,
number_of_arguments => 2,
comments => 'Run shell-script'
);
dbms_scheduler.set_job_argument_value(SHELL || jobidx,1,'blah');
dbms_scheduler.set_job_argument_value(SHELL || jobidx,2,'blah');
dbms_scheduler.enable('job1');

The shell script would call RMAN and pipe the parameters to it through STDIN.


Looks like I was wrong before and RMAN can be used with DBMS_PIPE. Article here. Don't understand it myself, but a comment on the blog may give some more details

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜