在相同的主机上创建一个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>

在相同的主机上创建一个duplicate数据库的更多相关文章

  1. 记一次oracle创建一个新数据库,并导入正式环境数据库备份的dmp包过程

    背景:正式环境oracle数据库定时用exp备份一个dmp包,现在打算在一台机器上创建一个新数据库,并导入这个dmp包. 1.创建数据库 开始 -> 所有程序 -> Oracle -> ...

  2. git 从分支上创建一个分支

    相关连接: 创建于合并分支:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00 ...

  3. 用ssh-key-gen 在本地主机上创建公钥和密钥

    用ssh-key-gen 在本地主机上创建公钥和密钥 ligh@local-host$ ssh-keygen -t rsa

  4. 创建一个 SQLite 数据库

    首先,我们学习如何创建一个SQLite 数据库.如果想要在data/example.sqlite 这个路径中创建一个示例数据库,就必须确保该路径存在.如果该路径不存在,就必须先创建路径:if (!di ...

  5. 如何创建一个 PostgreSQL 数据库?

    PostgreSQL 官网截图 PostgreSQL 是什么? PostgreSQL 是一个功能非常强大的,历史悠久,开源的关系数据库.PostgreSQL支持大部分的SQL标准并且提供了很多其他现代 ...

  6. [ASP.NET MVC2 系列] ASP.Net MVC教程之《在15分钟内用ASP.Net MVC创建一个电影数据库应用程序》

    [ASP.NET MVC2 系列]      [ASP.NET MVC2 系列] ASP.Net MVC教程之<在15分钟内用ASP.Net MVC创建一个电影数据库应用程序>       ...

  7. 在一个空ASP.NET Web项目上创建一个ASP.NET Web API 2.0应用

    由于ASP.NET Web API具有与ASP.NET MVC类似的编程方式,再加上目前市面上专门介绍ASP.NET Web API 的书籍少之又少(我们看到的相关内容往往是某本介绍ASP.NET M ...

  8. 如何在github上创建一个Repository (Windows)

    一种方式是利用Github for windows工具 来操作github,这个是我推荐的方式 1 请先下载一个工具Github for windows,下载地址为:https://windows.g ...

  9. 当网卡收到的包的目的地址是主机上另一个网卡的地址.arp总结

    2019/01/13 今天测试发现结果不符合预期呀,发现设置了arp_filter之后,仍然是能ping通主机上的另外一张网卡.但是现在的问题是 -------------------- 内核中是如何 ...

随机推荐

  1. 总结一下这几天学习django的心得

    总结一下这几天学习django的心得 http://www.tuicool.com/articles/jMVB3e 时间 2014-01-12 11:40:11  CSDN博客 原文  http:// ...

  2. 使用PHP发送邮件的两种方法

    使用PHP发送邮件的两种方法 May242013 作者:Jerry Bendy   发布:2013-05-24 22:25   分类:PHP   阅读:2,107 views   抢沙发     今天 ...

  3. apache磁盘缓存配置

    确保mod_cache和mod_disk_cache是开启的 配置如下: CacheDefaultExpire 86400 #失效时间,单位秒CacheEnable disk /      #缓存路径 ...

  4. 初学Java语法(笔记)

    2015-12-30

  5. word 使用宏批量设置表格

    Sub ChangeTable() Application.Browser.Target = wdBrowseTable To ActiveDocument.Tables.Count ActiveDo ...

  6. Java管道流

    管道流的主要作用可以用于两个线程之间的通信,有管道输出流 PipeOutputStream和管道输入流 PipeInputStream.然后通过connect将两个管道连接起来. import jav ...

  7. SQL查询语句中的 limit offset(转 )

    经常用到在数据库中查询中间几条数据的需求 比如下面的sql语句: ① selete * from testtable limit 2,1; ② selete * from testtable limi ...

  8. nginx配置相关

    一.autoindex on; 能解决无端端的403问题. 二.NGINX配置超时时间 1.啥时候用到 用来设置请求资源和服务器返回的时间,保证一个请求占用固定时间,超出后报504超时!这样可以保证一 ...

  9. Jquery小例子:全选按钮、加事件、挂事件;parent()语法;slideToggle()语法;animate()语法;元素的淡入淡出效果:fadeIn() 、fadeOut()、fadeToggle() 、fadeTo();function(e):e包括事件源和时间数据;append() 方法

    function(e): 事件包括事件源和事件数据,事件源是指是谁触发的这个事件,谁就是事件源(div,按钮,span都可以是事件源),时间数据是指比如点击鼠标的事件中,事件数据就是指点击鼠标的左建或 ...

  10. mysql 数据库封装类:返回索引、关联、字符串数组;分页查询封装类 :$page=new Page(表的总条数,每页的条数);$sql = "".$page->limit; echo $page->fpage();

    <?php class czy { public $host="localhost"; //地址 public $uid="root"; //用户名 pu ...