今天重新做了一次rman duplicate操作
[oracle@ora02 ~]$ rman target / auxiliary sys/oracle@PROD
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Jan 11 15:32:10 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1427785672)
connected to auxiliary database: PROD (not mounted)
RMAN> DUPLICATE TARGET DATABASE TO PROD FROM ACTIVE DATABASE
2> spfile PARAMETER_VALUE_CONVERT 'ORCL','PROD'
3> set CONTROL_FILES='/u01/app/oracle/oradata/PROD/control01.ctl','/u01/app/oracle/fast_recovery_area/PROD/control02.ctl'
4> set DB_FILE_NAME_CONVERT='ORCL','PROD'
5> set LOG_FILE_NAME_CONVERT='ORCL','PROD';
执行最后报错
Oracle instance shut down
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 01/11/2016 15:33:46
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 01/11/2016 15:33:37
ORA-17628: Oracle error 19505 returned by remote Oracle server
查看备库的时候,发现在备库,参数文件和控制文件都已经复制过去了。这时检查备库,发现备库的实例处于关闭状态。手动启动备库的实例,报错,参数文件和控制文件中的db_name不一致,可以断定,rman修改控制文件的这一步就没完成。
该创建的目录应该都创建了呀!oracle网络通的,静态监听处于启动状态,要不然文件也复制不过来呀!主库的归档也开了,并且最起码有一个归档。检查一下各种文件吧!
RMAN> report schema;
Report of database schema for database with db_unique_name ORCL
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 740 SYSTEM *** /u02/app/oracle/oradata/ORCL/system01.dbf
2 520 SYSAUX *** /u02/app/oracle/oradata/ORCL/sysaux01.dbf
3 70 UNDOTBS1 *** /u02/app/oracle/oradata/ORCL/undotbs01.dbf
4 5 USERS *** /u02/app/oracle/oradata/ORCL/users01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 20 TEMP 32767 /u01/app/oracle/oradata/ORCL/temp01.dbf
然后就发现了问题,怎么数据文件没有在它通常的位置?突然想起,前几天还做了一些改路径的操作。再回头看rman报出的日志
Starting backup at 2016-01-11 15:33:33
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u02/app/oracle/oradata/ORCL/system01.dbf
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 01/11/2016 15:33:34
ORA-17628: Oracle error 19505 returned by remote Oracle server
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u02/app/oracle/oradata/ORCL/sysaux01.dbf
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 01/11/2016 15:33:35
ORA-17628: Oracle error 19505 returned by remote Oracle server
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u02/app/oracle/oradata/ORCL/undotbs01.dbf
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 01/11/2016 15:33:36
ORA-17628: Oracle error 19505 returned by remote Oracle server
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u02/app/oracle/oradata/ORCL/users01.dbf
Oracle instance started
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 536874064 bytes
Database Buffers 289406976 bytes
Redo Buffers 6565888 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''PROD'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset db_unique_name scope=spfile";
shutdown clone immediate;
}
job一直在失败,因为备库就不存在对应的目录。知道问题,解决就简单了,在DB_FILE_NAME_CONVERT里加个对应关系就好了。
RMAN> connect auxiliary sys/oracle@PROD
connected to auxiliary database: PROD (not mounted)
RMAN> DUPLICATE TARGET DATABASE TO PROD FROM ACTIVE DATABASE
2> spfile PARAMETER_VALUE_CONVERT 'ORCL','PROD'
3> set CONTROL_FILES='/u01/app/oracle/oradata/PROD/control01.ctl','/u01/app/oracle/fast_recovery_area/PROD/control02.ctl'
4> set DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/ORCL','/u01/app/oracle/oradata/PROD','/u02/app/oracle/oradata/ORCL','/u01/app/oracle/oradata/PROD'
5> set LOG_FILE_NAME_CONVERT='ORCL','PROD';
Starting Duplicate Db at 2016-01-11 15:54:32
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=10 device type=DISK
contents of Memory Script:
{
backup as copy reuse
targetfile '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileORCL.ora' auxiliary format
'/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilePROD.ora' ;
sql clone "alter system set spfile= ''/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilePROD.ora''";
}
executing Memory Script
Starting backup at 2016-01-11 15:54:32
using channel ORA_DISK_1
Finished backup at 2016-01-11 15:54:34
sql statement: alter system set spfile= ''/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilePROD.ora''
contents of Memory Script:
{
sql clone "alter system set db_name =
''PROD'' comment=
''duplicate'' scope=spfile";
sql clone "alter system set audit_file_dest =
''/u01/app/oracle/admin/PROD/adump'' comment=
'''' scope=spfile";
sql clone "alter system set dispatchers =
''(PROTOCOL=TCP) (SERVICE=PRODXDB)'' comment=
'''' scope=spfile";
sql clone "alter system set CONTROL_FILES =
''/u01/app/oracle/oradata/PROD/control01.ctl'', ''/u01/app/oracle/fast_recovery_area/PROD/control02.ctl'' comment=
'''' scope=spfile";
sql clone "alter system set db_file_name_convert =
''/u01/app/oracle/oradata/ORCL'', ''/u01/app/oracle/oradata/PROD'', ''/u02/app/oracle/oradata/ORCL'', ''/u01/app/oracle/oradata/PROD'' comment=
'''' scope=spfile";
sql clone "alter system set LOG_FILE_NAME_CONVERT =
''ORCL'', ''PROD'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
sql statement: alter system set db_name = ''PROD'' comment= ''duplicate'' scope=spfile
sql statement: alter system set audit_file_dest = ''/u01/app/oracle/admin/PROD/adump'' comment= '''' scope=spfile
sql statement: alter system set dispatchers = ''(PROTOCOL=TCP) (SERVICE=PRODXDB)'' comment= '''' scope=spfile
sql statement: alter system set CONTROL_FILES = ''/u01/app/oracle/oradata/PROD/control01.ctl'', ''/u01/app/oracle/fast_recovery_area/PROD/control02.ctl'' comment= '''' scope=spfile
sql statement: alter system set db_file_name_convert = ''/u01/app/oracle/oradata/ORCL'', ''/u01/app/oracle/oradata/PROD'', ''/u02/app/oracle/oradata/ORCL'', ''/u01/app/oracle/oradata/PROD'' comment= '''' scope=spfile
sql statement: alter system set LOG_FILE_NAME_CONVERT = ''ORCL'', ''PROD'' comment= '''' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 536874064 bytes
Database Buffers 289406976 bytes
Redo Buffers 6565888 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''ORCL'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''PROD'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
backup as copy current controlfile auxiliary format '/u01/app/oracle/oradata/PROD/control01.ctl';
restore clone controlfile to '/u01/app/oracle/fast_recovery_area/PROD/control02.ctl' from
'/u01/app/oracle/oradata/PROD/control01.ctl';
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''PROD'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 536874064 bytes
Database Buffers 289406976 bytes
Redo Buffers 6565888 bytes
Starting backup at 2016-01-11 15:54:47
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_ORCL.f tag=TAG20160111T155447 RECID=9 STAMP=900863687
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2016-01-11 15:54:48
Starting restore at 2016-01-11 15:54:48
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=133 device type=DISK
channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 2016-01-11 15:54:49
database mounted
contents of Memory Script:
{
set newname for datafile 1 to
"/u01/app/oracle/oradata/PROD/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/PROD/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/PROD/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/PROD/users01.dbf";
backup as copy reuse
datafile 1 auxiliary format
"/u01/app/oracle/oradata/PROD/system01.dbf" datafile
2 auxiliary format
"/u01/app/oracle/oradata/PROD/sysaux01.dbf" datafile
3 auxiliary format
"/u01/app/oracle/oradata/PROD/undotbs01.dbf" datafile
4 auxiliary format
"/u01/app/oracle/oradata/PROD/users01.dbf" ;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting backup at 2016-01-11 15:54:54
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u02/app/oracle/oradata/ORCL/system01.dbf
output file name=/u01/app/oracle/oradata/PROD/system01.dbf tag=TAG20160111T155454
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u02/app/oracle/oradata/ORCL/sysaux01.dbf
output file name=/u01/app/oracle/oradata/PROD/sysaux01.dbf tag=TAG20160111T155454
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u02/app/oracle/oradata/ORCL/undotbs01.dbf
output file name=/u01/app/oracle/oradata/PROD/undotbs01.dbf tag=TAG20160111T155454
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u02/app/oracle/oradata/ORCL/users01.dbf
output file name=/u01/app/oracle/oradata/PROD/users01.dbf tag=TAG20160111T155454
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2016-01-11 15:55:28
sql statement: alter system archive log current
contents of Memory Script:
{
backup as copy reuse
archivelog like "/u01/app/oracle/fast_recovery_area/ORCL/archivelog/2016_01_11/o1_mf_1_23_c96qzjkx_.arc" auxiliary format
"/u01/app/oracle/fast_recovery_area/PROD/archivelog/2016_01_11/o1_mf_1_23_%u_.arc" ;
catalog clone recovery area;
switch clone datafile all;
}
executing Memory Script
Starting backup at 2016-01-11 15:55:28
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=23 RECID=18 STAMP=900863728
output file name=/u01/app/oracle/fast_recovery_area/PROD/archivelog/2016_01_11/o1_mf_1_23_1sqr45ng_.arc RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 2016-01-11 15:55:29
searching for all files in the recovery area
List of Files Unknown to the Database
=====================================
File Name: /u01/app/oracle/fast_recovery_area/PROD/archivelog/2016_01_11/o1_mf_1_23_1sqr45ng_.arc
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/app/oracle/fast_recovery_area/PROD/archivelog/2016_01_11/o1_mf_1_23_1sqr45ng_.arc
List of files in Recovery Area not managed by the database
==========================================================
File Name: /u01/app/oracle/fast_recovery_area/PROD/control02.ctl
RMAN-07526: Reason: File is not an Oracle Managed File
number of files not managed by recovery area is 1, totaling 9.28MB
datafile 1 switched to datafile copy
input datafile copy RECID=9 STAMP=900863730 file name=/u01/app/oracle/oradata/PROD/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=10 STAMP=900863730 file name=/u01/app/oracle/oradata/PROD/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=11 STAMP=900863730 file name=/u01/app/oracle/oradata/PROD/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=12 STAMP=900863730 file name=/u01/app/oracle/oradata/PROD/users01.dbf
contents of Memory Script:
{
set until scn 1026162;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 2016-01-11 15:55:29
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 23 is already on disk as file /u01/app/oracle/fast_recovery_area/PROD/archivelog/2016_01_11/o1_mf_1_23_1sqr45ng_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/PROD/archivelog/2016_01_11/o1_mf_1_23_1sqr45ng_.arc thread=1 sequence=23
media recovery complete, elapsed time: 00:00:00
Finished recover at 2016-01-11 15:55:30
Oracle instance started
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 536874064 bytes
Database Buffers 289406976 bytes
Redo Buffers 6565888 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''PROD'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset db_unique_name scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
sql statement: alter system set db_name = ''PROD'' comment= ''Reset to original value by RMAN'' scope=spfile
sql statement: alter system reset db_unique_name scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 536874064 bytes
Database Buffers 289406976 bytes
Redo Buffers 6565888 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "PROD" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/PROD/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/PROD/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/u01/app/oracle/oradata/PROD/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/u01/app/oracle/oradata/PROD/system01.dbf'
CHARACTER SET AL32UTF8
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/PROD/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/PROD/sysaux01.dbf",
"/u01/app/oracle/oradata/PROD/undotbs01.dbf",
"/u01/app/oracle/oradata/PROD/users01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/PROD/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD/sysaux01.dbf RECID=1 STAMP=900863742
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD/undotbs01.dbf RECID=2 STAMP=900863742
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/PROD/users01.dbf RECID=3 STAMP=900863742
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=900863742 file name=/u01/app/oracle/oradata/PROD/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=900863742 file name=/u01/app/oracle/oradata/PROD/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=900863742 file name=/u01/app/oracle/oradata/PROD/users01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 2016-01-11 15:55:45