使用RMAN进行Active Database Duplication

1. 配置listener文件,需要指定静态的SID

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /oracle/product/10.2/db_2)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl11)
(ORACLE_HOME = /oracle/product/11.1.0/db_1)
(SID_NAME = orcl11)
)
(SID_DESC =
(GLOBAL_DBNAME = test1)
(ORACLE_HOME = /oracle/product/11.1.0/db_1)
(SID_NAME = test1)
)

)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = nodeA)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)


2.为clone数据库配置一个tnsnames

test1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = nodeA)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test1)
(UR=A)
)
)

使用基于tnsnames的联接,auxiliary DB可以在本机,也可以在不同的机器上.


3.创建一个密码文件

orapwd password=admin entries=5 file=orapwtest1

注意target和clone的密码应该一样.


4.准备一个初始化参数文件

db_name = test1


5. 启动auxiliary数据库

export ORACLE_SID=test1

startup nomount pfile='/oracle/product/11.1.0/db_1/dbs/inittest1.ora'

6 启动RMAN,连接到target和auxiliary

export ORACLE_SID=orcl11

$ORACLE_HOME/bin/rman
connect target sys/admin@orcl11

连接到target数据库时需要指定密码,duplicate会使用这个用户名和密码连接到auxiliary实例.

connect auxiliary sys/admin@test1

如果出现ora-12528错误,那么需要在 tnsnames.ora里添加一个选项:(UR=A)
如果出现ora-1031,那么可能是密码文件配置错误

7.执行duplicate操作.

duplicate target database to test1 from active database
spfile
parameter_value_convert = '/oracle/oradata/orcl11','/oracle/oradata/test1'
set log_file_name_convert ='/oracle/oradata/orcl11','/oracle/oradata/test1'
db_file_name_convert = '/oracle/oradata/orcl11','/oracle/oradata/test1';

如果使用不同的机器和相同的目录结构,那么需要指定nofilenamecheck选项;
如果要忽略某个表空间,可以指定skip tablespace

duplicate target database to test1 from active database
nofilenamecheck
skip tablespace data;


以下是该命令的输出,看一下有助于理解rman到底作了什么:
-------------------------------------
Starting Duplicate Db at 18-JUN-09
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=97 device type=DISK

contents of Memory Script:
{
backup as copy reuse
file '/oracle/product/11.1.0/db_1/dbs/spfileorcl11.ora' auxiliary format
'/oracle/product/11.1.0/db_1/dbs/spfiletest1.ora' ;
sql clone "alter system set spfile= ''/oracle/product/11.1.0/db_1/dbs/spfiletest1.ora''";
}
executing Memory Script

Starting backup at 18-JUN-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=155 device type=DISK
Finished backup at 18-JUN-09

sql statement: alter system set spfile= ''/oracle/product/11.1.0/db_1/dbs/spfiletest1.ora''

contents of Memory Script:
{
sql clone "alter system set db_name =
''TEST1'' comment=
''duplicate'' scope=spfile";
sql clone "alter system set control_files =
''/oracle/oradata/test1/control01.ctl'', ''/oracle/oradata/test1/control02.ctl'', ''/oracle/oradata/test1/control03.ctl'' comment=
'''' scope=spfile";
sql clone "alter system set log_file_name_convert =
''/oracle/oradata/orcl11'', ''/oracle/oradata/test1'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount ;
}
executing Memory Script

sql statement: alter system set db_name = ''TEST1'' comment= ''duplicate'' scope=spfile

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

sql statement: alter system set log_file_name_convert = ''/oracle/oradata/orcl11'', ''/oracle/oradata/test1'' comment= '''' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 392495104 bytes

Fixed Size 2144744 bytes
Variable Size 117442072 bytes
Database Buffers 268435456 bytes
Redo Buffers 4472832 bytes

contents of Memory Script:
{
set newname for datafile 1 to
"/oracle/oradata/test1/system01.dbf";
set newname for datafile 2 to
"/oracle/oradata/test1/sysaux01.dbf";
set newname for datafile 3 to
"/oracle/oradata/test1/undotbs01.dbf";
set newname for datafile 4 to
"/oracle/oradata/test1/users01.dbf";
backup as copy reuse
datafile 1 auxiliary format
"/oracle/oradata/test1/system01.dbf" datafile
2 auxiliary format
"/oracle/oradata/test1/sysaux01.dbf" datafile
3 auxiliary format
"/oracle/oradata/test1/undotbs01.dbf" datafile
4 auxiliary format
"/oracle/oradata/test1/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 18-JUN-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/oracle/oradata/orcl11/system01.dbf
output file name=/oracle/oradata/test1/system01.dbf tag=TAG20090618T111156 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/oracle/oradata/orcl11/sysaux01.dbf
output file name=/oracle/oradata/test1/sysaux01.dbf tag=TAG20090618T111156 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/oracle/oradata/orcl11/undotbs01.dbf
output file name=/oracle/oradata/test1/undotbs01.dbf tag=TAG20090618T111156 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/oracle/oradata/orcl11/users01.dbf
output file name=/oracle/oradata/test1/users01.dbf tag=TAG20090618T111156 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 18-JUN-09

sql statement: alter system archive log current
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TEST1" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/oracle/oradata/test1/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/oracle/oradata/test1/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/oracle/oradata/test1/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/oracle/oradata/test1/system01.dbf'
CHARACTER SET AL32UTF8


contents of Memory Script:
{
backup as copy reuse
archivelog like "/oracle/flash_recovery_area/orcl11/archivelog/2009_06_18/o1_mf_1_19_53md6tmq_.arc" auxiliary format
"/oracle/product/11.1.0/db_1/dbs/arch1_19_683741214.dbf" ;
catalog clone archivelog "/oracle/product/11.1.0/db_1/dbs/arch1_19_683741214.dbf";
switch clone datafile all;
}
executing Memory Script

Starting backup at 18-JUN-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=19 RECID=66 STAMP=689858011
output file name=/oracle/product/11.1.0/db_1/dbs/arch1_19_683741214.dbf RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 18-JUN-09

cataloged archived log
archived log file name=/oracle/product/11.1.0/db_1/dbs/arch1_19_683741214.dbf RECID=1 STAMP=689858169

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=689858169 file name=/oracle/oradata/test1/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=689858169 file name=/oracle/oradata/test1/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=689858169 file name=/oracle/oradata/test1/users01.dbf

contents of Memory Script:
{
set until scn 2736101;
recover
clone database
delete archivelog
;
}
executing Memory Script

executing command: SET until clause

Starting recover at 18-JUN-09
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=153 device type=DISK

starting media recovery

archived log for thread 1 with sequence 19 is already on disk as file /oracle/product/11.1.0/db_1/dbs/arch1_19_683741214.dbf
archived log file name=/oracle/product/11.1.0/db_1/dbs/arch1_19_683741214.dbf thread=1 sequence=19
media recovery complete, elapsed time: 00:00:00
Finished recover at 18-JUN-09

contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount ;
}
executing Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 392495104 bytes

Fixed Size 2144744 bytes
Variable Size 117442072 bytes
Database Buffers 268435456 bytes
Redo Buffers 4472832 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TEST1" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/oracle/oradata/test1/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/oracle/oradata/test1/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/oracle/oradata/test1/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/oracle/oradata/test1/system01.dbf'
CHARACTER SET AL32UTF8


contents of Memory Script:
{
set newname for tempfile 1 to
"/oracle/oradata/test1/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/oracle/oradata/test1/sysaux01.dbf";
catalog clone datafilecopy "/oracle/oradata/test1/undotbs01.dbf";
catalog clone datafilecopy "/oracle/oradata/test1/users01.dbf";
switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

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

cataloged datafile copy
datafile copy file name=/oracle/oradata/test1/sysaux01.dbf RECID=1 STAMP=689858184

cataloged datafile copy
datafile copy file name=/oracle/oradata/test1/undotbs01.dbf RECID=2 STAMP=689858184

cataloged datafile copy
datafile copy file name=/oracle/oradata/test1/users01.dbf RECID=3 STAMP=689858184

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=689858184 file name=/oracle/oradata/test1/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=689858184 file name=/oracle/oradata/test1/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=689858184 file name=/oracle/oradata/test1/users01.dbf

contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished Duplicate Db at 18-JUN-09

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/100682/viewspace-1023252/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/100682/viewspace-1023252/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值