使用RMAN在本机创建Clone数据库

1.创建一个备份
backup database plus archivelog;

2. 配置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))
)
)


3.为clone数据库配置一个tnsnames
test1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = nodeA)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test1)
(UR=A)
)
)

4.创建一个密码文件

orapwd password=admin entries=5 file=orapwtest1


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

db_name = test1
db_block_size = 8192
compatible = 11.1.0.0.0
remote_login_passwordfile = exclusive
control_files = ('/oracle/oradata/test1/control01.ctl','/oracle/oradata/test1/control02.ctl')
db_file_name_convert = ('/oracle/oradata/orcl11','/oracle/oradata/test1')
log_file_name_convert = ('/oracle/oradata/orcl11','/oracle/oradata/test1')

6. 启动auxiliary数据库

export ORACLE_SID=test1

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

7. 启动RMAN,连接到target和auxiliary

export ORACLE_SID=orcl11

$ORACLE_HOME/bin/rman target /
connect auxiliary sys/admin@test1

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

8.执行duplicate操作.
duplicate target database to test1;


以下是该命令的输出,看一下有助于理解rman到底作了什么:
-------------------------------------
Starting Duplicate Db at 17-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:
{
set until scn 2718348;
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";
restore
clone database
;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 17-JUN-09
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /oracle/oradata/test1/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /oracle/oradata/test1/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /oracle/oradata/test1/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /oracle/oradata/test1/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /oracle/flash_recovery_area/orcl11/backupset/2009_06_17/o1_mf_nnndf_TAG20090617T151221_53k5twv6_.bkp
channel ORA_AUX_DISK_1: piece handle=/oracle/flash_recovery_area/orcl11/backupset/2009_06_17/o1_mf_nnndf_TAG20090617T151221_53k5twv6_.bkp tag=TAG20090617T151221
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:26
Finished restore at 17-JUN-09
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:
{
switch clone datafile all;
}
executing Memory Script

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

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

executing command: SET until clause

Starting recover at 17-JUN-09
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 15 is already on disk as file /oracle/flash_recovery_area/orcl11/archivelog/2009_06_17/o1_mf_1_15_53k5xohh_.arc
archived log file name=/oracle/flash_recovery_area/orcl11/archivelog/2009_06_17/o1_mf_1_15_53k5xohh_.arc thread=1 sequence=15
media recovery complete, elapsed time: 00:00:01
Finished recover at 17-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 217157632 bytes

Fixed Size 2142976 bytes
Variable Size 159386880 bytes
Database Buffers 50331648 bytes
Redo Buffers 5296128 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=689793365

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

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

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=689793365 file name=/oracle/oradata/test1/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=689793365 file name=/oracle/oradata/test1/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=689793365 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 17-JUN-09

[@more@]

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值