Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2800119
  • 博文数量: 389
  • 博客积分: 4177
  • 博客等级: 上校
  • 技术积分: 4773
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-16 23:29
文章分类

全部博文(389)

分类: Oracle

2014-03-09 11:20:17

                                      使用targetless duplicate数据库

    RMAN的duplicate为我们克隆数据库提供了很大的方便,但是在以前的版本中,使用duplicate时还是需要连接到target
库上进行duplicate上.这样也有一些实际上的不方便之处,主要是:1,使用duplicate时,必须连接到target库上传输数
据文件,这样每次都需要传输,有时候带宽不够,需要很长时间;2,对target库每次duplicate都会有性能影响;3,在某些
场景下,可能无法连接到target库,只能通过第三方人员拿到备份.

 在11.2后实现了一种叫作targetless的特性用来解决这些问题,只需要完整的target rman backupset就可以在另一个地
方进行duplicate数据库,而不需要直接连接到target库.

环境:oracle database 12c,RHEL 5.5


比如生产库的名字为c12,直接duplicate同一台物理机上的bak12数据库上,数据目录为/u02/bak12

准备目录
[oracle@o12c u02]$ mkdir -p /u02/bak

[oracle@o12c u02]$ mkdir -p /u02/bak12
[oracle@o12c bak12]$ mkdir -p /u02/bak12/pdb2
[oracle@o12c bak12]$ mkdir -p /u02/bak12/pdbseed

验证一下源库的某个表

[oracle@o12c ~]$ export ORACLE_SID=c12

SQL>  select count(*) from c##frank.FS1;

  COUNT(*)
----------
         7


对c12进行备份

RMAN> backup format '/u02/bak/%U' database plus archivelog;


Starting backup at 28-JAN-14
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=262 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=1 RECID=1 STAMP=838050046
input archived log thread=1 sequence=2 RECID=2 STAMP=838050256

............................

RMAN> backup current controlfile format '/u02/bak/control.bak';


[oracle@o12c bak]$ pwd
/u02/bak
[oracle@o12c bak]$ ls
03ov78eh_1_1  04ov78ej_1_1  05ov78h8_1_1  06ov78ic_1_1  07ov78jg_1_1


编写bak12实例的参数文件.

[oracle@o12c ~]$ vi bak12.ora


db_name=bak12
control_files='/u02/bak12/control01.ctl','/u02/bak12/control02.ctl'
memory_target=800M
compatible='12.1.0.0.0'
db_file_name_convert=('/u01/app/oracle/oradata/c12/','/u02/bak12/')
db_file_name_convert=('/u01/app/oracle/product/12.1.0/db_1/dbs/','/u02/bak12/')
db_file_name_convert=('/home/oracle/','/u02/bak12/')
db_file_name_convert=('/u01/app/oracle/oradata/c12/pdb2/','/u02/bak12/')
db_file_name_convert=('/u01/app/oracle/oradata/c12/pdbseed/','/u02/bak12/')
log_file_name_convert=('/u01/app/oracle/oradata/c12/','/u02/bak12/')
enable_pluggable_database=true  --如果没有启用cdb,则省略该参数.

 


实动新的实例

[oracle@o12c ~]$ export ORACLE_SID=bak12
[oracle@o12c ~]$ sqlplus /nolog

SQL> startup nomount pfile='/home/oracle/bak12.ora';
ORACLE instance started.

Total System Global Area  835104768 bytes
Fixed Size                  2293880 bytes
Variable Size             490737544 bytes
Database Buffers          335544320 bytes
Redo Buffers                6529024 bytes
SQL>

[oracle@o12c bak]$ export ORACLE_SID=bak12

[oracle@o12c bak]$ $ORACLE_HOME/bin/rman auxiliary /  nocatalog   --不需要定义 target

RMAN> run
2> {
3> allocate auxiliary channel c1 device type disk; --通道类型为auxiliary
4> allocate auxiliary channel c2 device type disk;
5> duplicate  database to bak12
6> backup location '/u02/bak/'
7> nofilenamecheck;
8> }

allocated channel: c1
channel c1: SID=11 device type=DISK

allocated channel: c2
channel c2: SID=113 device type=DISK

Starting Duplicate Db at 28-JAN-14

contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''C12'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =
 ''BAK12'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone primary controlfile from  '/u02/bak/control.bak';
   alter clone database mount;
}
executing Memory Script
.......................

 

增加临时表空间


SQL> create temporary tablespace tmp tempfile '/u02/bak12/tmp01.dbf' size 500M;

Tablespace created.

SQL> alter database default temporary tablespace tmp;

Database altered.

 

验证一下,确认现在已经是duplicate一个新的数据库了.

SQL> select name from v$database;

NAME
---------
BAK12

SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE


SQL>  select count(*) from c##frank.FS1;

  COUNT(*)
----------
         7

 

 

 

阅读(3040) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~