Duplicate的一点总结
生活随笔
收集整理的這篇文章主要介紹了
Duplicate的一点总结
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
目標(biāo)端啟動(dòng)靜態(tài)監(jiān)聽(源端的tns中關(guān)于目標(biāo)端配置,增加(UR=A)是無效的,因?yàn)閐uplicate過程中會(huì)關(guān)閉再啟動(dòng)目標(biāo)端,關(guān)閉的過程中目標(biāo)端的監(jiān)聽不再有了,這樣源端連接不到目標(biāo)端,無法再啟動(dòng)目標(biāo)端),目標(biāo)端實(shí)例啟動(dòng)到nomount狀態(tài)
Duplicate命令RMAN 自動(dòng)執(zhí)行下列步驟:
?1.為副本數(shù)據(jù)庫創(chuàng)建控制文件(所以源端和目標(biāo)端的db_name可以不一樣,比如源端為A,duplicate到目標(biāo)端為B)。
?2.Restore 數(shù)據(jù)文件到副本數(shù)據(jù)庫,并通過增量備份和Archived Redo Logs 進(jìn)行不完全恢復(fù)。
?3.重啟輔助實(shí)例,以加載服務(wù)器初始化參數(shù)文件即SPFILE。
?4.不完全恢復(fù)后通過Resetlogs 方式Open 副本數(shù)據(jù)庫以重建Online Redo Logs(Duplicate ... ForStandby 方式除外,該操作不會(huì)打開數(shù)據(jù)庫)。
?5.為副本數(shù)據(jù)庫產(chǎn)生一個(gè)新的,唯一的DBID(Duplicate ... For Standby 方式除外,該方式不會(huì)創(chuàng)建新的唯一DBID)。
duplicate target database to NPS使用源庫的備份文件來對(duì)目標(biāo)庫做復(fù)制
此時(shí)目標(biāo)庫必須能訪問到源端的備份包(可以把主庫備份文件拷貝至備庫,或主備共用存儲(chǔ),備份包一份,但是再主備都是一樣的存儲(chǔ)路徑),否則在主庫執(zhí)行duplicate時(shí)會(huì)報(bào)錯(cuò)說找不到備份包
比如沒有傳輸controlfile備份包,則報(bào)找不到控制文件備份無法restore controlfile
比如沒有傳輸datafile備份包,則報(bào)找不到控制文件備份無法restore datafile
使用備份包即不使用from active時(shí),必須使用密碼連接目標(biāo)端,如下
rman target / auxiliary sys/lf0320tcsge@WFTST
duplicate target database to NPS from active database使用源庫在線數(shù)據(jù)來對(duì)目標(biāo)庫做復(fù)制
使用from atcive database時(shí),必須使用密碼連接源端和目標(biāo)端,如下
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.
當(dāng)您使用FROM ACTIVE DATABASE執(zhí)行DUPLICATE時(shí)
將RMAN連接到源數(shù)據(jù)庫作為TARGET時(shí),即使RMAN使用操作系統(tǒng)身份驗(yàn)證,也必須指定密碼。 源數(shù)據(jù)庫必須被安裝或打開。 如果源數(shù)據(jù)庫是打開的,則必須啟用歸檔。 如果源數(shù)據(jù)庫未打開,則必須一直關(guān)閉源數(shù)據(jù)庫。
參數(shù)DB_FILE_NAME_CONVERT?和LOGFILE和LOG_FILE_NAME_CONVERT
db_file_name_convert參數(shù)僅適用于physical standby和rman duplicate,對(duì)logical standby和普通rman restore無效;
log_file_name_convert適用于physical standby和rman duplicate,但是不能用于rman duplicate的run命令中,存在duplicate目標(biāo)端的spfile文件中,所以一般在duplicate中加參數(shù)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命令上設(shè)置的DB_FILE_NAME_CONVERT將覆蓋初始化參數(shù)DB_FILE_NAME_CONVERT(如果已設(shè)置)。 例如,如果初始化參數(shù)文件設(shè)置為DB_FILE_NAME_CONVERT =('disk1','disk2'),但是您執(zhí)行DUPLICATE ... DB_FILE_NAME_CONVERT('disk1','disk3'),則RMAN不會(huì)將disk1子字符串轉(zhuǎn)換為disk2。 相反,RMAN將disk1子字符串轉(zhuǎn)換為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:指定在創(chuàng)建不是standby數(shù)據(jù)庫的duplicate數(shù)據(jù)庫時(shí)創(chuàng)建聯(lián)機(jī)重做日志的選項(xiàng)
如果不指定LOGFILE,則RMAN首先檢查是否設(shè)置了以下任何初始化參數(shù):LOG_FILE_NAME_CONVERT,DB_CREATE_FILE_DEST,DB_RECOVERY_FILE_DEST或DB_CREATE_ONLINE_LOG_DEST_n。 如果設(shè)置了這些參數(shù),RMAN將根據(jù)這些參數(shù)設(shè)置將duplicate的數(shù)據(jù)庫聯(lián)機(jī)重做日志文件到oracle的存儲(chǔ)。 如果沒有設(shè)置這些初始化參數(shù),則RMAN會(huì)使用源數(shù)據(jù)庫的原始重做日志文件名作為重復(fù)數(shù)據(jù)庫的重做日志文件。 在這種情況下,您必須指定NOFILENAMECHECK選項(xiàng)。
當(dāng)您在RUN命令本身中指定數(shù)據(jù)文件和聯(lián)機(jī)日志的名稱,您不要設(shè)置DB_FILE_NAME_CONVERT和LOG_FILE_NAME_CONVERT參數(shù)
參數(shù)PFILE
duplicate中參數(shù)pfile表示源端使用這個(gè)pfile來啟動(dòng)目標(biāo)端(一般是從目標(biāo)端拷貝到源端來,pfile=/源端路徑/XX.ora)
沒有pfile這個(gè)選項(xiàng)時(shí),表示源端直接加載目標(biāo)端的spfile來啟動(dòng)目標(biāo)端
所有如果目標(biāo)端沒有spfile,而duplicate中又沒有加pfile的選項(xiàng),則源端會(huì)加載目標(biāo)端一個(gè)虛擬的spfile,但是這個(gè)spfile實(shí)際又不存在(實(shí)驗(yàn)過,目標(biāo)端show parameter spfile時(shí)有一個(gè)spfile,但是這個(gè)spfile并不實(shí)際存在)
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.
指定輔助實(shí)例使用的pfile。 RMAN會(huì)在duplicate時(shí)自動(dòng)關(guān)閉并重新啟動(dòng)輔助實(shí)例。 如果輔助程序在默認(rèn)位置不使用服務(wù)器參數(shù)文件,則必須指定啟動(dòng)輔助實(shí)例時(shí)RMAN應(yīng)使用的pfile。 pfile必須位于與用于執(zhí)行重復(fù)的RMAN客戶機(jī)相同的主機(jī)上。(如果rman在源端開啟,則pfile放在源端上,如果ramn在目標(biāo)端開啟,則pfile放在目標(biāo)端上)。如果輔助實(shí)例在默認(rèn)位置使用服務(wù)器參數(shù)文件,則不需要指定PFILE。
參數(shù)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.
當(dāng)源數(shù)據(jù)庫文件與duplicate的數(shù)據(jù)庫文件使用相同的名稱時(shí),防止RMAN檢查源數(shù)據(jù)庫的數(shù)據(jù)文件和聯(lián)機(jī)重做日志文件是否正在使用。 您有責(zé)任確定duplicate操作不會(huì)覆蓋源端在用的數(shù)據(jù)。
在與源數(shù)據(jù)庫的主機(jī)具有相同磁盤配置,目錄結(jié)構(gòu)和文件名的不同主機(jī)中創(chuàng)建重復(fù)數(shù)據(jù)庫時(shí),此選項(xiàng)是必需的。 例如,假設(shè)您在srchost的/dbs目錄中有一個(gè)小數(shù)據(jù)庫:
/oracle/dbs/system_prod1.dbf
/oracle/dbs/users_prod1.dbf
/oracle/dbs/rbs_prod1.dbf
假設(shè)您要將此數(shù)據(jù)庫復(fù)制到目標(biāo)端,目標(biāo)端和源端一樣具有相同文件系統(tǒng)/oracle/dbs/*,并且要在目標(biāo)端數(shù)據(jù)庫中的使用和源端相同文件名。 在這種情況下,請(qǐng)指定NOFILENAMECHECK選項(xiàng)以避免出現(xiàn)錯(cuò)誤消息。 因?yàn)镽MAN不知道不同的主機(jī),RMAN無法自動(dòng)確定不應(yīng)該檢查文件名。
一些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時(shí)間是29號(hào),源端25號(hào)有個(gè)0級(jí)備份,26號(hào)有個(gè)1級(jí)備份,源端在27號(hào)重新生成了一個(gè)生命周期5,28號(hào)又做了次1級(jí)備份了,如果until time到25或26號(hào)會(huì)報(bào)錯(cuò)源端resetlogs了,until到28號(hào)之后則會(huì)用到25、26、28的備份包和28號(hào)備份以后的歸檔日志,但是期間生命周期不一樣,加了前面的一個(gè)生命周期就正常了)
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后目標(biāo)端的tempfile可能需要重建下,能查詢到select * from dba_temp_files即可
因?yàn)槭褂?/span>db_file_name_convert時(shí)會(huì)在duplicate庫生成一個(gè)temp文件,但是如果duplicate原來的目錄下存在一個(gè)這樣名字的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.
一些錯(cuò)誤案例
from?active database源端不使用密碼,有如下會(huì)報(bào)錯(cuò)(一開始的連接并沒有報(bào)錯(cuò),綠色字體顯示)
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命令中沒有l(wèi)ogfile,目標(biāo)端四個(gè)log相關(guān)參數(shù)為空,直接使用了主庫的logfile,導(dǎo)致報(bào)錯(cuò)(duplicate目標(biāo)端數(shù)據(jù)庫的spfile中加了LOG_FILE_NAME_CONVERT就不再報(bào)錯(cuò)了)
源端ONLINE路徑:/db/oracle/oradata/TDB/
目標(biāo)端這幾個(gè)參數(shù)都是空:LOG_FILE_NAME_CONVERT,DB_CREATE_FILE_DEST,DB_RECOVERY_FILE_DEST或DB_CREATE_ONLINE_LOG_DEST_n
目標(biāo)端沒有/db/oracle/oradata/TDB/這個(gè)路徑
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參數(shù)
RMAN-01008: the bad identifier was: LOG_FILE_NAME_CONVERT
Duplicate命令RMAN 自動(dòng)執(zhí)行下列步驟:
?1.為副本數(shù)據(jù)庫創(chuàng)建控制文件(所以源端和目標(biāo)端的db_name可以不一樣,比如源端為A,duplicate到目標(biāo)端為B)。
?2.Restore 數(shù)據(jù)文件到副本數(shù)據(jù)庫,并通過增量備份和Archived Redo Logs 進(jìn)行不完全恢復(fù)。
?3.重啟輔助實(shí)例,以加載服務(wù)器初始化參數(shù)文件即SPFILE。
?4.不完全恢復(fù)后通過Resetlogs 方式Open 副本數(shù)據(jù)庫以重建Online Redo Logs(Duplicate ... ForStandby 方式除外,該操作不會(huì)打開數(shù)據(jù)庫)。
?5.為副本數(shù)據(jù)庫產(chǎn)生一個(gè)新的,唯一的DBID(Duplicate ... For Standby 方式除外,該方式不會(huì)創(chuàng)建新的唯一DBID)。
duplicate target database to NPS使用源庫的備份文件來對(duì)目標(biāo)庫做復(fù)制
此時(shí)目標(biāo)庫必須能訪問到源端的備份包(可以把主庫備份文件拷貝至備庫,或主備共用存儲(chǔ),備份包一份,但是再主備都是一樣的存儲(chǔ)路徑),否則在主庫執(zhí)行duplicate時(shí)會(huì)報(bào)錯(cuò)說找不到備份包
比如沒有傳輸controlfile備份包,則報(bào)找不到控制文件備份無法restore controlfile
比如沒有傳輸datafile備份包,則報(bào)找不到控制文件備份無法restore datafile
使用備份包即不使用from active時(shí),必須使用密碼連接目標(biāo)端,如下
rman target / auxiliary sys/lf0320tcsge@WFTST
duplicate target database to NPS from active database使用源庫在線數(shù)據(jù)來對(duì)目標(biāo)庫做復(fù)制
使用from atcive database時(shí),必須使用密碼連接源端和目標(biāo)端,如下
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.
當(dāng)您使用FROM ACTIVE DATABASE執(zhí)行DUPLICATE時(shí)
將RMAN連接到源數(shù)據(jù)庫作為TARGET時(shí),即使RMAN使用操作系統(tǒng)身份驗(yàn)證,也必須指定密碼。 源數(shù)據(jù)庫必須被安裝或打開。 如果源數(shù)據(jù)庫是打開的,則必須啟用歸檔。 如果源數(shù)據(jù)庫未打開,則必須一直關(guān)閉源數(shù)據(jù)庫。
參數(shù)DB_FILE_NAME_CONVERT?和LOGFILE和LOG_FILE_NAME_CONVERT
db_file_name_convert參數(shù)僅適用于physical standby和rman duplicate,對(duì)logical standby和普通rman restore無效;
log_file_name_convert適用于physical standby和rman duplicate,但是不能用于rman duplicate的run命令中,存在duplicate目標(biāo)端的spfile文件中,所以一般在duplicate中加參數(shù)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命令上設(shè)置的DB_FILE_NAME_CONVERT將覆蓋初始化參數(shù)DB_FILE_NAME_CONVERT(如果已設(shè)置)。 例如,如果初始化參數(shù)文件設(shè)置為DB_FILE_NAME_CONVERT =('disk1','disk2'),但是您執(zhí)行DUPLICATE ... DB_FILE_NAME_CONVERT('disk1','disk3'),則RMAN不會(huì)將disk1子字符串轉(zhuǎn)換為disk2。 相反,RMAN將disk1子字符串轉(zhuǎn)換為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:指定在創(chuàng)建不是standby數(shù)據(jù)庫的duplicate數(shù)據(jù)庫時(shí)創(chuàng)建聯(lián)機(jī)重做日志的選項(xiàng)
如果不指定LOGFILE,則RMAN首先檢查是否設(shè)置了以下任何初始化參數(shù):LOG_FILE_NAME_CONVERT,DB_CREATE_FILE_DEST,DB_RECOVERY_FILE_DEST或DB_CREATE_ONLINE_LOG_DEST_n。 如果設(shè)置了這些參數(shù),RMAN將根據(jù)這些參數(shù)設(shè)置將duplicate的數(shù)據(jù)庫聯(lián)機(jī)重做日志文件到oracle的存儲(chǔ)。 如果沒有設(shè)置這些初始化參數(shù),則RMAN會(huì)使用源數(shù)據(jù)庫的原始重做日志文件名作為重復(fù)數(shù)據(jù)庫的重做日志文件。 在這種情況下,您必須指定NOFILENAMECHECK選項(xiàng)。
當(dāng)您在RUN命令本身中指定數(shù)據(jù)文件和聯(lián)機(jī)日志的名稱,您不要設(shè)置DB_FILE_NAME_CONVERT和LOG_FILE_NAME_CONVERT參數(shù)
參數(shù)PFILE
duplicate中參數(shù)pfile表示源端使用這個(gè)pfile來啟動(dòng)目標(biāo)端(一般是從目標(biāo)端拷貝到源端來,pfile=/源端路徑/XX.ora)
沒有pfile這個(gè)選項(xiàng)時(shí),表示源端直接加載目標(biāo)端的spfile來啟動(dòng)目標(biāo)端
所有如果目標(biāo)端沒有spfile,而duplicate中又沒有加pfile的選項(xiàng),則源端會(huì)加載目標(biāo)端一個(gè)虛擬的spfile,但是這個(gè)spfile實(shí)際又不存在(實(shí)驗(yàn)過,目標(biāo)端show parameter spfile時(shí)有一個(gè)spfile,但是這個(gè)spfile并不實(shí)際存在)
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.
指定輔助實(shí)例使用的pfile。 RMAN會(huì)在duplicate時(shí)自動(dòng)關(guān)閉并重新啟動(dòng)輔助實(shí)例。 如果輔助程序在默認(rèn)位置不使用服務(wù)器參數(shù)文件,則必須指定啟動(dòng)輔助實(shí)例時(shí)RMAN應(yīng)使用的pfile。 pfile必須位于與用于執(zhí)行重復(fù)的RMAN客戶機(jī)相同的主機(jī)上。(如果rman在源端開啟,則pfile放在源端上,如果ramn在目標(biāo)端開啟,則pfile放在目標(biāo)端上)。如果輔助實(shí)例在默認(rèn)位置使用服務(wù)器參數(shù)文件,則不需要指定PFILE。
參數(shù)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.
當(dāng)源數(shù)據(jù)庫文件與duplicate的數(shù)據(jù)庫文件使用相同的名稱時(shí),防止RMAN檢查源數(shù)據(jù)庫的數(shù)據(jù)文件和聯(lián)機(jī)重做日志文件是否正在使用。 您有責(zé)任確定duplicate操作不會(huì)覆蓋源端在用的數(shù)據(jù)。
在與源數(shù)據(jù)庫的主機(jī)具有相同磁盤配置,目錄結(jié)構(gòu)和文件名的不同主機(jī)中創(chuàng)建重復(fù)數(shù)據(jù)庫時(shí),此選項(xiàng)是必需的。 例如,假設(shè)您在srchost的/dbs目錄中有一個(gè)小數(shù)據(jù)庫:
/oracle/dbs/system_prod1.dbf
/oracle/dbs/users_prod1.dbf
/oracle/dbs/rbs_prod1.dbf
假設(shè)您要將此數(shù)據(jù)庫復(fù)制到目標(biāo)端,目標(biāo)端和源端一樣具有相同文件系統(tǒng)/oracle/dbs/*,并且要在目標(biāo)端數(shù)據(jù)庫中的使用和源端相同文件名。 在這種情況下,請(qǐng)指定NOFILENAMECHECK選項(xiàng)以避免出現(xiàn)錯(cuò)誤消息。 因?yàn)镽MAN不知道不同的主機(jī),RMAN無法自動(dòng)確定不應(yīng)該檢查文件名。
一些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時(shí)間是29號(hào),源端25號(hào)有個(gè)0級(jí)備份,26號(hào)有個(gè)1級(jí)備份,源端在27號(hào)重新生成了一個(gè)生命周期5,28號(hào)又做了次1級(jí)備份了,如果until time到25或26號(hào)會(huì)報(bào)錯(cuò)源端resetlogs了,until到28號(hào)之后則會(huì)用到25、26、28的備份包和28號(hào)備份以后的歸檔日志,但是期間生命周期不一樣,加了前面的一個(gè)生命周期就正常了)
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后目標(biāo)端的tempfile可能需要重建下,能查詢到select * from dba_temp_files即可
因?yàn)槭褂?/span>db_file_name_convert時(shí)會(huì)在duplicate庫生成一個(gè)temp文件,但是如果duplicate原來的目錄下存在一個(gè)這樣名字的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.
一些錯(cuò)誤案例
from?active database源端不使用密碼,有如下會(huì)報(bào)錯(cuò)(一開始的連接并沒有報(bào)錯(cuò),綠色字體顯示)
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命令中沒有l(wèi)ogfile,目標(biāo)端四個(gè)log相關(guān)參數(shù)為空,直接使用了主庫的logfile,導(dǎo)致報(bào)錯(cuò)(duplicate目標(biāo)端數(shù)據(jù)庫的spfile中加了LOG_FILE_NAME_CONVERT就不再報(bào)錯(cuò)了)
源端ONLINE路徑:/db/oracle/oradata/TDB/
目標(biāo)端這幾個(gè)參數(shù)都是空:LOG_FILE_NAME_CONVERT,DB_CREATE_FILE_DEST,DB_RECOVERY_FILE_DEST或DB_CREATE_ONLINE_LOG_DEST_n
目標(biāo)端沒有/db/oracle/oradata/TDB/這個(gè)路徑
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參數(shù)
RMAN-01008: the bad identifier was: LOG_FILE_NAME_CONVERT
來自 “ ITPUB博客 ” ,鏈接:http://blog.itpub.net/30126024/viewspace-2129593/,如需轉(zhuǎn)載,請(qǐng)注明出處,否則將追究法律責(zé)任。
轉(zhuǎn)載于:http://blog.itpub.net/30126024/viewspace-2129593/
總結(jié)
以上是生活随笔為你收集整理的Duplicate的一点总结的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【SDCC 2016现场】数据库/大数据
- 下一篇: HttpClientHelper