[20161214]rman checksyntax.txt

[20161214]rman checksyntax.txt

--rman在命令行使用参数checksyntax可以检查命令语法是否正确,而且并不会真正执行.但是昨天在恢复一个10g的数据库时遇到问题,做
--一个记录:

1.环境:
--要恢复的数据库版本:
> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- ----------------------------------------------------------------
x86_64/Linux 2.4.xx            10.2.0.4.0     Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

2.建立脚本
$ cat reco.rman
run
{
set until time '2016-12-03 04:00:00';
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
restore database;
recover database;
release channel c1;
release channel c2;
release channel c3;
}

3.测试:
$ rlrman checksyntax
Recovery Manager: Release 10.2.0.4.0 - Production on Wed Dec 14 10:51:12 2016
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
connected to target database: STATISTI (DBID=3581654166)

RMAN> @ reco.rman
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: "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-01008: the bad identifier was: reco
RMAN-01007: at line 1 column 2 file: standard input

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "dot": 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 1 column 6 file: standard input

--//如果仔细看报错信息,RMAN-01008: the bad identifier was: reco,昨天学习如何看这种错误,采用从底向上的方式查看.
--//于是采用copy&paste的方式检查发现没有错误,难道10g支持脚本这样的检查方式吗?于是我取消@与reco.rman之间的空格(在这步我浪
--//费大量的时间):

RMAN> @reco.rman
RMAN> run
2> {
3> set until time '2016-12-03 04:00:00';
4> allocate channel c1 type disk;
5> allocate channel c2 type disk;
6> allocate channel c3 type disk;
7> restore database;
8> recover database;
9> release channel c1;
10> release channel c2;
11> release channel c3;
12> }
The cmdfile has no syntax errors
RMAN> **end-of-file**

--Ok,原来这样的检查方式不能在@与脚本文件之间存在空格.另外如果真正执行也是一样,不能在@与脚本文件之间存在空格.大家可以自行测试.

4.继续测试在11g的情况.
SYS@book> @ &r/ver1

PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

$ rlrman checksyntax
Recovery Manager: Release 11.2.0.4.0 - Production on Wed Dec 14 11:02:24 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: BOOK (DBID=1337401710)

RMAN> @ reco.rman
RMAN> run
2> {
3> set until time '2016-12-03 04:00:00';
4> allocate channel c1 type disk;
5> allocate channel c2 type disk;
6> allocate channel c3 type disk;
7> restore database;
8> recover database;
9> release channel c1;
10> release channel c2;
11> release channel c3;
12> }
The cmdfile has no syntax errors
RMAN> **end-of-file**

RMAN> @reco.rman
RMAN> run
2> {
3> set until time '2016-12-03 04:00:00';
4> allocate channel c1 type disk;
5> allocate channel c2 type disk;
6> allocate channel c3 type disk;
7> restore database;
8> recover database;
9> release channel c1;
10> release channel c2;
11> release channel c3;
12> }
The cmdfile has no syntax errors
RMAN> **end-of-file**

--//很明显11g已经修复了这个bug,可以在@与脚本文件加入空格.这个错误我浪费了1个多小时,晚下班半个小时,oracle真是处处是陷阱.

5.补充在10g的测试:
$ rlrman
run
{
  allocate channel c1 device type DISK;
  allocate channel c2 device type DISK;
  #list backup summary;
  release channel c1;
  release channel c2;
}

RMAN> @ r.rman
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: "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-01008: the bad identifier was: r
RMAN-01007: at line 1 column 2 file: standard input

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "dot": 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 1 column 3 file: standard input

RMAN> @r.rman
RMAN> run
2> {
3>   allocate channel c1 device type DISK;
4>   allocate channel c2 device type DISK;
5> #   list backup summary;
6>   release channel c1;
7>   release channel c2;
8> }
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=484 devtype=DISK

allocated channel: c2
channel c2: sid=483 devtype=DISK

released channel: c1

released channel: c2

RMAN> **end-of-file**

--//以后注意10g,rman下脚本执行时@与脚本文件之间不能带空格.
--//另外大家可以看看我以前写的blog http://blog.itpub.net/267265/viewspace-1988542/=> [20160214]rman执行脚本注解问题.txt
--//实际上这个问题再次体现一点,认真看出错信息很重要.我当时就是心里太浮躁.....

时间: 2024-10-11 00:28:06

[20161214]rman checksyntax.txt的相关文章

[20161230]rman checksyntax2.txt

[20161230]rman checksyntax2.txt --曾经写过一篇rman checksyntax的问题,这个问题存在10g: http://blog.itpub.net/267265/viewspace-2130511/ --今天看了一个链接重复测试:https://jhdba.wordpress.com/2016/12/29/rman-checksyntax-function/#comment-11009 1.环境: SYS@book> @ &r/ver1 PORT_STR

[20170208]rman tape.txt

[20170208]rman tape.txt --前一阵子,同事测试使用磁带做rman备份,留下一些备份信息在控制文件,要清除. --我依稀记得我以前也干过这些事情,晚上看了一下书: Apress.RMAN.Recipes.for.Oracle.Database.12c.2nd.Edition.Jul.2013.pdf Allocating an RMAN Maintenance Channel P145 Suppose your current backup strategy uses on

[20171122]rman filesystemio_options.txt

[20171122]rman备份与参数filesystemio_options设置.txt --//这几天写了几篇filesystemio_options参数设置的文章,单独测试这个参数对rman备份以及os缓存的影响. 1.测试环境: SYS@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------------- ----------

[20161214]如何确定dbid.txt

[20161214]如何确定dbid.txt --如何确定数据库的dbid,我曾经写过一篇blog,链接:http://blog.itpub.net/267265/viewspace-2125849/ --实际上还有1种非常武断的方法,直接使用strings扫sysaux表空间对应的数据文件,就可以知道: 例子如下: SYS@book> @&r/ver1 PORT_STRING                    VERSION        BANNER ----------------

[20161101]rman备份与数据文件变化7.txt

[20161101]rman备份与数据文件变化7.txt --//想象一下,如果备份文件时间很长,而这个时候数据文件大小发生了变化,oracle的备份如何解决这个问题呢? --//去年已经测试了建立备份集的情况,一直想做一次image copy的测试,一直脱,主要原因自己不想做这个测试.... --//而且当时的测试很乱,自己主要一边做一边想.... --//链接: http://blog.itpub.net/267265/viewspace-2127386/ http://blog.itpub

[20171121]rman使用copy image恢复.txt

[20171121]rman使用copy image恢复.txt --//上个星期做数据文件块头恢复时,提到使用rman备份数据文件时,文件头数据库信息是最后写入备份集文件的,在filesperset=1的情况 --//下写入备份集文件中的倒数第2块就是文件头的备份.参考链接: http://blog.itpub.net/267265/viewspace-2147297/=>[20171115]恢复数据文件块头4补充.txt --//而且我最后还做了测试证明如果resotre数据文件,实际上文件

[20171121]rman backup as copy.txt

[20171121]rman backup as copy.txt --//上个星期做数据文件块头恢复时,提到使用rman备份数据文件时,文件头数据库信息是最后写入备份集文件的,在filesperset=1的情况 --//下写入备份集文件中的倒数第2块就是文件头的备份.参考链接: http://blog.itpub.net/267265/viewspace-2147297/=>[20171115]恢复数据文件块头4补充.txt --//而且我最后还做了测试证明如果resotre数据文件,实际上文

[20171130]关于rman的一些总结.txt

[20171130]关于rman的一些总结.txt --//最近一直做rman相关测试,测试那个乱,没办法.无法从周围的人获得帮助,纯粹是自己的乱猜,乱测,不知道别人是否能看懂我写的东西. --//有必要做一些总结,不一定对,仅仅是我当前的看法. 1.数据文件备份集中,文件头是最后写到备份集文件的. 2.使用备份集恢复也是一样,文件头也是最好写入的. 3.以上情况对as copy的方式也是一样. --//oracle这样操作主要目的保证备份是好的可用,反之恢复也是一样. 4.关于备份参数file

[20171128]rman Input or output Memory Buffers.txt

[20171128]rman Input or output Memory Buffers.txt --//Input Memory Buffers如何测试,不清楚.不过找到一本电子书.摘要如下: Oracle RMAN 11g Backup and Recovery.pdf 作者:Robert G. Freeman Matthew Hart 页数:689 出版社:Mc graw hill 出版号: ISBN: 978-0-07-162861-7         MHID: 0-07-16286