在相同的主机上创建一个duplicate数据库

在相同的主机上创建一个duplicate数据库

source db:dbtest

auxiliary db:dupdb

duplicate database会自动分配一个新的DBID
要确保auxiliary channel能访问到所需的备份以及归档日志

1.备份source db

$ rman target /
RMAN> backup database format ='/home/oracle/arch/dbbak_%U' plus archivelog;

2.修改监听文件,静态注册监听

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = testdb)
(ORACLE_HOME = /u01/app/oracle/product/11.2./dbhome_1/)
(SID_NAME =testdb)
)
(SID_DESC =
(GLOBAL_DBNAME = dupdb)
(ORACLE_HOME = /u01/app/oracle/product/11.2./dbhome_1/)
(SID_NAME =dupdb)
)
)

3.修改tnsnames.ora文件

DBTEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = testdb)(PORT = ))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dbtest)
)
) DUPDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = testdb)(PORT = ))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dupdb)
)
)

4.为duplicate 数据库创建参数文件initdupdb.ora

db_name=dupdb
db_block_size=
compatible=11.2.0.4.
remote_login_passwordfile=exclusive
control_files=('/u01/app/oracle/oradata/dupdb/control01.ctl','/u01/app/oracle/oradata/dupdb/control02.ctl')
db_file_name_convert=('/u01/app/oracle/oradata/dbtest','/u01/app/oracle/oradata/dupdb')
log_file_name_covert=('/u01/app/oracle/oradata/dbtest','/u01/app/oracle/oradata/dupdb')

#其他参数是可选的

5.启动auxiliary database(duplicate database)

$ export ORACLE_SID=dupdb
$ sqlplus /nolog
SQL> connect /as sysdba
SQL> startup nomount pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initdupdb.ora'
ORACLE instance started. Total System Global Area bytes
Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes
SQL>

6.启动rman

$ export ORACLE_SID=dupdb
$ rman Recovery Manager: Release 11.2.0.4. - Production on Thu Jun :: Copyright (c) , , Oracle and/or its affiliates. All rights reserved. RMAN> connect target sys/system1@dbtest connected to target database: DBTEST (DBID=) RMAN> connect auxiliary / connected to auxiliary database: DUPDB (not mounted) RMAN>

7.启动duplicate database操作

RMAN> duplicate target database to dupdb;

以下为duplicate命令的执行结果:

RMAN> duplicate target database to dupdb;

Starting Duplicate Db at -JUN- ::
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID= device type=DISK contents of Memory Script:
{
sql clone "create spfile from memory";
}
executing Memory Script sql statement: create spfile from memory contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script Oracle instance shut down connected to auxiliary database (not started)
Oracle instance started Total System Global Area bytes Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes contents of Memory Script:
{
sql clone "alter system set db_name =
''DBTEST'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''DUPDB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile;
alter clone database mount;
}
executing Memory Script sql statement: alter system set db_name = ''DBTEST'' comment= ''Modified by RMAN duplicate'' scope=spfile sql statement: alter system set db_unique_name = ''DUPDB'' comment= ''Modified by RMAN duplicate'' scope=spfile Oracle instance shut down Oracle instance started Total System Global Area bytes Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes Starting restore at -JUN- ::
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID= device type=DISK channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/DBTEST/autobackup/2015_06_25/o1_mf_s_883287663_brp8zhvt_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/DBTEST/autobackup/2015_06_25/o1_mf_s_883287663_brp8zhvt_.bkp tag=TAG20150625T054103
channel ORA_AUX_DISK_1: restored backup piece
channel ORA_AUX_DISK_1: restore complete, elapsed time: ::
output file name=/u01/app/oracle/oradata/dupdb/control01.ctl
output file name=/u01/app/oracle/oradata/dupdb/control02.ctl
Finished restore at -JUN- :: database mounted contents of Memory Script:
{
set until scn ;
sql clone 'alter database flashback off';
set newname for datafile to
"/u01/app/oracle/oradata/dupdb/system01.dbf";
set newname for datafile to
"/u01/app/oracle/oradata/dupdb/sysaux01.dbf";
set newname for datafile to
"/u01/app/oracle/oradata/dupdb/undotbs01.dbf";
set newname for datafile to
"/u01/app/oracle/oradata/dupdb/users01.dbf";
set newname for datafile to
"/u01/app/oracle/oradata/dupdb/example01.dbf";
set newname for datafile to
"/u01/app/oracle/oradata/dupdb/nnc_data01.dbf";
set newname for datafile to
"/u01/app/oracle/oradata/dupdb/nnc_data02.dbf";
set newname for datafile to
"/u01/app/oracle/oradata/dupdb/nnc_data03.dbf";
set newname for datafile to
"/u01/app/oracle/oradata/dupdb/nnc_index01.dbf";
set newname for datafile to
"/u01/app/oracle/oradata/dupdb/nnc_index02.dbf";
set newname for datafile to
"/u01/app/oracle/oradata/dupdb/nnc_index03.dbf";
restore
clone database
;
}
executing Memory Script executing command: SET until clause sql statement: alter database flashback off executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME Starting restore at -JUN- ::
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 to /u01/app/oracle/oradata/dupdb/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile to /u01/app/oracle/oradata/dupdb/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile to /u01/app/oracle/oradata/dupdb/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile to /u01/app/oracle/oradata/dupdb/users01.dbf
channel ORA_AUX_DISK_1: restoring datafile to /u01/app/oracle/oradata/dupdb/example01.dbf
channel ORA_AUX_DISK_1: restoring datafile to /u01/app/oracle/oradata/dupdb/nnc_data01.dbf
channel ORA_AUX_DISK_1: restoring datafile to /u01/app/oracle/oradata/dupdb/nnc_data02.dbf
channel ORA_AUX_DISK_1: restoring datafile to /u01/app/oracle/oradata/dupdb/nnc_data03.dbf
channel ORA_AUX_DISK_1: restoring datafile to /u01/app/oracle/oradata/dupdb/nnc_index01.dbf
channel ORA_AUX_DISK_1: restoring datafile to /u01/app/oracle/oradata/dupdb/nnc_index02.dbf
channel ORA_AUX_DISK_1: restoring datafile to /u01/app/oracle/oradata/dupdb/nnc_index03.dbf
channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/arch/dbbak_0tqabpiv_1_1
channel ORA_AUX_DISK_1: piece handle=/home/oracle/arch/dbbak_0tqabpiv_1_1 tag=TAG20150625T054047
channel ORA_AUX_DISK_1: restored backup piece
channel ORA_AUX_DISK_1: restore complete, elapsed time: ::
Finished restore at -JUN- :: contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/system01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/sysaux01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/undotbs01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/users01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/example01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/nnc_data01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/nnc_data02.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/nnc_data03.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/nnc_index01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/nnc_index02.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/nnc_index03.dbf contents of Memory Script:
{
set until scn ;
recover
clone database
delete archivelog
;
}
executing Memory Script executing command: SET until clause Starting recover at -JUN- ::
using channel ORA_AUX_DISK_1 starting media recovery archived log for thread with sequence is already on disk as file /home/oracle/arch/1_10_883118265.dbf
archived log for thread with sequence is already on disk as file /home/oracle/arch/1_11_883118265.dbf
archived log file name=/home/oracle/arch/1_10_883118265.dbf thread= sequence=
archived log file name=/home/oracle/arch/1_11_883118265.dbf thread= sequence=
media recovery complete, elapsed time: ::
Finished recover at -JUN- ::
Oracle instance started Total System Global Area bytes Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes contents of Memory Script:
{
sql clone "alter system set db_name =
''DUPDB'' 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 = ''DUPDB'' 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 bytes Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DUPDB" RESETLOGS ARCHIVELOG
MAXLOGFILES
MAXLOGMEMBERS
MAXDATAFILES
MAXINSTANCES
MAXLOGHISTORY
LOGFILE
GROUP ( '/u01/app/oracle/oradata/dupdb/redo01.log' ) SIZE M REUSE,
GROUP ( '/u01/app/oracle/oradata/dupdb/redo02.log' ) SIZE M REUSE,
GROUP ( '/u01/app/oracle/oradata/dupdb/redo03.log' ) SIZE M REUSE
DATAFILE
'/u01/app/oracle/oradata/dupdb/system01.dbf'
CHARACTER SET ZHS16GBK contents of Memory Script:
{
set newname for tempfile to
"/u01/app/oracle/oradata/dupdb/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/dupdb/sysaux01.dbf",
"/u01/app/oracle/oradata/dupdb/undotbs01.dbf",
"/u01/app/oracle/oradata/dupdb/users01.dbf",
"/u01/app/oracle/oradata/dupdb/example01.dbf",
"/u01/app/oracle/oradata/dupdb/nnc_data01.dbf",
"/u01/app/oracle/oradata/dupdb/nnc_data02.dbf",
"/u01/app/oracle/oradata/dupdb/nnc_data03.dbf",
"/u01/app/oracle/oradata/dupdb/nnc_index01.dbf",
"/u01/app/oracle/oradata/dupdb/nnc_index02.dbf",
"/u01/app/oracle/oradata/dupdb/nnc_index03.dbf";
switch clone datafile all;
}
executing Memory Script executing command: SET NEWNAME renamed tempfile to /u01/app/oracle/oradata/dupdb/temp01.dbf in control file cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupdb/sysaux01.dbf RECID= STAMP=
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupdb/undotbs01.dbf RECID= STAMP=
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupdb/users01.dbf RECID= STAMP=
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupdb/example01.dbf RECID= STAMP=
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupdb/nnc_data01.dbf RECID= STAMP=
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupdb/nnc_data02.dbf RECID= STAMP=
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupdb/nnc_data03.dbf RECID= STAMP=
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupdb/nnc_index01.dbf RECID= STAMP=
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupdb/nnc_index02.dbf RECID= STAMP=
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupdb/nnc_index03.dbf RECID= STAMP= datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/sysaux01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/undotbs01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/users01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/example01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/nnc_data01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/nnc_data02.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/nnc_data03.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/nnc_index01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/nnc_index02.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oracle/oradata/dupdb/nnc_index03.dbf contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script database opened
Finished Duplicate Db at -JUN- :: RMAN>
上一篇:json 串转成 java 对象再拼接成前台 html 元素


下一篇:Kafka权威指南 读书笔记之(四)Kafka 消费者一一从 Kafka读取数据