Oracle11gR2使用RMAN duplicate复制数据库——Backup-based database duplicate

简介:

本实例测试ORACLE 11g使用rman复制数据库。11gRMAN duplicate 可以通过Active database duplicateBackup-based duplicate两种方法实现。这里的测试使用的是Backup-based duplicate

应用场景。基于Active database duplicate参考http://hbxztc.blog.51cto.com/1587495/1872754

    1、旧库或网络不可用,但是有备份

实验环境:

target db

ip 192.168.56.10

oracle_sid=mydb

oracle_version=11.2.0.3

auxiliary db

ip 192.168.56.150

oracle_sid=oradu

oracle_version=11.2.0.3

1、备份target db

RMAN> backup database include current controlfile plus archivelog delete all input;

 

Starting backup at 20-MAR-16

current log archived

using channel ORA_DISK_1

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=25 RECID=47 STAMP=906998693

input archived log thread=1 sequence=26 RECID=48 STAMP=906999061

channel ORA_DISK_1: starting piece 1 at 20-MAR-16

channel ORA_DISK_1: finished piece 1 at 20-MAR-16

piece handle=/u01/app/oracle/product/11.2.0/db/dbs/34r0vd8l_1_1 tag=TAG20160320T161101 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

channel ORA_DISK_1: deleting archived log(s)

archived log file name=/u01/app/oracle/product/11.2.0/db/dbs/arch/1_25_906314379.dbf RECID=47 STAMP=906998693

archived log file name=/u01/app/oracle/product/11.2.0/db/dbs/arch/1_26_906314379.dbf RECID=48 STAMP=906999061

Finished backup at 20-MAR-16

Starting backup at 20-MAR-16

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=/u01/app/oracle/oradata/mydb/system01.dbf

input datafile file number=00002 name=/u01/app/oracle/oradata/mydb/sysaux01.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/mydb/undotbs01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/mydb/users01.dbf

channel ORA_DISK_1: starting piece 1 at 20-MAR-16

channel ORA_DISK_1: finished piece 1 at 20-MAR-16

piece handle=/u01/app/oracle/product/11.2.0/db/dbs/35r0vd8m_1_1 tag=TAG20160320T161102 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

channel ORA_DISK_1: starting piece 1 at 20-MAR-16

channel ORA_DISK_1: finished piece 1 at 20-MAR-16

piece handle=/u01/app/oracle/product/11.2.0/db/dbs/36r0vdad_1_1 tag=TAG20160320T161102 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 20-MAR-16

Starting backup at 20-MAR-16

current log archived

using channel ORA_DISK_1

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=27 RECID=49 STAMP=906999120

channel ORA_DISK_1: starting piece 1 at 20-MAR-16

channel ORA_DISK_1: finished piece 1 at 20-MAR-16

piece handle=/u01/app/oracle/product/11.2.0/db/dbs/37r0vdag_1_1 tag=TAG20160320T161200 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

channel ORA_DISK_1: deleting archived log(s)

archived log file name=/u01/app/oracle/product/11.2.0/db/dbs/arch/1_27_906314379.dbf RECID=49 STAMP=906999120

Finished backup at 20-MAR-16

Starting Control File and SPFILE Autobackup at 20-MAR-16

piece handle=/u01/app/oracle/product/11.2.0/db/dbs/c-2820637901-20160320-05 comment=NONE

Finished Control File and SPFILE Autobackup at 20-MAR-16

2、复制参数文件和创建密码文件

--必须保持target DBauxiliary DB的密码一致。这里我直接把target db的密码文件复制到auxiliary db对应的目录下

--target db上执行

[oracle@localhost ~]$ cd $ORACLE_HOME/dbs

[oracle@localhost dbs]$ scp orapwmydb oracle@192.168.56.150:/home/oracle

oracle@192.168.56.150's password: 

orapwmydb                                     100% 1536     1.5KB/s   00:00    

[oracle@localhost dbs]$ scp initmydb.ora oracle@192.168.56.150:/home/oracle

oracle@192.168.56.150's password: 

initmydb.ora                                  100%  193     0.2KB/s   00:00    

3、把旧机器的备份复制到新机器上的对应目录

[oracle@localhost dbs]$ scp /u01/app/oracle/product/11.2.0/db/dbs/34r0vd8l_1_1 oracle@192.168.56.150:/home/oracle/bak

oracle@192.168.56.150's password: 

34r0vd8l_1_1                                  100% 5457KB   5.3MB/s   00:00    

[oracle@localhost dbs]$ scp /u01/app/oracle/product/11.2.0/db/dbs/35r0vd8m_1_1 oracle@192.168.56.150:/home/oracle/bak

oracle@192.168.56.150's password: 

35r0vd8m_1_1                                  100% 1049MB  15.0MB/s   01:10    

[oracle@localhost dbs]$ scp /u01/app/oracle/product/11.2.0/db/dbs/36r0vdad_1_1 oracle@192.168.56.150:/home/oracle/bak

oracle@192.168.56.150's password: 

36r0vdad_1_1                                  100% 9952KB   9.7MB/s   00:00    

[oracle@localhost dbs]$ scp /u01/app/oracle/product/11.2.0/db/dbs/37r0vdag_1_1 oracle@192.168.56.150:/home/oracle/bak

oracle@192.168.56.150's password: 

37r0vdag_1_1                                  100%   10KB  10.0KB/s   00:00    

4、更改密码文件、参数文件的文件名和参数文件中的对应的实例名(实例名不变时不需要执行),

把目录转换参数加入参数文件中(实例名、目录不变时不需要)

本实验中更新实例名为oradu

[oracle@localhost ~]$ mv initmydb.ora initoradu.ora

[oracle@localhost ~]$ mv orapwmydb orapworadu

vi initoradu.ora把所有的旧实例名mydb改为oradu,并加入转换参数

db_file_name_convert=('/u01/app/oracle/oradata/mydb/','/u01/app/oracle/oradata/oradu/')

log_file_name_convert=('/u01/app/oracle/oradata/mydb/','/u01/app/oracle/oradata/oradu/')

新建目录

mkdir -p /u01/app/oracle/oradata/oradu/

不改变实例名只需要新建目录

mkdir -p /u01/app/oracle/oradata/mydb/

移动参数文件和密码文件到默认目录中/u01/app/oracle/product/11.2.0/db/dbs/

[oracle@localhost ~]$ mv initoradu.ora /u01/app/oracle/product/11.2.0/db/dbs/

[oracle@localhost ~]$ mv orapworadu /u01/app/oracle/product/11.2.0/db/dbs/

5、启动到nomount

[oracle@localhost ~]$ export ORACLE_SID=oradu

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Sun Mar 20 16:31:43 2016

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> create spfile from pfile;

File created.

SQL> startup nomount; 

ORACLE instance started.

Total System Global Area  238034944 bytes

Fixed Size                  2227136 bytes

Variable Size             180356160 bytes

Database Buffers           50331648 bytes

Redo Buffers                5120000 bytes

SQL> 

6、使用RMAN开始复制

[oracle@localhost ~]$ rman auxiliary /

Recovery Manager: Release 11.2.0.3.0 - Production on Sun Mar 20 16:33:11 2016

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to auxiliary database: ORADU (not mounted)

RMAN> duplicate database to oradu backup location '/home/oracle/bak';

Starting Duplicate Db at 20-MAR-16

contents of Memory Script:

{

   sql clone "alter system set  db_name = 

 ''MYDB'' comment=

 ''Modified by RMAN duplicate'' scope=spfile";

   sql clone "alter system set  db_unique_name = 

 ''ORADU'' comment=

 ''Modified by RMAN duplicate'' scope=spfile";

   shutdown clone immediate;

   startup clone force nomount

   restore clone primary controlfile from  '/home/oracle/bak/36r0vdad_1_1';

   alter clone database mount;

}

executing Memory Script

sql statement: alter system set  db_name =  ''MYDB'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set  db_unique_name =  ''ORADU'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area     238034944 bytes

Fixed Size                     2227136 bytes

Variable Size                180356160 bytes

Database Buffers              50331648 bytes

Redo Buffers                   5120000 bytes

Starting restore at 20-MAR-16

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=18 device type=DISK

channel ORA_AUX_DISK_1: restoring control file

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02

output file name=/u01/app/oracle/oradata/oradu/control01.ctl

output file name=/u01/app/oracle/oradata/oradu/control02.ctl

Finished restore at 20-MAR-16

database mounted

released channel: ORA_AUX_DISK_1

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=18 device type=DISK

contents of Memory Script:

{

   set until scn  2815228;

   set newname for datafile  1 to 

 "/u01/app/oracle/oradata/oradu/system01.dbf";

   set newname for datafile  2 to 

 "/u01/app/oracle/oradata/oradu/sysaux01.dbf";

   set newname for datafile  3 to 

 "/u01/app/oracle/oradata/oradu/undotbs01.dbf";

   set newname for datafile  4 to 

 "/u01/app/oracle/oradata/oradu/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 20-MAR-16

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 /u01/app/oracle/oradata/oradu/system01.dbf

channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/oradu/sysaux01.dbf

channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/oradu/undotbs01.dbf

channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/oradu/users01.dbf

channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/bak/35r0vd8m_1_1

channel ORA_AUX_DISK_1: piece handle=/home/oracle/bak/35r0vd8m_1_1 tag=TAG20160320T161102

channel ORA_AUX_DISK_1: restored backup piece 1

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:05

Finished restore at 20-MAR-16

contents of Memory Script:

{

   switch clone datafile all;

}

executing Memory Script

datafile 1 switched to datafile copy

input datafile copy RECID=5 STAMP=907000504 file name=/u01/app/oracle/oradata/oradu/system01.dbf

datafile 2 switched to datafile copy

input datafile copy RECID=6 STAMP=907000504 file name=/u01/app/oracle/oradata/oradu/sysaux01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=7 STAMP=907000504 file name=/u01/app/oracle/oradata/oradu/undotbs01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=8 STAMP=907000504 file name=/u01/app/oracle/oradata/oradu/users01.dbf

contents of Memory Script:

{

   set until scn  2815228;

   recover

   clone database

    delete archivelog

   ;

}

executing Memory Script

executing command: SET until clause

Starting recover at 20-MAR-16

using channel ORA_AUX_DISK_1

starting media recovery

channel ORA_AUX_DISK_1: starting archived log restore to default destination

channel ORA_AUX_DISK_1: restoring archived log

archived log thread=1 sequence=27

channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/bak/37r0vdag_1_1

channel ORA_AUX_DISK_1: piece handle=/home/oracle/bak/37r0vdag_1_1 tag=TAG20160320T161200

channel ORA_AUX_DISK_1: restored backup piece 1

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01

archived log file name=/u01/app/oracle/product/11.2.0/db/dbs/arch1_27_906314379.dbf thread=1 sequence=27

channel clone_default: deleting archived log(s)

archived log file name=/u01/app/oracle/product/11.2.0/db/dbs/arch1_27_906314379.dbf RECID=1 STAMP=907000505

media recovery complete, elapsed time: 00:00:01

Finished recover at 20-MAR-16

Oracle instance started

Total System Global Area     238034944 bytes

Fixed Size                     2227136 bytes

Variable Size                180356160 bytes

Database Buffers              50331648 bytes

Redo Buffers                   5120000 bytes

contents of Memory Script:

{

   sql clone "alter system set  db_name = 

 ''ORADU'' 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 =  ''ORADU'' 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                     2227136 bytes

Variable Size                180356160 bytes

Database Buffers              50331648 bytes

Redo Buffers                   5120000 bytes

sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORADU" RESETLOGS ARCHIVELOG 

  MAXLOGFILES     16

  MAXLOGMEMBERS      3

  MAXDATAFILES      100

  MAXINSTANCES     8

  MAXLOGHISTORY      292

 LOGFILE

  GROUP   1 ( '/u01/app/oracle/oradata/oradu/redo01.log', '/u01/app/oracle/oradata/oradu/redo01_01.log' ) SIZE 100 M  REUSE,

  GROUP   2 ( '/u01/app/oracle/oradata/oradu/redo02.log', '/u01/app/oracle/oradata/oradu/redo02_01.log' ) SIZE 100 M  REUSE,

  GROUP   3 ( '/u01/app/oracle/oradata/oradu/redo03.log', '/u01/app/oracle/oradata/oradu/redo03_01.log' ) SIZE 100 M  REUSE,

  GROUP   4 ( '/u01/app/oracle/oradata/oradu/redo04.log', '/u01/app/oracle/oradata/oradu/redo04_01.log' ) SIZE 100 M  REUSE

 DATAFILE

  '/u01/app/oracle/oradata/oradu/system01.dbf'

 CHARACTER SET ZHS16GBK

contents of Memory Script:

{

   set newname for tempfile  1 to 

 "/u01/app/oracle/oradata/oradu/temp01.dbf";

   switch clone tempfile all;

   catalog clone datafilecopy  "/u01/app/oracle/oradata/oradu/sysaux01.dbf", 

 "/u01/app/oracle/oradata/oradu/undotbs01.dbf", 

 "/u01/app/oracle/oradata/oradu/users01.dbf";

   switch clone datafile all;

}

executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/oradata/oradu/temp01.dbf in control file

cataloged datafile copy

datafile copy file name=/u01/app/oracle/oradata/oradu/sysaux01.dbf RECID=1 STAMP=907000517

cataloged datafile copy

datafile copy file name=/u01/app/oracle/oradata/oradu/undotbs01.dbf RECID=2 STAMP=907000517

cataloged datafile copy

datafile copy file name=/u01/app/oracle/oradata/oradu/users01.dbf RECID=3 STAMP=907000517

datafile 2 switched to datafile copy

input datafile copy RECID=1 STAMP=907000517 file name=/u01/app/oracle/oradata/oradu/sysaux01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=2 STAMP=907000517 file name=/u01/app/oracle/oradata/oradu/undotbs01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=3 STAMP=907000517 file name=/u01/app/oracle/oradata/oradu/users01.dbf

Reenabling controlfile options for auxiliary database

Executing: alter database add supplemental log data

contents of Memory Script:

{

   Alter clone database open resetlogs;

}

executing Memory Script

database opened

Finished Duplicate Db at 20-MAR-16

RMAN> 

7、验证是否可用

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Sun Mar 20 16:36:52 2016

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name,open_mode from v$database;

NAME      OPEN_MODE

--------- --------------------

ORADU     READ WRITE






     本文转自hbxztc 51CTO博客,原文链接:http://blog.51cto.com/hbxztc/1896881,如需转载请自行联系原作者




相关文章
|
9天前
|
Oracle 关系型数据库 网络安全
崖山异构数据库迁移利器YMP初体验-Oracle迁移YashanDB
文章是作者小草对崖山异构数据库迁移利器 YMP 的初体验分享,包括背景、YMP 简介、体验环境说明、YMP 部署(含安装前准备、安装、卸载、启动与停止)、数据迁移及遇到的问题与解决过程。重点介绍了 YMP 功能、部署的诸多细节和数据迁移流程,还提到了安装和迁移中遇到的问题及解决办法。
|
6天前
|
数据库
【YashanDB数据库】YAS-02079 archive log mode must be enabled when database is in replication mode
YAS-02079 archive log mode must be enabled when database is in replication mode
|
3月前
|
存储 Oracle 关系型数据库
数据库数据恢复—ORACLE常见故障的数据恢复方案
Oracle数据库常见故障表现: 1、ORACLE数据库无法启动或无法正常工作。 2、ORACLE ASM存储破坏。 3、ORACLE数据文件丢失。 4、ORACLE数据文件部分损坏。 5、ORACLE DUMP文件损坏。
194 11
|
4月前
|
Oracle 关系型数据库 数据库
Oracle数据恢复—Oracle数据库文件有坏快损坏的数据恢复案例
一台Oracle数据库打开报错,报错信息: “system01.dbf需要更多的恢复来保持一致性,数据库无法打开”。管理员联系我们数据恢复中心寻求帮助,并提供了Oracle_Home目录的所有文件。用户方要求恢复zxfg用户下的数据。 由于数据库没有备份,无法通过备份去恢复数据库。
|
4月前
|
存储 Oracle 关系型数据库
oracle数据恢复—Oracle数据库文件大小变为0kb的数据恢复案例
存储掉盘超过上限,lun无法识别。管理员重组存储的位图信息并导出lun,发现linux操作系统上部署的oracle数据库中有上百个数据文件的大小变为0kb。数据库的大小缩水了80%以上。 取出&并分析oracle数据库的控制文件。重组存储位图信息,重新导出控制文件中记录的数据文件,发现这些文件的大小依然为0kb。
|
4月前
|
SQL Oracle 关系型数据库
Oracle数据库优化方法
【10月更文挑战第25天】Oracle数据库优化方法
88 7
|
4月前
|
存储 Oracle 关系型数据库
Oracle数据库优化策略
【10月更文挑战第25天】Oracle数据库优化策略
61 5
|
3月前
|
存储 Oracle 关系型数据库
服务器数据恢复—华为S5300存储Oracle数据库恢复案例
服务器存储数据恢复环境: 华为S5300存储中有12块FC硬盘,其中11块硬盘作为数据盘组建了一组RAID5阵列,剩下的1块硬盘作为热备盘使用。基于RAID的LUN分配给linux操作系统使用,存放的数据主要是Oracle数据库。 服务器存储故障: RAID5阵列中1块硬盘出现故障离线,热备盘自动激活开始同步数据,在同步数据的过程中又一块硬盘离线,RAID5阵列瘫痪,上层LUN无法使用。
|
10月前
|
SQL Oracle 关系型数据库
WARNING: Too Many Parse Errors With error=911 When Running a JDBC Application Connected to an Oracle 19c database
WARNING: Too Many Parse Errors With error=911 When Running a JDBC Application Connected to an Oracle 19c database (
138 2
|
10月前
|
Oracle 关系型数据库
19c 开启Oracle Database Vault
19c 开启Oracle Database Vault
197 1

推荐镜像

更多