目标端启动静态监听(源端的tns中关于目标端配置,增加(UR=A)是无效的,因为duplicate过程中会关闭再启动目标端,关闭的过程中目标端的监听不再有了,这样源端连接不到目标端,无法再启动目标端),目标端实例启动到nomount状态
Duplicate命令RMAN 自动执行下列步骤:
1.为副本数据库创建控制文件(所以源端和目标端的db_name可以不一样,比如源端为A,duplicate到目标端为B)。
2.Restore 数据文件到副本数据库,并通过增量备份和Archived Redo Logs 进行不完全恢复。
3.重启辅助实例,以加载服务器初始化参数文件即SPFILE。
4.不完全恢复后通过Resetlogs 方式Open 副本数据库以重建Online Redo Logs(Duplicate ... ForStandby 方式除外,该操作不会打开数据库)。
5.为副本数据库产生一个新的,唯一的DBID(Duplicate ... For Standby 方式除外,该方式不会创建新的唯一DBID)。
duplicate target database to NPS使用源库的备份文件来对目标库做复制
此时目标库必须能访问到源端的备份包(可以把主库备份文件拷贝至备库,或主备共用存储,备份包一份,但是再主备都是一样的存储路径),否则在主库执行duplicate时会报错说找不到备份包
比如没有传输controlfile备份包,则报找不到控制文件备份无法restore controlfile
比如没有传输datafile备份包,则报找不到控制文件备份无法restore datafile
使用备份包即不使用from active时,必须使用密码连接目标端,如下
rman target / auxiliary sys/lf0320tcsge@WFTST
duplicate target database to NPS from active database使用源库在线数据来对目标库做复制
使用from atcive database时,必须使用密码连接源端和目标端,如下
rman target sys/lf0320tcsge@WF auxiliary sys/lf0320tcsge@WFTST
When you execute DUPLICATE with FROM ACTIVE DATABASE
When you connect RMAN to the source database as TARGET, you must specify a password, even if RMAN uses operating system authentication. The source database must be mounted or open. If the source database is open, then archiving must be enabled. If the source database is not open, then it must have been shut down consistently.
当您使用FROM ACTIVE DATABASE执行DUPLICATE时
将RMAN连接到源数据库作为TARGET时,即使RMAN使用操作系统身份验证,也必须指定密码。 源数据库必须被安装或打开。 如果源数据库是打开的,则必须启用归档。 如果源数据库未打开,则必须一直关闭源数据库。
参数DB_FILE_NAME_CONVERT 和 LOGFILE和LOG_FILE_NAME_CONVERT
db_file_name_convert参数仅适用于physical standby和rman duplicate,对logical standby和普通rman restore无效;
log_file_name_convert适用于physical standby和rman duplicate,但是不能用于rman duplicate的run命令中,存在duplicate目标端的spfile文件中,所以一般在duplicate中加参数logfile
DB_FILE_NAME_CONVERT set on the DUPLICATE command overrides the initialization parameter DB_FILE_NAME_CONVERT (if set). For example, if the initialization parameter file setting is DB_FILE_NAME_CONVERT=('disk1','disk2'), but you execute DUPLICATE ... DB_FILE_NAME_CONVERT ('disk1','disk3'), then RMAN does not convert the disk1 substring to disk2. Instead, RMAN converts the disk1 substring to disk3.
在DUPLICATE命令上设置的DB_FILE_NAME_CONVERT将覆盖初始化参数DB_FILE_NAME_CONVERT(如果已设置)。 例如,如果初始化参数文件设置为DB_FILE_NAME_CONVERT =('disk1','disk2'),但是您执行DUPLICATE ... DB_FILE_NAME_CONVERT('disk1','disk3'),则RMAN不会将disk1子字符串转换为disk2。 相反,RMAN将disk1子字符串转换为disk3。
LOGFILE:Specifies options for creating online redo logs when creating a duplicate database that is not a standby database
If you do not specify LOGFILE, then RMAN first checks if any of the following initialization parameters are set: LOG_FILE_NAME_CONVERT,DB_CREATE_FILE_DEST, DB_RECOVERY_FILE_DEST or DB_CREATE_ONLINE_LOG_DEST_n. If these parameters are set, RMAN directs duplicate database online redo log files to Oracle managed storage based on these parameter settings. If none of these initialization parameters are set, then RMAN uses the original redo log file names of the source database for redo log files of the duplicate database. You must specify the NOFILENAMECHECK option in this case.
you do not set DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT because you are specifying names for data files and online logs in the RUN command itself
LOGFILE:指定在创建不是standby数据库的duplicate数据库时创建联机重做日志的选项
如果不指定LOGFILE,则RMAN首先检查是否设置了以下任何初始化参数:LOG_FILE_NAME_CONVERT,DB_CREATE_FILE_DEST,DB_RECOVERY_FILE_DEST或DB_CREATE_ONLINE_LOG_DEST_n。 如果设置了这些参数,RMAN将根据这些参数设置将duplicate的数据库联机重做日志文件到oracle的存储。 如果没有设置这些初始化参数,则RMAN会使用源数据库的原始重做日志文件名作为重复数据库的重做日志文件。 在这种情况下,您必须指定NOFILENAMECHECK选项。
当您在RUN命令本身中指定数据文件和联机日志的名称,您不要设置DB_FILE_NAME_CONVERT和LOG_FILE_NAME_CONVERT参数
参数PFILE
duplicate中参数pfile表示源端使用这个pfile来启动目标端(一般是从目标端拷贝到源端来,pfile=/源端路径/XX.ora)
没有pfile这个选项时,表示源端直接加载目标端的spfile来启动目标端
所有如果目标端没有spfile,而duplicate中又没有加pfile的选项,则源端会加载目标端一个虚拟的spfile,但是这个spfile实际又不存在(实验过,目标端show parameter spfile时有一个spfile,但是这个spfile并不实际存在)
Specifies a text-based initialization parameter file used by the auxiliary instance. RMAN automatically shuts down and restarts the auxiliary instance during duplication. If the auxiliary does not use a server parameter file in the default location, then you must specify the text-based initialization parameter file that RMAN should use when starting the auxiliary instance. The initialization parameter file must reside on the same host as the RMAN client used to perform the duplication.
If the auxiliary instance uses a server parameter file in the default location, then you do not need to specify PFILE.
指定辅助实例使用的pfile。 RMAN会在duplicate时自动关闭并重新启动辅助实例。 如果辅助程序在默认位置不使用服务器参数文件,则必须指定启动辅助实例时RMAN应使用的pfile。 pfile必须位于与用于执行重复的RMAN客户机相同的主机上。(如果rman在源端开启,则pfile放在源端上,如果ramn在目标端开启,则pfile放在目标端上)。如果辅助实例在默认位置使用服务器参数文件,则不需要指定PFILE。
参数NOFILENAMECHECK
Prevents RMAN from checking whether the data files and online redo logs files of the source database are in use when the source database files share the same names as the duplicate database files. You are responsible for determining that the duplicate operation does not overwrite useful data.
This option is necessary when you are creating a duplicate database in a different host that has the same disk configuration, directory structure, and file names as the host of the source database. For example, assume that you have a small database located in the /dbs directory of srchost:
/oracle/dbs/system_prod1.dbf
/oracle/dbs/users_prod1.dbf
/oracle/dbs/rbs_prod1.dbf
Assume that you want to duplicate this database to desthost, which has the same file system /oracle/dbs/*, and you want to use the same file names in the duplicate database as in the source database. In this case, specify the NOFILENAMECHECK option to avoid an error message. Because RMAN is not aware of the different hosts, RMAN cannot determine automatically that it should not check the file names.
当源数据库文件与duplicate的数据库文件使用相同的名称时,防止RMAN检查源数据库的数据文件和联机重做日志文件是否正在使用。 您有责任确定duplicate操作不会覆盖源端在用的数据。
在与源数据库的主机具有相同磁盘配置,目录结构和文件名的不同主机中创建重复数据库时,此选项是必需的。 例如,假设您在srchost的/dbs目录中有一个小数据库:
/oracle/dbs/system_prod1.dbf
/oracle/dbs/users_prod1.dbf
/oracle/dbs/rbs_prod1.dbf
假设您要将此数据库复制到目标端,目标端和源端一样具有相同文件系统/oracle/dbs/*,并且要在目标端数据库中的使用和源端相同文件名。 在这种情况下,请指定NOFILENAMECHECK选项以避免出现错误消息。 因为RMAN不知道不同的主机,RMAN无法自动确定不应该检查文件名。
一些duplicate的语法如下
nohup rman target sys/123@WF auxiliary sys/123@WFTST cmdfile=duplicateWF_WFTST.rman msglog=duplicateWF_WFTST.log &
run {
duplicate database PROD incarnation 4 to DEV
pfile=/ebsbak/rmanbackup/duplicate/initDEV.ora
db_file_name_convert=('/db/prod/db/apps_st/','/u01/DEV/db/apps_st/')
LOGFILE
'/u01/DEV/db/apps_st/data/log01.dbf' size 1024M,
'/u01/DEV/db/apps_st/data/log02.dbf' size 1024M,
'/u01/DEV/db/apps_st/data/log03.dbf' size 1024M
NOFILENAMECHECK UNTIL TIME "TO_DATE('2016-11-29 10:00:00','YYYY-MM-DD hh24:mi:ss')";
以上例子(做duplicate时间是29号,源端25号有个0级备份,26号有个1级备份,源端在27号重新生成了一个生命周期5,28号又做了次1级备份了,如果until time到25或26号会报错源端resetlogs了,until到28号之后则会用到25、26、28的备份包和28号备份以后的归档日志,但是期间生命周期不一样,加了前面的一个生命周期就正常了)
run {
duplicate target database to NPS from active database NOFILENAMECHECK
pfile=/u01/NPS/db/tech_st/11.2.0/dbs/initNPS.ora
db_file_name_convert=('/u03/PFT/db/apps_st/data/','/u01/NPS/db/apps_st/data/')
LOGFILE
'/u01/NPS/db/apps_st/data/log01.dbf' size 1024M,
'/u01/NPS/db/apps_st/data/log02.dbf' size 1024M,
'/u01/NPS/db/apps_st/data/log03.dbf' size 1024M;
}
run {
duplicate target database to wftst NOFILENAMECHECK UNTIL TIME "TO_DATE('2016-09-05 08:00:00','YYYY-MM-DD hh24:mi:ss')"
db_file_name_convert=('/wfdb/db/oradata/WF','/wfdb/db/oradata/WFTST')
LOGFILE
'/wfdb/db/oradata/WFTST/log01.dbf' size 50M,
'/wfdb/db/oradata/WFTST/log02.dbf' size 50M,
'/wfdb/db/oradata/WFTST/log03.dbf' size 50M;
}
run {
duplicate target database to wftst from active database
db_file_name_convert=('/wfdb/db/oradata/WF','/wfdb/db/oradata/WFTST')
nofilenamecheck;
}
run {
duplicate target database for standby from active database nofilenamecheck;
}
run {
duplicate target database for standby
pfile=/home/oraprod/initPROD.ora
from active database nofilenamecheck;
}
最后,duplicate后目标端的tempfile可能需要重建下,能查询到select * from dba_temp_files即可
因为使用db_file_name_convert时会在duplicate库生成一个temp文件,但是如果duplicate原来的目录下存在一个这样名字的temp文件呢
[oranps@npstest NPS_npstest]$ oerr rman 05541
5541, 1, "no archived logs found in target database"
// *Cause: Target database was running in archived log mode, but
// control file did not have any archived log records.
// *Action: Archive current log before retrying command.
一些错误案例
from active database源端不使用密码,有如下会报错(一开始的连接并没有报错,绿色字体显示)
rman target / auxiliary sys/123456@PLMDB
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Oct 20 20:15:18 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: TDB (DBID=2585234821)
connected to auxiliary database: PLMDB (not mounted)
RMAN>duplicate target database to PLMDB from active database NOFILENAMECHECK
...
ORA-17629: Cannot connect to the remote database server
ORA-17627: ORA-01017: invalid username/password; logon denied
duplicate命令中没有logfile,目标端四个log相关参数为空,直接使用了主库的logfile,导致报错(duplicate目标端数据库的spfile中加了LOG_FILE_NAME_CONVERT就不再报错了)
源端ONLINE路径:/db/oracle/oradata/TDB/
目标端这几个参数都是空:LOG_FILE_NAME_CONVERT,DB_CREATE_FILE_DEST,DB_RECOVERY_FILE_DEST或DB_CREATE_ONLINE_LOG_DEST_n
目标端没有/db/oracle/oradata/TDB/这个路径
rman target sys/123456@TDB auxiliary sys/123456@PLMDB
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Oct 20 20:51:00 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: TDB (DBID=2585234821)
connected to auxiliary database: PLMDB (not mounted)
RMAN>run {
2> duplicate target database to PLMDB from active database NOFILENAMECHECK
3> db_file_name_convert=('/db/oracle/oradata/TDB/','/mnt/sdb1/u01/app/oracle/oradata/plmdb/','/db/oracle/admin/TDB/dpdump/','/mnt/sdb1/u01/app/oracle/oradata/plmdb/');
4> }
...
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "PLMDB" RESETLOGS ARCHIVELO G
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/db/oracle/oradata/TDB/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/db/oracle/oradata/TDB/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/db/oracle/oradata/TDB/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/mnt/sdb1/u01/app/oracle/oradata/plmdb/system01.dbf'
CHARACTER SET AL32UTF8
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 10/20/2017 20:44:49
RMAN-05501: aborting duplication of target database
RMAN-06136: ORACLE error from auxiliary database: ORA-01503: CREATE CONTROLFILE failed
ORA-00349: failure obtaining block size for '/db/oracle/oradata/TDB/redo01.log'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 9
duplicate命令中直接使用了LOG_FILE_NAME_CONVERT参数
RMAN-01008: the bad identifier was: LOG_FILE_NAME_CONVERT
Duplicate命令RMAN 自动执行下列步骤:
1.为副本数据库创建控制文件(所以源端和目标端的db_name可以不一样,比如源端为A,duplicate到目标端为B)。
2.Restore 数据文件到副本数据库,并通过增量备份和Archived Redo Logs 进行不完全恢复。
3.重启辅助实例,以加载服务器初始化参数文件即SPFILE。
4.不完全恢复后通过Resetlogs 方式Open 副本数据库以重建Online Redo Logs(Duplicate ... ForStandby 方式除外,该操作不会打开数据库)。
5.为副本数据库产生一个新的,唯一的DBID(Duplicate ... For Standby 方式除外,该方式不会创建新的唯一DBID)。
duplicate target database to NPS使用源库的备份文件来对目标库做复制
此时目标库必须能访问到源端的备份包(可以把主库备份文件拷贝至备库,或主备共用存储,备份包一份,但是再主备都是一样的存储路径),否则在主库执行duplicate时会报错说找不到备份包
比如没有传输controlfile备份包,则报找不到控制文件备份无法restore controlfile
比如没有传输datafile备份包,则报找不到控制文件备份无法restore datafile
使用备份包即不使用from active时,必须使用密码连接目标端,如下
rman target / auxiliary sys/lf0320tcsge@WFTST
duplicate target database to NPS from active database使用源库在线数据来对目标库做复制
使用from atcive database时,必须使用密码连接源端和目标端,如下
rman target sys/lf0320tcsge@WF auxiliary sys/lf0320tcsge@WFTST
When you execute DUPLICATE with FROM ACTIVE DATABASE
When you connect RMAN to the source database as TARGET, you must specify a password, even if RMAN uses operating system authentication. The source database must be mounted or open. If the source database is open, then archiving must be enabled. If the source database is not open, then it must have been shut down consistently.
当您使用FROM ACTIVE DATABASE执行DUPLICATE时
将RMAN连接到源数据库作为TARGET时,即使RMAN使用操作系统身份验证,也必须指定密码。 源数据库必须被安装或打开。 如果源数据库是打开的,则必须启用归档。 如果源数据库未打开,则必须一直关闭源数据库。
参数DB_FILE_NAME_CONVERT 和 LOGFILE和LOG_FILE_NAME_CONVERT
db_file_name_convert参数仅适用于physical standby和rman duplicate,对logical standby和普通rman restore无效;
log_file_name_convert适用于physical standby和rman duplicate,但是不能用于rman duplicate的run命令中,存在duplicate目标端的spfile文件中,所以一般在duplicate中加参数logfile
DB_FILE_NAME_CONVERT set on the DUPLICATE command overrides the initialization parameter DB_FILE_NAME_CONVERT (if set). For example, if the initialization parameter file setting is DB_FILE_NAME_CONVERT=('disk1','disk2'), but you execute DUPLICATE ... DB_FILE_NAME_CONVERT ('disk1','disk3'), then RMAN does not convert the disk1 substring to disk2. Instead, RMAN converts the disk1 substring to disk3.
在DUPLICATE命令上设置的DB_FILE_NAME_CONVERT将覆盖初始化参数DB_FILE_NAME_CONVERT(如果已设置)。 例如,如果初始化参数文件设置为DB_FILE_NAME_CONVERT =('disk1','disk2'),但是您执行DUPLICATE ... DB_FILE_NAME_CONVERT('disk1','disk3'),则RMAN不会将disk1子字符串转换为disk2。 相反,RMAN将disk1子字符串转换为disk3。
LOGFILE:Specifies options for creating online redo logs when creating a duplicate database that is not a standby database
If you do not specify LOGFILE, then RMAN first checks if any of the following initialization parameters are set: LOG_FILE_NAME_CONVERT,DB_CREATE_FILE_DEST, DB_RECOVERY_FILE_DEST or DB_CREATE_ONLINE_LOG_DEST_n. If these parameters are set, RMAN directs duplicate database online redo log files to Oracle managed storage based on these parameter settings. If none of these initialization parameters are set, then RMAN uses the original redo log file names of the source database for redo log files of the duplicate database. You must specify the NOFILENAMECHECK option in this case.
you do not set DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT because you are specifying names for data files and online logs in the RUN command itself
LOGFILE:指定在创建不是standby数据库的duplicate数据库时创建联机重做日志的选项
如果不指定LOGFILE,则RMAN首先检查是否设置了以下任何初始化参数:LOG_FILE_NAME_CONVERT,DB_CREATE_FILE_DEST,DB_RECOVERY_FILE_DEST或DB_CREATE_ONLINE_LOG_DEST_n。 如果设置了这些参数,RMAN将根据这些参数设置将duplicate的数据库联机重做日志文件到oracle的存储。 如果没有设置这些初始化参数,则RMAN会使用源数据库的原始重做日志文件名作为重复数据库的重做日志文件。 在这种情况下,您必须指定NOFILENAMECHECK选项。
当您在RUN命令本身中指定数据文件和联机日志的名称,您不要设置DB_FILE_NAME_CONVERT和LOG_FILE_NAME_CONVERT参数
参数PFILE
duplicate中参数pfile表示源端使用这个pfile来启动目标端(一般是从目标端拷贝到源端来,pfile=/源端路径/XX.ora)
没有pfile这个选项时,表示源端直接加载目标端的spfile来启动目标端
所有如果目标端没有spfile,而duplicate中又没有加pfile的选项,则源端会加载目标端一个虚拟的spfile,但是这个spfile实际又不存在(实验过,目标端show parameter spfile时有一个spfile,但是这个spfile并不实际存在)
Specifies a text-based initialization parameter file used by the auxiliary instance. RMAN automatically shuts down and restarts the auxiliary instance during duplication. If the auxiliary does not use a server parameter file in the default location, then you must specify the text-based initialization parameter file that RMAN should use when starting the auxiliary instance. The initialization parameter file must reside on the same host as the RMAN client used to perform the duplication.
If the auxiliary instance uses a server parameter file in the default location, then you do not need to specify PFILE.
指定辅助实例使用的pfile。 RMAN会在duplicate时自动关闭并重新启动辅助实例。 如果辅助程序在默认位置不使用服务器参数文件,则必须指定启动辅助实例时RMAN应使用的pfile。 pfile必须位于与用于执行重复的RMAN客户机相同的主机上。(如果rman在源端开启,则pfile放在源端上,如果ramn在目标端开启,则pfile放在目标端上)。如果辅助实例在默认位置使用服务器参数文件,则不需要指定PFILE。
参数NOFILENAMECHECK
Prevents RMAN from checking whether the data files and online redo logs files of the source database are in use when the source database files share the same names as the duplicate database files. You are responsible for determining that the duplicate operation does not overwrite useful data.
This option is necessary when you are creating a duplicate database in a different host that has the same disk configuration, directory structure, and file names as the host of the source database. For example, assume that you have a small database located in the /dbs directory of srchost:
/oracle/dbs/system_prod1.dbf
/oracle/dbs/users_prod1.dbf
/oracle/dbs/rbs_prod1.dbf
Assume that you want to duplicate this database to desthost, which has the same file system /oracle/dbs/*, and you want to use the same file names in the duplicate database as in the source database. In this case, specify the NOFILENAMECHECK option to avoid an error message. Because RMAN is not aware of the different hosts, RMAN cannot determine automatically that it should not check the file names.
当源数据库文件与duplicate的数据库文件使用相同的名称时,防止RMAN检查源数据库的数据文件和联机重做日志文件是否正在使用。 您有责任确定duplicate操作不会覆盖源端在用的数据。
在与源数据库的主机具有相同磁盘配置,目录结构和文件名的不同主机中创建重复数据库时,此选项是必需的。 例如,假设您在srchost的/dbs目录中有一个小数据库:
/oracle/dbs/system_prod1.dbf
/oracle/dbs/users_prod1.dbf
/oracle/dbs/rbs_prod1.dbf
假设您要将此数据库复制到目标端,目标端和源端一样具有相同文件系统/oracle/dbs/*,并且要在目标端数据库中的使用和源端相同文件名。 在这种情况下,请指定NOFILENAMECHECK选项以避免出现错误消息。 因为RMAN不知道不同的主机,RMAN无法自动确定不应该检查文件名。
一些duplicate的语法如下
nohup rman target sys/123@WF auxiliary sys/123@WFTST cmdfile=duplicateWF_WFTST.rman msglog=duplicateWF_WFTST.log &
run {
duplicate database PROD incarnation 4 to DEV
pfile=/ebsbak/rmanbackup/duplicate/initDEV.ora
db_file_name_convert=('/db/prod/db/apps_st/','/u01/DEV/db/apps_st/')
LOGFILE
'/u01/DEV/db/apps_st/data/log01.dbf' size 1024M,
'/u01/DEV/db/apps_st/data/log02.dbf' size 1024M,
'/u01/DEV/db/apps_st/data/log03.dbf' size 1024M
NOFILENAMECHECK UNTIL TIME "TO_DATE('2016-11-29 10:00:00','YYYY-MM-DD hh24:mi:ss')";
以上例子(做duplicate时间是29号,源端25号有个0级备份,26号有个1级备份,源端在27号重新生成了一个生命周期5,28号又做了次1级备份了,如果until time到25或26号会报错源端resetlogs了,until到28号之后则会用到25、26、28的备份包和28号备份以后的归档日志,但是期间生命周期不一样,加了前面的一个生命周期就正常了)
run {
duplicate target database to NPS from active database NOFILENAMECHECK
pfile=/u01/NPS/db/tech_st/11.2.0/dbs/initNPS.ora
db_file_name_convert=('/u03/PFT/db/apps_st/data/','/u01/NPS/db/apps_st/data/')
LOGFILE
'/u01/NPS/db/apps_st/data/log01.dbf' size 1024M,
'/u01/NPS/db/apps_st/data/log02.dbf' size 1024M,
'/u01/NPS/db/apps_st/data/log03.dbf' size 1024M;
}
run {
duplicate target database to wftst NOFILENAMECHECK UNTIL TIME "TO_DATE('2016-09-05 08:00:00','YYYY-MM-DD hh24:mi:ss')"
db_file_name_convert=('/wfdb/db/oradata/WF','/wfdb/db/oradata/WFTST')
LOGFILE
'/wfdb/db/oradata/WFTST/log01.dbf' size 50M,
'/wfdb/db/oradata/WFTST/log02.dbf' size 50M,
'/wfdb/db/oradata/WFTST/log03.dbf' size 50M;
}
run {
duplicate target database to wftst from active database
db_file_name_convert=('/wfdb/db/oradata/WF','/wfdb/db/oradata/WFTST')
nofilenamecheck;
}
run {
duplicate target database for standby from active database nofilenamecheck;
}
run {
duplicate target database for standby
pfile=/home/oraprod/initPROD.ora
from active database nofilenamecheck;
}
最后,duplicate后目标端的tempfile可能需要重建下,能查询到select * from dba_temp_files即可
因为使用db_file_name_convert时会在duplicate库生成一个temp文件,但是如果duplicate原来的目录下存在一个这样名字的temp文件呢
[oranps@npstest NPS_npstest]$ oerr rman 05541
5541, 1, "no archived logs found in target database"
// *Cause: Target database was running in archived log mode, but
// control file did not have any archived log records.
// *Action: Archive current log before retrying command.
一些错误案例
from active database源端不使用密码,有如下会报错(一开始的连接并没有报错,绿色字体显示)
rman target / auxiliary sys/123456@PLMDB
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Oct 20 20:15:18 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: TDB (DBID=2585234821)
connected to auxiliary database: PLMDB (not mounted)
RMAN>duplicate target database to PLMDB from active database NOFILENAMECHECK
...
ORA-17629: Cannot connect to the remote database server
ORA-17627: ORA-01017: invalid username/password; logon denied
duplicate命令中没有logfile,目标端四个log相关参数为空,直接使用了主库的logfile,导致报错(duplicate目标端数据库的spfile中加了LOG_FILE_NAME_CONVERT就不再报错了)
源端ONLINE路径:/db/oracle/oradata/TDB/
目标端这几个参数都是空:LOG_FILE_NAME_CONVERT,DB_CREATE_FILE_DEST,DB_RECOVERY_FILE_DEST或DB_CREATE_ONLINE_LOG_DEST_n
目标端没有/db/oracle/oradata/TDB/这个路径
rman target sys/123456@TDB auxiliary sys/123456@PLMDB
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Oct 20 20:51:00 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: TDB (DBID=2585234821)
connected to auxiliary database: PLMDB (not mounted)
RMAN>run {
2> duplicate target database to PLMDB from active database NOFILENAMECHECK
3> db_file_name_convert=('/db/oracle/oradata/TDB/','/mnt/sdb1/u01/app/oracle/oradata/plmdb/','/db/oracle/admin/TDB/dpdump/','/mnt/sdb1/u01/app/oracle/oradata/plmdb/');
4> }
...
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "PLMDB" RESETLOGS ARCHIVELO G
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/db/oracle/oradata/TDB/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/db/oracle/oradata/TDB/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/db/oracle/oradata/TDB/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/mnt/sdb1/u01/app/oracle/oradata/plmdb/system01.dbf'
CHARACTER SET AL32UTF8
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 10/20/2017 20:44:49
RMAN-05501: aborting duplication of target database
RMAN-06136: ORACLE error from auxiliary database: ORA-01503: CREATE CONTROLFILE failed
ORA-00349: failure obtaining block size for '/db/oracle/oradata/TDB/redo01.log'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 9
duplicate命令中直接使用了LOG_FILE_NAME_CONVERT参数
RMAN-01008: the bad identifier was: LOG_FILE_NAME_CONVERT
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30126024/viewspace-2129593/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30126024/viewspace-2129593/