【RMAN】Run Allocate Channel For Maintenance From Script Fails

生产库的备库在做rman备份到磁带的时候,总是失败。
查找原因时发现:
crosscheck archivelog all;
delete noprompt expired archivelog all;
##allocate channel for maintenance type 'sbt_tape';
crosscheck backup;
crosscheck copy;
delete noprompt expired backup;
delete noprompt expired copy;
delete noprompt obsolete;

for maintenance 关键字在run{}中执行时会报错
下面介绍一下
ALLOCATE CHANNEL FOR MAINTENANCE命令。
ALLOCATE CHANNEL FOR MAINTENANCE命令是用来分配通道的,专用于CHANGE、DELETE、CROSSCHECK命令,并且也不需要(而且也不能)包含在RUN块中。
默认配置下CONFIGURE已经分配了一个指定 DISK 的通道,因此也可以不需要执行ALLOCATE CHANNEL FOR MAINTENANCE命令,Oracle也建议通过CONFIGURE分配通道,来替代使用该命令维护管理用的专用通道,这可能会增强备份脚本的复杂度。
=================================metalink 官方文档解释======================================
RMAN Run Allocate Channel For Maintenance From Script. Fails With Syntax Error [ID 224353.1]
fact: Oracle Server - Enterprise Edition
fact: Recovery Manager (RMAN)
symptom: Allocate Channel For Maintenance fails
symptom: RMAN-01005: syntax error: found "for": expecting one of: 
"channel_id, double-quoted-string, identifier, single-quoted-string"
symptom: RMAN-01007: at line %d column %d file: %s
symptom: allocate channel for maintenance type disk;
原因: Cannot Run RMAN Allocate Channel For Maintenance From An RMAN Script.
 Must Be Run Direct From The RMAN Prompt.
现象:
Running the following will fail.
RMAN> run {
3> allocate channel for maintenance type disk;
执行报错~~~!
解决:
Run direct from RMAN prompt.
RMAN> allocate channel for maintenance type disk;
RMAN> crosscheck backup of database;

=========================测试例子如下=====================
测试环境:
oracle版本:11.2.0.1.0
rman  版本:11.2.0.1.0
=========================二备库=======================
正确的方式:
RMAN> run {
2> allocate channel ch00 type 'SBT_TAPE';
3> RELEASE CHANNEL ch00;
4> }
allocated channel: ch00
channel ch00: SID=678 device type=SBT_TAPE
channel ch00: Veritas NetBackup for Oracle - Release 6.5 (2010042404)
released channel: ch00
RMAN> 
错误的方式:
RMAN> run {
2> allocate channel ch00 for maintenance type 'sbt_tape';

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "for": expecting one of: "device, type"
RMAN-01007: at line 2 column 23 file: standard input


=====================rac测试环境 =========================
--------------------下面是错误的例子-------------------------
RMAN> run {
2> allocate channel ch00 for maintenance type disk;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "for": expecting one of: "device, type"
RMAN-01007: at line 2 column 23 file: standard input

RMAN> run {
2> allocate channel ch00 for maintenance device type disk;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "for": expecting one of: "device, type"
RMAN-01007: at line 2 column 23 file: standard input

RMAN> run {
2> allocate channel ch00 for type disk;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "for": expecting one of: "device, type"
RMAN-01007: at line 2 column 23 file: standard input

RMAN> allocate channel ch00 device  type disk for maintenance;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: "for"
RMAN-01008: the bad identifier was: ch00
RMAN-01007: at line 1 column 18 file: standard input

RMAN> run {
2> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "for": expecting one of: "channel_id, double-quoted-string, identifier, single-quoted-string, "
RMAN-01007: at line 2 column 18 file: standard input

RMAN> run {
2> allocate channel ch00 device type disk ;
3> release channel;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found ";": expecting one of: "channel_id, double-quoted-string, identifier, single-quoted-string, "
RMAN-01007: at line 3 column 16 file: standard input
--------------------下面是正确的例子-------------------------
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
allocated channel: ORA_MAINT_DISK_1
channel ORA_MAINT_DISK_1: SID=963 instance=rac1 device type=DISK

RMAN> release channel;
released channel: ORA_MAINT_DISK_1


RMAN> run {
2> allocate channel ch00 device type disk ;
3> release channel ch00;
4> }
allocated channel: ch00
channel ch00: SID=963 instance=rac1 device type=DISK
released channel: ch00
RMAN> 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22664653/viewspace-706195/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/22664653/viewspace-706195/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值