首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RMAN复制- Oracle数据保护-语法错误(S) RMAN-01009 / RMAN-01008 / RMAN-01007

RMAN复制- Oracle数据保护-语法错误(S) RMAN-01009 / RMAN-01008 / RMAN-01007
EN

Database Administration用户
提问于 2019-03-07 09:45:32
回答 1查看 3.8K关注 0票数 0

新的到DB。对Oracle数据保护感兴趣。与RMAN合作的新工作。

所有这些仅用于测试,不涉及任何类型的生产env。

利用ORACLE文档:

  • 使用RMAN DUPLICATE...FROM活动数据库创建物理备用的逐步指南(Doc 1075908.1)

。.==========================================================================.。

The主数据库:

代码语言:javascript
复制
[oracle@ol12c pridb]$ env | grep ORA
ORACLE_UNQNAME=cdb1
ORACLE_SID=pridb
ORACLE_BASE=/u01/app/oracle
ORACLE_HOSTNAME=ol12c.localdomain
ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/db_1

SQL> startup pfile=/u01/app/oracle/product/12.1.0.2/db_1/dbs/initpridb.ora;

SQL> show parameter db_recovery_file_dest
NAME                     TYPE    VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest            string  /u01/app/oracle/fast_recovery_
                         area
db_recovery_file_dest_size       big integer 2G

SQL> archive log list
Database log mode          Archive Mode
Automatic archival         Enabled
Archive destination        USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     12
Next log sequence to archive   13
Current log sequence           13

。.==========================================================================.。

2.待机:

代码语言:javascript
复制
[oracle@ol12c stbdb]$ env | grep ORA
ORACLE_UNQNAME=cdb1
ORACLE_SID=stbdb
ORACLE_BASE=/u01/app/oracle
ORACLE_HOSTNAME=ol12c.localdomain
ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/db_1

SQL> startup nomount pfile='/u01/app/oracle/product/12.1.0.2/db_1/dbs/initstbdb.ora'

SQL> show parameter db_recovery_file_dest

NAME                     TYPE    VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest            string  /u01/app/oracle/fast_recovery_
                         area/stbdb
db_recovery_file_dest_size       big integer 2G

。.==========================================================================.。

3. RMAN (在主db上):

代码语言:javascript
复制
[oracle@ol12c pridb]$ rman

RMAN> connect target sys/oracle@pridb
connected to target database: PRIDB (DBID=1212094364)

RMAN> connect auxiliary sys/oracle@stbdb
connected to auxiliary database: PRIDB (not mounted)

。.==========================================================================.。

4.错误:

代码语言:javascript
复制
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "db_unique_name": expecting one of: "archivelog, autobackup, auxiliary, auxname, backup, catalog, command, compression, controlfile, database, dbid, decryption, default, echo, encryption, high, incarnation, incremental, long, maxcorrupt, maxseq, newname, nocfau, numwidth, restore, snapshot, to restore point, until restore point, until, "
RMAN-01007: at line 1 column 1 file: standard input

代码语言:javascript
复制
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: "archivelog, autobackup, auxiliary, auxname, backup, catalog, command, compression, controlfile, database, dbid, decryption, default, echo, encryption, high, incarnation, incremental, long, maxcorrupt, maxseq, newname, nocfau, numwidth, restore, snapshot, to restore point, until restore point, until, "
RMAN-01008: the bad identifier was: log_archive_dest_2
RMAN-01007: at line 1 column 7 file: standard input

从log_file_name_convert开始,我收到命令中指定的所有参数的<>RMAN-01008错误。

。.==========================================================================.。

5.我的输入:

代码语言:javascript
复制
run 
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate auxiliary channel aux type disk;
duplicate target database for standby from active database 
  parameter_value_convert'pridb','stbdb'
  set db_unique_name='stbdb'
  set db_file_name_convert='pridb','stbdb'
  set log_file_name_convert='pridb','stbdb'
  set control_files='/u01/app/oracle/oradata/stbdb/stbdb_control1.ctl'
  set standby_file_management='AUTO'
  set log_archive_max_processes='10'
  set fal_client='stbdb'
  set fal_server='pridb'
  set standby_file_management='AUTO'
  set log_archive_config='dg_config=(pridb,stbdb)'
  set log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=stbdb'
  set log_archive_dest_2='service=testdb ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=stbdb'
;
}

首先我得到了:

RMAN-05557:未用服务器参数文件启动的目标实例

因为我正在尝试:duplicate target database for standby from active database spfile和我不是从spfile开始,而是直接从pfile开始。

根据我的研究,我应该能够不指定SPfile:

因此,我从duplicate target database for standby from active database spfile更改为duplicate target database for standby from active database,应该像我检查的链接中提到的那样工作。

->但我现在要更新哪些参数呢?对我来说,这似乎不合逻辑。。

上面的代码在分配通道时成功地运行了一次,但随后停止并开始抛出错误。

目前,我正在运行rman checksyntax中的脚本,以确保我没有破坏任何东西。:)

。.==========================================================================.。

你能帮帮我吗?

  • 我试着更好地理解瑞曼。
  • 找出在上述情况下我做错了什么。(+为什么!)

我更感兴趣的是了解正在发生的事情等,而不是让这个工作迅速。

(尽管它很有用!:)现在的目的是学习。

预先为您的帮助Thank!

。.==========================================================================.。

解决方案

需要一个SPFILE

在主数据库上:

代码语言:javascript
复制
SQL> create spfile from     pfile='/u01/app/oracle/product/12.1.0.2/db_1/dbs/initpridb.ora';
File created.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup;
ORACLE instance started.

Total System Global Area 1073741824 bytes
Fixed Size          2932632 bytes
Variable Size         671088744 bytes
Database Buffers      394264576 bytes
Redo Buffers            5455872 bytes
Database mounted.
Database opened.

然后启动RMAN并运行脚本,就像我们说的那样!:) - YEY!

以下错误:

RMAN-05537:在使用spfile启动辅助实例时没有目标连接的重复不能使用SPFILE子句。

通过更新脚本值&重新连接dbs来解决问题。

使用的最终脚本:

代码语言:javascript
复制
RMAN> run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate auxiliary channel aux type disk;
duplicate target database for standby from active database 
spfile
  parameter_value_convert'pridb','stbdb'
  set db_unique_name='stbdb'
  set db_file_name_convert='/u01/app/oracle/oradata/pridb/PRIDB/datafile/','/u01/app/oracle/oradata/stbdb/STBDB/datafile/'
  set log_file_name_convert='/u01/app/oracle/oradata/pridb/PRIDB/onlinelog/','/u01/app/oracle/oradata/stbdb/STBDB/onlinelog/'
  set control_files='/u01/app/oracle/oradata/stbdb/stbdb_control1.ctl'
  set standby_file_management='AUTO'
  set log_archive_max_processes='10'
  set fal_client='stbdb'
  set fal_server='pridb'
  set standby_file_management='AUTO'
  set log_archive_config='dg_config=(pridb,stbdb)'
  set log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=stbdb'
  set log_archive_dest_2='service=testdb ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=stbdb'
;
}
EN

回答 1

Database Administration用户

回答已采纳

发布于 2019-03-07 09:57:33

没有parameter_value_convert就不能使用spfile

复本

<#>dupOptionList::=

主数据库是用spfile启动的:

代码语言:javascript
复制
[oracle@o71 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Thu Mar 7 11:41:46 2019

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/12.1.0
                                                 /dbhome_1/dbs/spfilepridb.ora
SQL>

待机状态从pfile启动:

代码语言:javascript
复制
[oracle@o72 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Thu Mar 7 11:39:23 2019

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

Connected to an idle instance.

SQL> startup nomount pfile='/tmp/pf.ora';
ORACLE instance started.

Total System Global Area 1073741824 bytes
Fixed Size                  2932632 bytes
Variable Size             402653288 bytes
Database Buffers          662700032 bytes
Redo Buffers                5455872 bytes
SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
[oracle@o72 ~]$

重复:

代码语言:javascript
复制
[oracle@o71 ~]$ rman target sys/Oracle123@\'o71:1521/pridb\' auxiliary sys/Oracle123@\'o72:1521/stbdb\'

Recovery Manager: Release 12.1.0.2.0 - Production on Thu Mar 7 11:39:45 2019

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PRIDB (DBID=1212244976)
connected to auxiliary database: PRIDB (not mounted)

RMAN> run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate auxiliary channel aux type disk;
duplicate target database for standby from active database
  spfile parameter_value_convert'pridb','stbdb'
  set db_unique_name='ic_stb'
  set db_file_name_convert='pridb','stbdb'
  set log_file_name_convert='pridb','stbdb'
  set control_files='/oradata/stbdb/control01.ctl', '/oradata/stbdb/control02.ctl'
  set standby_file_management='AUTO'
  set log_archive_max_processes='10'
  set fal_client='stbdb'
  set fal_server='pridb'
  set standby_file_management='AUTO'
  set log_archive_config='dg_config=(pridb,stbdb)'
  set log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=stbdb'
  set log_archive_dest_2='service=testdb ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=stbdb'
;
23> }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=247 device type=DISK

allocated channel: c2
channel c2: SID=401 device type=DISK

allocated channel: c3
channel c3: SID=5 device type=DISK

allocated channel: c4
channel c4: SID=88 device type=DISK

allocated channel: aux
channel aux: SID=83 device type=DISK

Starting Duplicate Db at 07-MAR-19

contents of Memory Script:
{
   backup as copy reuse
   targetfile  '/u01/app/oracle/product/12.1.0/dbhome_1/dbs/orapwpridb' auxiliary format
 '/u01/app/oracle/product/12.1.0/dbhome_1/dbs/orapwstbdb'   targetfile
 '/u01/app/oracle/product/12.1.0/dbhome_1/dbs/spfilepridb.ora' auxiliary format
 '/u01/app/oracle/product/12.1.0/dbhome_1/dbs/spfilestbdb.ora'   ;
   sql clone "alter system set spfile= ''/u01/app/oracle/product/12.1.0/dbhome_1/dbs/spfilestbdb.ora''";
}
executing Memory Script

Starting backup at 07-MAR-19
Finished backup at 07-MAR-19

sql statement: alter system set spfile= ''/u01/app/oracle/product/12.1.0/dbhome_1/dbs/spfilestbdb.ora''

contents of Memory Script:
{
   sql clone "alter system set  audit_file_dest =
 ''/u01/app/oracle/admin/stbdb/adump'' comment=
 '''' scope=spfile";
   sql clone "alter system set  dispatchers =
 ''(PROTOCOL=TCP) (SERVICE=stbdbXDB)'' comment=
 '''' scope=spfile";
   sql clone "alter system set  db_unique_name =
 ''ic_stb'' comment=
 '''' scope=spfile";
   sql clone "alter system set  db_file_name_convert =
 ''pridb'', ''stbdb'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_file_name_convert =
 ''pridb'', ''stbdb'' comment=
 '''' scope=spfile";
   sql clone "alter system set  control_files =
 ''/oradata/stbdb/control01.ctl'', ''/oradata/stbdb/control02.ctl'' comment=
 '''' scope=spfile";
   sql clone "alter system set  standby_file_management =
 ''AUTO'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_archive_max_processes =
 10 comment=
 '''' scope=spfile";
   sql clone "alter system set  fal_client =
 ''stbdb'' comment=
 '''' scope=spfile";
   sql clone "alter system set  fal_server =
 ''pridb'' comment=
 '''' scope=spfile";
   sql clone "alter system set  standby_file_management =
 ''AUTO'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_archive_config =
 ''dg_config=(pridb,stbdb)'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_archive_dest_1 =
 ''location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=stbdb'' comment=
 '''' scope=spfile";
   sql clone "alter system set  log_archive_dest_2 =
 ''service=testdb ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=stbdb'' comment=
 '''' scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

sql statement: alter system set  audit_file_dest =  ''/u01/app/oracle/admin/stbdb/adump'' comment= '''' scope=spfile

sql statement: alter system set  dispatchers =  ''(PROTOCOL=TCP) (SERVICE=stbdbXDB)'' comment= '''' scope=spfile

sql statement: alter system set  db_unique_name =  ''ic_stb'' comment= '''' scope=spfile

sql statement: alter system set  db_file_name_convert =  ''pridb'', ''stbdb'' comment= '''' scope=spfile

sql statement: alter system set  log_file_name_convert =  ''pridb'', ''stbdb'' comment= '''' scope=spfile

sql statement: alter system set  control_files =  ''/oradata/stbdb/control01.ctl'', ''/oradata/stbdb/control02.ctl'' comment= '''' scope=spfile

sql statement: alter system set  standby_file_management =  ''AUTO'' comment= '''' scope=spfile

sql statement: alter system set  log_archive_max_processes =  10 comment= '''' scope=spfile

sql statement: alter system set  fal_client =  ''stbdb'' comment= '''' scope=spfile

sql statement: alter system set  fal_server =  ''pridb'' comment= '''' scope=spfile

sql statement: alter system set  standby_file_management =  ''AUTO'' comment= '''' scope=spfile

sql statement: alter system set  log_archive_config =  ''dg_config=(pridb,stbdb)'' comment= '''' scope=spfile

sql statement: alter system set  log_archive_dest_1 =  ''location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=stbdb'' comment= '''' scope=spfile

sql statement: alter system set  log_archive_dest_2 =  ''service=testdb ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=stbdb'' comment= '''' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1073741824 bytes

Fixed Size                     2932632 bytes
Variable Size                402653288 bytes
Database Buffers             662700032 bytes
Redo Buffers                   5455872 bytes
allocated channel: aux
channel aux: SID=163 device type=DISK

contents of Memory Script:
{
   backup as copy current controlfile for standby auxiliary format  '/oradata/stbdb/control01.ctl';
   restore clone primary controlfile to  '/oradata/stbdb/control02.ctl' from
 '/oradata/stbdb/control01.ctl';
}
executing Memory Script

Starting backup at 07-MAR-19
channel c1: starting datafile copy
copying standby control file
output file name=/u01/app/oracle/product/12.1.0/dbhome_1/dbs/snapcf_pridb.f tag=TAG20190307T114117
channel c1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 07-MAR-19

Starting restore at 07-MAR-19

channel aux: copied control file copy
Finished restore at 07-MAR-19

contents of Memory Script:
{
   sql clone 'alter database mount standby database';
}
executing Memory Script

sql statement: alter database mount standby database

contents of Memory Script:
{
   set newname for tempfile  1 to
 "/oradata/stbdb/temp01.dbf";
   switch clone tempfile all;
   set newname for datafile  1 to
 "/oradata/stbdb/system01.dbf";
   set newname for datafile  3 to
 "/oradata/stbdb/sysaux01.dbf";
   set newname for datafile  4 to
 "/oradata/stbdb/undotbs01.dbf";
   set newname for datafile  6 to
 "/oradata/stbdb/users01.dbf";
   backup as copy reuse
   datafile  1 auxiliary format
 "/oradata/stbdb/system01.dbf"   datafile
 3 auxiliary format
 "/oradata/stbdb/sysaux01.dbf"   datafile
 4 auxiliary format
 "/oradata/stbdb/undotbs01.dbf"   datafile
 6 auxiliary format
 "/oradata/stbdb/users01.dbf"   ;
   sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /oradata/stbdb/temp01.dbf in control file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting backup at 07-MAR-19
channel c1: starting datafile copy
input datafile file number=00001 name=/oradata/pridb/system01.dbf
channel c2: starting datafile copy
input datafile file number=00003 name=/oradata/pridb/sysaux01.dbf
channel c3: starting datafile copy
input datafile file number=00004 name=/oradata/pridb/undotbs01.dbf
channel c4: starting datafile copy
input datafile file number=00006 name=/oradata/pridb/users01.dbf
output file name=/oradata/stbdb/system01.dbf tag=TAG20190307T114124
channel c1: datafile copy complete, elapsed time: 00:00:01
output file name=/oradata/stbdb/sysaux01.dbf tag=TAG20190307T114124
channel c2: datafile copy complete, elapsed time: 00:00:01
output file name=/oradata/stbdb/undotbs01.dbf tag=TAG20190307T114124
channel c3: datafile copy complete, elapsed time: 00:00:01
output file name=/oradata/stbdb/users01.dbf tag=TAG20190307T114124
channel c4: datafile copy complete, elapsed time: 00:00:01
Finished backup at 07-MAR-19

sql statement: alter system archive log current

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=1 STAMP=1002282086 file name=/oradata/stbdb/system01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=1002282086 file name=/oradata/stbdb/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=1002282086 file name=/oradata/stbdb/undotbs01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=4 STAMP=1002282086 file name=/oradata/stbdb/users01.dbf
Finished Duplicate Db at 07-MAR-19
released channel: c1
released channel: c2
released channel: c3
released channel: c4
released channel: aux

RMAN>

您的主服务器应该使用spfile。

票数 0
EN
页面原文内容由Database Administration提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://dba.stackexchange.com/questions/231543

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档