登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

飞哥的技术博客

世上无难事,只怕有心人!

 
 
 

日志

 
 
 
 

rman pipe的使用学习  

2009-06-23 20:17:49|  分类: Oracle |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

  rman pipe的使用学习收藏

 rman pipe的使用学习
学习参考:
http://yangtingkun.itpub.net/post/468/65127


1、创建管道
RMAN-00578: pipe string is not private and owned by SYS

Cause: The pipe that RMAN needs to use for its input or
output is either a public pipe or a private pipe that is not
owned by SYS. This is a potential security problem, because
it allows a non-SYS user to issue commands to RMAN or to
retrieve the RMAN output.

Action: If you are attempting to put data on the RMAN input
pipe prior to starting RMAN, so RMAN will process the data
on the pipe as soon as it starts, you must be connected as
SYS and you must first use the dbms_pipe.create_pipe
function to explicitely create the pipe as a private pipe.

Please add more information about this Error

解决:
应该在sys用户下创建sys用户私有的pipe
创建脚本如下:
SQL> connect sys/111111 as sysdba
Connected.
SQL> declare
  2    flag int;
  3  begin
  4    flag := dbms_pipe.create_pipe('P2', 8192, true);
  5    if flag = 0 then
  6      dbms_output.put_line('privite PIPE CREATE SUCCEED');
  7    end if;
  8  end;
  9  /
privite PIPE CREATE SUCCEED

2、以pipe方式启动rman如下:
[oracle@localhost ~]$ rman pipe P2 target sys/111111@STAPLES

Recovery Manager: Release 10.2.0.1.0 - Production on Mon Nov 10 10:43:16 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

3、然后执行下面的语句:
SQL> DECLARE
  2   V_INPUT VARCHAR2(32767) := 'SHOW ALL;';
  3   V_OUT NUMBER;
  4  BEGIN
  5   DBMS_PIPE.PACK_MESSAGE(V_INPUT);
  6   V_OUT := DBMS_PIPE.SEND_MESSAGE('ORA$RMAN_P2_IN');
  7   DBMS_OUTPUT.PUT_LINE(V_OUT);
  8   COMMIT;
  9   END;
 10  /
0

PL/SQL procedure successfully completed.

SQL> SET SERVEROUT ON SIZE 1000000
SQL>  DECLARE
  2   V_OUTPUT VARCHAR2(32767);
  3   V_OUT NUMBER := 0;
  4  BEGIN
  5   WHILE (V_OUT = 0) LOOP
  6   V_OUT := DBMS_PIPE.RECEIVE_MESSAGE('ORA$RMAN_P2_OUT', 5);
  7   IF V_OUT = 0 THEN
  8  DBMS_PIPE.UNPACK_MESSAGE(V_OUTPUT);
  9   DBMS_OUTPUT.PUT_LINE(V_OUTPUT);
 10   END IF;
 11   END LOOP;
 12   COMMIT;
 13   END;
 14  /
connected to target database: STAPLES (DBID=1268442274)
RMAN-00572: waiting for dbms_pipe input
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 300 M;
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF;
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/opt/oracle/product/10.2.0/dbs/snapcf_STAPLES.f'; # default
RMAN-00572: waiting for dbms_pipe input

PL/SQL procedure successfully completed.


4、通过DBMS_PIPE包就可以RMAN进行交互了,下面让RMAN执行数据库的全备:
SQL> DECLARE
  2  V_INPUT VARCHAR2(32767) := 'BACKUP DATABASE;';
  3  V_OUT NUMBER;
  4  BEGIN
  5  DBMS_PIPE.PACK_MESSAGE(V_INPUT);
  6  V_OUT := DBMS_PIPE.SEND_MESSAGE('ORA$RMAN_P2_IN');
  7  DBMS_OUTPUT.PUT_LINE(V_OUT);
  8  COMMIT;
  9  END;
 10  /
0
PL/SQL procedure successfully completed.
SQL>  DECLARE
  2   V_OUTPUT VARCHAR2(32767);
  3   V_OUT NUMBER := 0;
  4   BEGIN
  5   WHILE (V_OUT = 0) LOOP
  6   V_OUT := DBMS_PIPE.RECEIVE_MESSAGE('ORA$RMAN_P2_OUT', 5);
  7   IF V_OUT = 0 THEN
  8   DBMS_PIPE.UNPACK_MESSAGE(V_OUTPUT);
  9   DBMS_OUTPUT.PUT_LINE(V_OUTPUT);
 10   END IF;
 11   END LOOP;
 12   COMMIT;
 13   END;
 14  /
Starting backup at 10-NOV-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1624 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00008 >input datafile fno=00001 >input datafile fno=00003 >input datafile fno=00004 >input datafile fno=00002 >input datafile fno=00007 >input datafile fno=00005 >input datafile fno=00006 >input datafile fno=00009 >input datafile fno=00010 >channel ORA_DISK_1: starting piece 1 at 10-NOV-08
channel ORA_DISK_1: finished piece 1 at 10-NOV-08
piece handle=/opt/oracle/product/10.2.0/dbs/1gjvbgu5_1_1 tag=TAG20081110T111101 comment=NONE
channel ORA_DISK_1: starting piece 2 at 10-NOV-08

PL/SQL procedure successfully completed.

当备份结束后,可以通过DBMS_PIPE包结束RMAN命令:

SQL> DECLARE
  2  V_INPUT VARCHAR2(32767) := 'EXIT;';
  3  V_OUT NUMBER;
  4  BEGIN
  5  DBMS_PIPE.PACK_MESSAGE(V_INPUT);
  6  V_OUT := DBMS_PIPE.SEND_MESSAGE('ORA$RMAN_P2_IN');
  7  DBMS_OUTPUT.PUT_LINE(V_OUT);
  8  END;
  9  /
0

PL/SQL procedure successfully completed.

SQL> DECLARE
  2  V_OUTPUT VARCHAR2(32767);
  3  V_OUT NUMBER := 0;
  4  BEGIN
  5  WHILE (V_OUT = 0) LOOP
  6  V_OUT := DBMS_PIPE.RECEIVE_MESSAGE('ORA$RMAN_P2_OUT', 5);
  7  IF V_OUT = 0 THEN
  8  DBMS_PIPE.UNPACK_MESSAGE(V_OUTPUT);
  9  DBMS_OUTPUT.PUT_LINE(V_OUTPUT);
 10  END IF;
 11  END LOOP;
 12  COMMIT;
 13  END;
 14  /
channel ORA_DISK_1: finished piece 7 at 10-NOV-08
piece handle=/opt/oracle/product/10.2.0/dbs/1gjvbgu5_7_1 tag=TAG20081110T111101 comment=NONE
channel ORA_DISK_1: starting piece 8 at 10-NOV-08

PL/SQL procedure successfully completed.

查看rman窗口,启动的rman被关了,显示如下:
[oracle@localhost ~]$ rman pipe P2 target sys/111111@STAPLES

Recovery Manager: Release 10.2.0.1.0 - Production on Mon Nov 10 10:43:16 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

[oracle@localhost ~]$


  评论这张
 
阅读(528)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018