这是将 Oracle Recovery Manager 与 Oracle Job Scheduler 结合使用的有效方法吗?

发布于 2024-08-14 19:47:51 字数 816 浏览 2 评论 0原文

首先,我正在创建一个可执行作业:

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

接下来,我尝试使用这一系列 Oracle 命令执行该作业:

DECLARE
  pipename CONSTANT VARCHAR2(100) := 'TEST_PIPE_1';
  create_result INTEGER;
  send_result 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;

现在,当我调用 RUN_JOB 时,RMAN 可执行文件会在服务器上启动,但随后可能会立即退出因为它永远不会收到我试图打包到管道中的命令。

如何正确使用管道使 RMAN 接收我尝试发送的命令?

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_result 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故事还在继续 2024-08-21 19:47:51

我认为您不能为此使用 DBMS_PIPE。它是一个 PL/SQL“东西”,而不是 RMAN 可以处理的东西,也不像 unix 管道到 STDIN 那样。

不过,您可以使用 DBMS_SCHEDULER 进行参数设置。您可能需要一个介入的 shell 脚本。

[额外]
我有一个带有一个或多个参数的 shell 脚本

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

shell 脚本将调用 RMAN 并通过 STDIN 将参数通过管道传递给它。

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.

洋洋洒洒 2024-08-21 19:47:51

看来我之前错了,RMAN可以与DBMS_PIPE一起使用。
文章此处。我自己不太明白,但博客上的评论可能会提供更多细节

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文