使用RMAN创建复制数据库
作者:网络转载 发布时间:[ 2015/11/12 10:55:03 ] 推荐标签:数据库 RMAN
4.运行RMAN DUPLICATE命令
登录到A机:
$ rman target sys/oracle@A auxiliary sys/oracle@B
RMAN> duplicate target database to testdb from active database;
具体过程如下:
[oracle@JY-DB01 admin]$ rman target sys/oracle@A auxiliary sys/oracle@B
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Nov 5 15:44:57 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORADB (DBID=2647366668)
connected to auxiliary database: TESTDB (not mounted)
RMAN> duplicate target database to testdb from active database;
Starting Duplicate Db at 2015-11-05 15:46:44
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=1 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 238034944 bytes
Fixed Size 2252016 bytes
Variable Size 180355856 bytes
Database Buffers 50331648 bytes
Redo Buffers 5095424 bytes
contents of Memory Script:
{
sql clone "alter system set control_files =
''/u01/oradata2/TESTDB/controlfile/o1_mf_c3p2gqj2_.ctl'' comment=
''Set by RMAN'' scope=spfile";
sql clone "alter system set db_name =
''ORADB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''TESTDB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
backup as copy current controlfile auxiliary format '/u01/oradata2/TESTDB/controlfile/o1_mf_c3p2gqjc_.ctl';
sql clone "alter system set control_files =
''/u01/oradata2/TESTDB/controlfile/o1_mf_c3p2gqjc_.ctl'' comment=
''Set by RMAN'' scope=spfile";
shutdown clone immediate;
startup clone nomount;
alter clone database mount;
}
executing Memory Script
sql statement: alter system set control_files = ''/u01/oradata2/TESTDB/controlfile/o1_mf_c3p2gqj2_.ctl'' comment= ''Set by RMAN'' scope=spfile
sql statement: alter system set db_name = ''ORADB'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''TESTDB'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 238034944 bytes
Fixed Size 2252016 bytes
Variable Size 180355856 bytes
Database Buffers 50331648 bytes
Redo Buffers 5095424 bytes
Starting backup at 2015-11-05 15:47:29
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=46 device type=DISK
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_oradb.f tag=TAG20151105T154729 RECID=27 STAMP=894988050
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2015-11-05 15:47:31
sql statement: alter system set control_files = ''/u01/oradata2/TESTDB/controlfile/o1_mf_c3p2gqjc_.ctl'' comment= ''Set by RMAN'' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 238034944 bytes
Fixed Size 2252016 bytes
Variable Size 180355856 bytes
Database Buffers 50331648 bytes
Redo Buffers 5095424 bytes
database mounted
contents of Memory Script:
{
set newname for clone datafile 1 to new;
set newname for clone datafile 2 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 4 to new;
backup as copy reuse
datafile 1 auxiliary format new
datafile 2 auxiliary format new
datafile 3 auxiliary format new
datafile 4 auxiliary format new
;
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 2015-11-05 15:47:57
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/oradata/ORADB/datafile/o1_mf_system_c2v0xxm5_.dbf
output file name=/u01/oradata2/TESTDB/datafile/o1_mf_system_4uqlgrpe_.dbf tag=TAG20151105T154757
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=/u01/oradata/ORADB/datafile/o1_mf_sysaux_c2v0xxp1_.dbf
output file name=/u01/oradata2/TESTDB/datafile/o1_mf_sysaux_4vqlgrq7_.dbf tag=TAG20151105T154757
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=/u01/oradata/ORADB/datafile/o1_mf_undotbs1_c2v0xxpb_.dbf
output file name=/u01/oradata2/TESTDB/datafile/o1_mf_undotbs1_50qlgrqm_.dbf tag=TAG20151105T154757
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=/u01/oradata/ORADB/datafile/users01.dbf
output file name=/u01/oradata2/TESTDB/datafile/o1_mf_users_51qlgrqp_.dbf tag=TAG20151105T154757
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2015-11-05 15:48:43
sql statement: alter system archive log current
contents of Memory Script:
{
backup as copy reuse
archivelog like "/u01/oradb_arch1/1_146_894101903.dbf" auxiliary format
"/opt/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_146_894101903.dbf" ;
catalog clone archivelog "/opt/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_146_894101903.dbf";
switch clone datafile all;
}
executing Memory Script
Starting backup at 2015-11-05 15:48:44
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=146 RECID=252 STAMP=894988123
output file name=/opt/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_146_894101903.dbf RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 2015-11-05 15:48:45
cataloged archived log
archived log file name=/opt/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_146_894101903.dbf RECID=252 STAMP=894988217
datafile 1 switched to datafile copy
input datafile copy RECID=27 STAMP=894988217 file name=/u01/oradata2/TESTDB/datafile/o1_mf_system_4uqlgrpe_.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=28 STAMP=894988217 file name=/u01/oradata2/TESTDB/datafile/o1_mf_sysaux_4vqlgrq7_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=29 STAMP=894988217 file name=/u01/oradata2/TESTDB/datafile/o1_mf_undotbs1_50qlgrqm_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=30 STAMP=894988217 file name=/u01/oradata2/TESTDB/datafile/o1_mf_users_51qlgrqp_.dbf
contents of Memory Script:
{
set until scn 2237265;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 2015-11-05 15:48:46
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=24 device type=DISK
starting media recovery
archived log for thread 1 with sequence 146 is already on disk as file /opt/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_146_894101903.dbf
archived log file name=/opt/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_146_894101903.dbf thread=1 sequence=146
media recovery complete, elapsed time: 00:00:00
Finished recover at 2015-11-05 15:48:49
Oracle instance started
Total System Global Area 238034944 bytes
Fixed Size 2252016 bytes
Variable Size 180355856 bytes
Database Buffers 50331648 bytes
Redo Buffers 5095424 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''TESTDB'' 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 = ''TESTDB'' 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 238034944 bytes
Fixed Size 2252016 bytes
Variable Size 180355856 bytes
Database Buffers 50331648 bytes
Redo Buffers 5095424 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TESTDB" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 SIZE 50 M ,
GROUP 2 SIZE 50 M ,
GROUP 3 SIZE 50 M
DATAFILE
'/u01/oradata2/TESTDB/datafile/o1_mf_system_4uqlgrpe_.dbf'
CHARACTER SET ZHS16GBK
contents of Memory Script:
{
set newname for clone tempfile 1 to new;
switch clone tempfile all;
catalog clone datafilecopy "/u01/oradata2/TESTDB/datafile/o1_mf_sysaux_4vqlgrq7_.dbf",
"/u01/oradata2/TESTDB/datafile/o1_mf_undotbs1_50qlgrqm_.dbf",
"/u01/oradata2/TESTDB/datafile/o1_mf_users_51qlgrqp_.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/oradata2/TESTDB/datafile/o1_mf_temp_%u_.tmp in control file
cataloged datafile copy
datafile copy file name=/u01/oradata2/TESTDB/datafile/o1_mf_sysaux_4vqlgrq7_.dbf RECID=1 STAMP=894988259
cataloged datafile copy
datafile copy file name=/u01/oradata2/TESTDB/datafile/o1_mf_undotbs1_50qlgrqm_.dbf RECID=2 STAMP=894988259
cataloged datafile copy
datafile copy file name=/u01/oradata2/TESTDB/datafile/o1_mf_users_51qlgrqp_.dbf RECID=3 STAMP=894988259
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=894988259 file name=/u01/oradata2/TESTDB/datafile/o1_mf_sysaux_4vqlgrq7_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=894988259 file name=/u01/oradata2/TESTDB/datafile/o1_mf_undotbs1_50qlgrqm_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=894988259 file name=/u01/oradata2/TESTDB/datafile/o1_mf_users_51qlgrqp_.dbf
Reenabling controlfile options for auxiliary database
Executing: alter database enable block change tracking
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 2015-11-05 15:49:38
RMAN>
5.打开辅助实例
登录到B机,
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Nov 5 16:06:29 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> select status, instance_name from v$instance;
STATUS INSTANCE_NAME
------------ ----------------
OPEN testdb
SQL> select dbid, open_mode from v$database;
DBID OPEN_MODE
---------- --------------------
2678316385 READ WRITE
至此,成功duplicate数据库TESTDB。可以发现使用RMAN DUPLICATE复制的数据库DBID是不同的。
本文内容不用于商业目的,如涉及知识产权问题,请权利人联系SPASVO小编(021-61079698-8054),我们将立即处理,马上删除。
相关推荐
在测试数据库性能时,需要注意哪些方面的内容?测试管理工具TC数据库报错的原因有哪些?怎么解决?数据库的三大范式以及五大约束编程常用的几种时间戳转换(java .net 数据库)优化mysql数据库的几个步骤数据库并行读取和写入之Python实现深入理解数据库(DB2)缓冲池(BufferPool)国内三大云数据库测试对比预警即预防:6大常见数据库安全漏洞数据库规划、设计与管理数据库-事务的概念SQL Server修改数据库物理文件存在位置使用PHP与SQL搭建可搜索的加密数据库用Python写一个NoSQL数据库详述 SQL 中的数据库操作详述 SQL 中的数据库操作Java面试准备:数据库MySQL性能优化
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11热门文章
常见的移动App Bug??崩溃的测试用例设计如何用Jmeter做压力测试QC使用说明APP压力测试入门教程移动app测试中的主要问题jenkins+testng+ant+webdriver持续集成测试使用JMeter进行HTTP负载测试Selenium 2.0 WebDriver 使用指南