Chip 发表于 2014-1-14 17:20:53

“RMAN脚本中使用替换变量”的其他可选方案

需要对RMAN脚本使用变量,参数从OS传入RMAN Script。看过Maclean大的文章,http://www.askmaclean.com/archives/%E4%BD%BF%E7%94%A8oracle-rman%E8%84%9A%E6%9C%AC.html

可是,这个特性应该是11g独有。在10g中使用,错误如下

$rman   

Recovery Manager: Release 10.2.0.4.0 - Production on ÐÇÆÚ¶þ 1ÔÂ 14 17:05:15 2014

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

RMAN> @restore_ctl.rman 2814259363

RMAN> connect target *
connected to target database: GISDBSP (not mounted)

RMAN> connect catalog *
connected to recovery catalog database

RMAN> run {
2> allocate channel ch00 device type 'sbt_tape';
3> send 'NB_ORA_CLIENT=GISDBSP';
4> set until scn &
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "atsign": expecting one of: "equal, integer"
RMAN-01007: at line 6 column 15 file: restore_ctl.rman

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "integer": expecting one of: "allocate, alter, backup, beginline, blockrecover, catalog, change, connect, copy, convert, create, crosscheck, configure, duplicate, debug, delete, drop, exit, endinline, flashback, host, {, library, list, mount, open, print, quit, recover, register, release, replace, report, renormalize, reset, restore, resync, rman, run, rpctest, set, setlimit, sql, switch, spool, startup, shutdown, send, show, test, transport, upgrade, unregister, validate"
RMAN-01007: at line 0 column 2 file: standard input

使用到的脚本restore_ctl.rman内容如下connect target /
connect catalog rman/rman@RCATDG
run {
allocate channel ch00 device type 'sbt_tape';
send 'NB_ORA_CLIENT=GISDBSP';
set until scn &1;
restore controlfile;
release channel ch00;
}

Liu Maclean(刘相兵 发表于 2014-1-14 20:39:51

10g 是不行的, 无需纠结了

Chip 发表于 2014-1-15 17:04:46

Liu Maclean(刘相兵 发表于 2014-1-14 20:39 static/image/common/back.gif
10g 是不行的, 无需纠结了

是的,查了文档,的确只有11g有

最后,曲线救国,用SHELL脚本来解决。

方案如下CUR_SCN=`tail -10 /usr/openv/script/SCN.log |sed -n '2p'`

# Prepare RMAN restore script
cat > /oracle/p2d/bin/restore_ctl.rman <<EOF
connect target /
connect catalog rman/rman@RCAT
run {
allocate channel ch00 device type 'sbt_tape';
send 'NB_ORA_CLIENT=GISDBSP';
set until scn $CUR_SCN;
restore controlfile;
release channel ch00;
}
EOF
页: [1]
查看完整版本: “RMAN脚本中使用替换变量”的其他可选方案