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 name=/opt/oracle/oradata/STAPLES/datafiledaimin01.dbf
input datafile fno=00001 name=/opt/oracle/oradata/STAPLES/datafile/o1_mf_system_40n25j1h_.dbf
input datafile fno=00003 name=/opt/oracle/oradata/STAPLES/datafile/o1_mf_sysaux_40n25j2m_.dbf
input datafile fno=00004 name=/opt/oracle/oradata/STAPLES/datafile/o1_mf_users_40n25j90_.dbf
input datafile fno=00002 name=/opt/oracle/oradata/STAPLES/datafile/o1_mf_undotbs1_40n25j77_.dbf
input datafile fno=00007 name=/opt/oracle/oradata/STAPLES/datafile/perfstat.dbf
input datafile fno=00005 name=/opt/oracle/oradata/STAPLES/datafile/MYDB
input datafile fno=00006 name=/opt/oracle/oradata/STAPLES/datafile/test02.dbf
input datafile fno=00009 name=/opt/oracle/oradata/STAPLES/datafile/block01.dbf
input datafile fno=00010 name=/opt/oracle/product/10.2.0/dbs/FOO
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 ~]$


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值