首页 > 数据库 > Oracle > 11g从活动数据库复制数据库
11g新特性,duplicate database,文件不落地,直接从库复制库
db1:
189.168.0.11
db2
189.168.0.22
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = db1)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /opt/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = zaradb)
(ORACLE_HOME = /opt/oracle/product/11.2.0/db_1)
(SID_NAME = zaradb)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = db2)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /opt/oracle
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = zaradb)
(ORACLE_HOME = /opt/oracle/product/11.2.0/db_1)
(SID_NAME = zaradb)
)
)
db1=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=189.168.0.11)(PORT=1521))
(CONNECT_DATA=
(SERVICE_NAME=zaradb)
)
)
db2=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=189.168.0.22)(PORT=1521))
(CONNECT_DATA=
(SERVICE_NAME=zaradb)
)
)
listener动态注册,口令文件一致
orapwd file=?/dbs/orapworcl password=oracle
db1归档open
db2启动到nomount
rman target sys/oracle@db1 auxiliary sys/oracle@db2
duplicate target database to ZARADB from active database nofilenamecheck;
注意事项
监听必须是静态注册
---------------------------
oracle@db2 /opt/oracle/oradata$rman target sys/oracle@db1 auxiliary sys/oracle@db2
Recovery Manager: Release 11.2.0.3.0 - Production on Wed Mar 19 14:38:40 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ZARADB (DBID=2839592742)
connected to auxiliary database: ZARADB (not mounted)
RMAN> duplicate target database to ZARADB from active database nofilenamecheck;
Starting Duplicate Db at 19-MAR-14
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=19 device type=DISK
contents of Memory Script:
{
sql clone "alter system set db_name =
''ZARADB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''ZARADB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
backup as copy current controlfile auxiliary format '/opt/oracle/oradata/zaradb/control01.ctl';
restore clone controlfile to '/opt/oracle/oradata/zaradb/control02.ctl' from
'/opt/oracle/oradata/zaradb/control01.ctl';
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''ZARADB'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''ZARADB'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 523108352 bytes
Fixed Size 1346052 bytes
Variable Size 159385084 bytes
Database Buffers 356515840 bytes
Redo Buffers 5861376 bytes
Starting backup at 19-MAR-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=43 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/opt/oracle/product/11.2.0/db_1/dbs/snapcf_zaradb.f tag=TAG20140319T143853 RECID=2 STAMP=842625533
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:04
Finished backup at 19-MAR-14
Starting restore at 19-MAR-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=18 device type=DISK
channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 19-MAR-14
database mounted
contents of Memory Script:
{
set newname for datafile 1 to
"/opt/oracle/oradata/zaradb/system01.dbf";
set newname for datafile 2 to
"/opt/oracle/oradata/zaradb/sysaux01.dbf";
set newname for datafile 3 to
"/opt/oracle/oradata/zaradb/undotbs01.dbf";
set newname for datafile 4 to
"/opt/oracle/oradata/zaradb/users01.dbf";
backup as copy reuse
datafile 1 auxiliary format
"/opt/oracle/oradata/zaradb/system01.dbf" datafile
2 auxiliary format
"/opt/oracle/oradata/zaradb/sysaux01.dbf" datafile
3 auxiliary format
"/opt/oracle/oradata/zaradb/undotbs01.dbf" datafile
4 auxiliary format
"/opt/oracle/oradata/zaradb/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 19-MAR-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/opt/oracle/oradata/zaradb/system01.dbf
output file name=/opt/oracle/oradata/zaradb/system01.dbf tag=TAG20140319T143904
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:38
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/opt/oracle/oradata/zaradb/sysaux01.dbf
output file name=/opt/oracle/oradata/zaradb/sysaux01.dbf tag=TAG20140319T143904
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/opt/oracle/oradata/zaradb/undotbs01.dbf
output file name=/opt/oracle/oradata/zaradb/undotbs01.dbf tag=TAG20140319T143904
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/opt/oracle/oradata/zaradb/users01.dbf
output file name=/opt/oracle/oradata/zaradb/users01.dbf tag=TAG20140319T143904
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 19-MAR-14
sql statement: alter system archive log current
contents of Memory Script:
{
backup as copy reuse
archivelog like "/opt/oracle/oradata/arch/1_6_842613930.dbf" auxiliary format
"/opt/oracle/oradata/arch/1_6_842613930.dbf" ;
catalog clone archivelog "/opt/oracle/oradata/arch/1_6_842613930.dbf";
switch clone datafile all;
}
executing Memory Script
Starting backup at 19-MAR-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=6 RECID=2 STAMP=842625626
output file name=/opt/oracle/oradata/arch/1_6_842613930.dbf RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 19-MAR-14
cataloged archived log
archived log file name=/opt/oracle/oradata/arch/1_6_842613930.dbf RECID=2 STAMP=842625627
datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=842625627 file name=/opt/oracle/oradata/zaradb/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=842625627 file name=/opt/oracle/oradata/zaradb/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=842625628 file name=/opt/oracle/oradata/zaradb/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=842625628 file name=/opt/oracle/oradata/zaradb/users01.dbf
contents of Memory Script:
{
set until scn 855884;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 19-MAR-14
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 6 is already on disk as file /opt/oracle/oradata/arch/1_6_842613930.dbf
archived log file name=/opt/oracle/oradata/arch/1_6_842613930.dbf thread=1 sequence=6
media recovery complete, elapsed time: 00:00:00
Finished recover at 19-MAR-14
Oracle instance started
Total System Global Area 523108352 bytes
Fixed Size 1346052 bytes
Variable Size 159385084 bytes
Database Buffers 356515840 bytes
Redo Buffers 5861376 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''ZARADB'' 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 = ''ZARADB'' 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 523108352 bytes
Fixed Size 1346052 bytes
Variable Size 159385084 bytes
Database Buffers 356515840 bytes
Redo Buffers 5861376 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ZARADB" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/opt/oracle/oradata/zaradb/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/opt/oracle/oradata/zaradb/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/opt/oracle/oradata/zaradb/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/opt/oracle/oradata/zaradb/system01.dbf'
CHARACTER SET ZHS16GBK
contents of Memory Script:
{
set newname for tempfile 1 to
"/opt/oracle/oradata/zaradb/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/opt/oracle/oradata/zaradb/sysaux01.dbf",
"/opt/oracle/oradata/zaradb/undotbs01.dbf",
"/opt/oracle/oradata/zaradb/users01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /opt/oracle/oradata/zaradb/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/opt/oracle/oradata/zaradb/sysaux01.dbf RECID=1 STAMP=842625647
cataloged datafile copy
datafile copy file name=/opt/oracle/oradata/zaradb/undotbs01.dbf RECID=2 STAMP=842625647
cataloged datafile copy
datafile copy file name=/opt/oracle/oradata/zaradb/users01.dbf RECID=3 STAMP=842625647
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=842625647 file name=/opt/oracle/oradata/zaradb/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=842625647 file name=/opt/oracle/oradata/zaradb/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=842625647 file name=/opt/oracle/oradata/zaradb/users01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 19-MAR-14
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/13177610/viewspace-1125138/ ,如需转载,请注明出处,否则将追究法律责任。