【RMAN】Run Allocate Channel For Maintenance From Script Fails

楊奇龍發表於2011-08-30
生產庫的備庫在做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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章