使用RMAN工具克隆生产数据库

一.概述

复制数据库即使用RMAN工具的DUPLICATE命令从源数据库拷贝所有或者一部分的数据到目标数据库。复制数据库技术在多种场景都是特别有用的,如创建standby数据库,创建用于不同目的地测试环境,数据库迁移等。

使用DUPLICATE命令复制数据库能自动配置与源数据库不同的DBID,确保目标数据库和源数据库能一起存放在相同的恢复目录数据库中。

RMAN支持两种复制类型:活动数据库复制和基本备份的复制。RMAN能在源数据库和恢复目录数据库存在或者不存在的情况下执行基于备份的复制。

活动数据库复制要求同时连接到源数据库和恢复目标数据库,如果使用恢复目录作为元数据的存储,那么还需要连接到恢复目录数据库。

对于复制技术的选择可以考虑如下因素,活动数据库复制最主要的优势不要求源数据库备份。这个技术的缺点是在复制过程中长时间消耗服务器资源,这对源数据库会产生一定的影响。

二.活动数据库复制准备工作

在活动数据复制中,RMAN连接到作为目标数据库实例和辅助实例,RMAN通过网络拷贝源数据库到辅助实例,由此创建复制数据库,这并不需要先创建源数据库库备份

实际的复制工作是源数据库和辅助实例通过它们之间的网络完成的,源数据库实例和辅助数据库实例之间的网络由Oracle Net实现。

执行数据库复制操作,源数据库和复制数据库必须是相同的平台,在执行活动数据库复制操作之前需要完成以下准备工作:

(1)数据库空间要求

确保目标主机有足够的存储空间存放数据库的数据

(2)源和目标主机通过LAN或者WAN进行连接

在WAN中活动数据库复制的性能可能比LAN(本地区域网络)更慢,如果WAN的性能变得不可接受,那么基于备份的复制可能变成唯一的选择了,如果在多用户活动期间复制数据库,可能导致网络吞吐量下降,这种情况最好的选择基于备份的复制。

(3)复制文件的命名策略

当复制数据库是,RMAN为复制控制文件,数据文件,临时文件和联机REDO日志文件生成名称。因此,必须制定这些文件的命名策略

Oracle推荐简单的复制策略,配置与源数据库相同的名称,使用相同名称意思是环境要符合下列要求:

如果源数据库使用ASM磁盘组,那么复制数据库必须使用相同名称的磁盘组

如果源数据库文件是Oracle管理的文件(OMF),那么辅助实例必须设置DB_FILE_CREATE_DEST参数,指定与源数据库相同的目录位置,源和目标主机的目录相同,Oracle数据库为复制文件创建相应的名称。

源数据库和复制数据库要有相同的路径存放数据库文件

按照以上建议配置环境,就不需要额外的配置工作了

(4)Oracle Net 连通性

要确保源数据库到辅助实例之间的Oracle Net的连通性,如果源数据库是RAC数据库,确保RAC数据库的所有节点都可以建立于辅助实例之间的网络连接

(5) 为辅助实例创建密码文件

手动创建密码文件,活动复制要求原数据库和辅助实例使用相同的密码,默认使用SYS用户

(6)创建初始化参数文件

手动创建初始化参数文件

在DUPLICATE 命令中明确指定SPFILE选项

(7)确保源数据库处于正常状态

(8)基本步骤如下:a.连接到源数据库,b.连接到辅助实例,c.连接到恢复目录数据库(如果有的话)

切换归档redo日志 :ALTER SYSTEM ARCHIVE LOG CURRENT

执行DULICATE 命令复制活动的数据库

DUPLICATE TARGET DATABASE TO "目标数据库实例"

FROM ACTIVE DATABASE

PASSWORD FILE

SPFILE

NOFILENAMECHECK; 源数据库数据文件,密码文件,参数文件和辅助实例具有相同的目录结构;

成功执行上面命令必须确保源数据库在归档模式,以及至少产生一次归档。

三.完整的活动数据库复制实例:

(1).源数据库实例CPP,目标数据库实例MES,Oracle Net配置:

源库:cat listener.ora 
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = orcl1)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /u01/oracle

如果目标库和源库都在同一台服务器上,必须在源库的监听器上静态注册目标实例和源实例,否则当目标库nomount后,PMON进程会动态注册监听,此时监听会一直处于BLOCKED状态,无法完成复制:

(SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = PHUB)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) 源库静态监听注册
      (SID_NAME = PHUB)
    )
  )
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = MECBS)
      (ORACLE_HOME = /u03/app/oracle/product/11.2.0/db_1)---目标库静态监听
      (SID_NAME = MECBS)
    )
  )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.180)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle)

cat tnsnames.ora

CPP =

(DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.175)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = CPP)
    )
  )
MES =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.176)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = MES)
    )
  )

目标库: cat listener.ora 
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = orcl2)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )
ADR_BASE_LISTENER = /u01/oracle
SID_LIST_LISTENER=
(SID_LIST=
        (SID_DESC=
           (GLOBAL_DBNAME=MES)
          (SID_NAME=MES)
          (ORACLE_HOME=/u01/oracle/product/11.2.0/db_1)
        )

)

cat tnsnames.ora 
CPP =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.175)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = CPP)
    )

)
MES =
(DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.176)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = MES)
    )

)

配置完成后用tnsping检测网络连通性

(2)将源库的密码文件拷贝到目标库,并重新命名:

scp orapwCPP 192.168.1.176:/u01/oracle/product/11.2.0/db_1/dbs/orapwMES

(3)拷贝源库的参数文件,根据实际情况修改参数文件

MES.__java_pool_size=4194304
MES.__large_pool_size=12582912
MES.__oracle_base=‘/u01/oracle‘#ORACLE_BASE set from environment
MES.__pga_aggregate_target=314572800
MES.__sga_target=469762048
MES.__shared_io_pool_size=0
MES.__shared_pool_size=184549376
MES.__streams_pool_size=4194304

*.db_create_file_dest=‘/u01/oracle/oradata/‘

*.audit_file_dest=‘/u01/oracle/admin/MES/adump‘ --注意在目标库上创建相应的目录
*.audit_trail=‘db‘
*.compatible=‘11.2.0.4.0‘
*.control_files=‘/u01/oracle/oradata/ MES/control01.ctl‘,‘/u01/oracle/fast_recovery_area/MES/control02.ctl‘
*.db_block_size=8192
*.db_domain=‘‘
*.db_name=‘MES‘
*.db_recovery_file_dest=‘/u01/oracle/fast_recovery_area‘
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest=‘/u01/oracle‘
*.dispatchers=‘(PROTOCOL=TCP) (SERVICE=CPPXDB)‘
*.memory_target=784334848
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile=‘EXCLUSIVE‘
*.undo_tablespace=‘UNDOTBS1‘

(4)启动目标数据到NOMOUNT状态

[email protected] dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Wed Oct 15 12:08:33 2014
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to an idle instance.
ORACLE instance started.
Total System Global Area  780824576 bytes
Fixed Size
   2257312 bytes
Variable Size
 511708768 bytes
Database Buffers 260046848 bytes
Redo Buffers
   6811648 bytes

(5)在源数据库上执行复制:

[[email protected] dbs]$ rman target / auxiliary sys/[email protected]/MES
Recovery Manager: Release 11.2.0.4.0 - Production on Wed Oct 15 13:31:54 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: CPP (DBID=3676002607)
connected to auxiliary database: MES (not mounted)
RMAN> duplicate target database to mes from active database nofilenamecheck;
Starting Duplicate Db at 2014-10-15 13:32:20
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=129 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     780824576 bytes
Fixed Size                     2257312 bytes
Variable Size                515903072 bytes
Database Buffers             255852544 bytes
Redo Buffers                   6811648 bytes
contents of Memory Script:
{
    sql clone "alter system set  db_name = 
  ‘‘CPP‘‘ comment=
  ‘‘Modified by RMAN duplicate‘‘ scope=spfile";
    sql clone "alter system set  db_unique_name = 
  ‘‘MES‘‘ comment=
  ‘‘Modified by RMAN duplicate‘‘ scope=spfile";
   shutdown clone immediate;
    startup clone force nomount
    backup as copy current controlfile auxiliary format  ‘/u01/oracle/oradata/MES/control01.ctl‘;
   restore clone controlfile to  ‘/u01/oracle/fast_recovery_area/MES/control02.ctl‘ from 
 ‘/u01/oracle/oradata/MES/control01.ctl‘;
   alter clone database mount;
}
executing Memory Script
sql statement: alter system set  db_name =  ‘‘CPP‘‘ comment= ‘‘Modified by RMAN duplicate‘‘ scope=spfile
sql statement: alter system set  db_unique_name =  ‘‘MES‘‘ comment= ‘‘Modified by RMAN duplicate‘‘ scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area     780824576 bytes
Fixed Size                     2257312 bytes
Variable Size                515903072 bytes
Database Buffers             255852544 bytes
Redo Buffers                   6811648 bytes
Starting backup at 2014-10-15 13:32:48
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/oracle/product/11.2.0/db_1/dbs/snapcf_CPP.f tag=TAG20141015T133249 RECID=8 STAMP=861024770
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 2014-10-15 13:32:52
Starting restore at 2014-10-15 13:32:53
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=63 device type=DISK
channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 2014-10-15 13:32:55
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;
    set newname for clone datafile  5 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
   datafile  5 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
executing command: SET NEWNAME
Starting backup at 2014-10-15 13:33:00
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/oracle/oradata/CPP/system01.dbf
output file name=/u01/oracle/oradata/MES/datafile/o1_mf_system_0jpl4cgd_.dbf tag=TAG20141015T133301
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/oracle/oradata/CPP/sysaux01.dbf
output file name=/u01/oracle/oradata/MES/datafile/o1_mf_sysaux_0kpl4cif_.dbf tag=TAG20141015T133301
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/oracle/oradata/CPP/example01.dbf
output file name=/u01/oracle/oradata/MES/datafile/o1_mf_example_0lpl4cjs_.dbf tag=TAG20141015T133301
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/oracle/oradata/CPP/undotbs01.dbf
output file name=/u01/oracle/oradata/MES/datafile/o1_mf_undotbs1_0mpl4ckv_.dbf tag=TAG20141015T133301
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:16
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/oracle/oradata/CPP/users01.dbf
output file name=/u01/oracle/oradata/MES/datafile/o1_mf_users_0npl4clf_.dbf tag=TAG20141015T133301
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2014-10-15 13:35:44
sql statement: alter system archive log current
contents of Memory Script:
{
    backup as copy reuse
    archivelog like  "/arch/cpp/ARC0000000024_0861010994.0001_db1b592f.log" auxiliary format 
  "/arch/MES/ARC0000000024_0861010994.0001_db1b592f.log"   ;
   catalog clone archivelog  "/arch/MES/ARC0000000024_0861010994.0001_db1b592f.log";  switch clone datafile all;
}
executing Memory Script
Starting backup at 2014-10-15 13:35:46
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=24 RECID=18 STAMP=861024945
output file name=/arch/MES/ARC0000000024_0861010994.0001_db1b592f.log RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 2014-10-15 13:35:47
cataloged archived log
archived log file name=/arch/MES/ARC0000000024_0861010994.0001_db1b592f.log RECID=18 STAMP=861024947
datafile 1 switched to datafile copy
input datafile copy RECID=8 STAMP=861024947 file name=/u01/oracle/oradata/MES/datafile/o1_mf_system_0jpl4cgd_.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=9 STAMP=861024947 file name=/u01/oracle/oradata/MES/datafile/o1_mf_sysaux_0kpl4cif_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=10 STAMP=861024947 file name=/u01/oracle/oradata/MES/datafile/o1_mf_undotbs1_0mpl4ckv_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=11 STAMP=861024947 file name=/u01/oracle/oradata/MES/datafile/o1_mf_users_0npl4clf_.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=12 STAMP=861024947 file name=/u01/oracle/oradata/MES/datafile/o1_mf_example_0lpl4cjs_.dbf
contents of Memory Script:
{
    set until scn  1028509;
    recover
    clone database
    delete archivelog
    ;
}
executing Memory Script
executing command: SET until clause
Starting recover at 2014-10-15 13:35:48
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 24 is already on disk as file /arch/MES/ARC0000000024_0861010994.0001_db1b592f.log
archived log file name=/arch/MES/ARC0000000024_0861010994.0001_db1b592f.log thread=1 sequence=24
media recovery complete, elapsed time: 00:00:00
Finished recover at 2014-10-15 13:35:52
Oracle instance started
Total System Global Area     780824576 bytes
Fixed Size                     2257312 bytes
Variable Size                515903072 bytes
Database Buffers             255852544 bytes
Redo Buffers                   6811648 bytes
contents of Memory Script:
{
    sql clone "alter system set  db_name = 
  ‘‘MES‘‘ 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 =  ‘‘MES‘‘ 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     780824576 bytes
Fixed Size                     2257312 bytes
Variable Size                515903072 bytes
Database Buffers             255852544 bytes
Redo Buffers                   6811648 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "MES" 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/oracle/oradata/MES/datafile/o1_mf_system_0jpl4cgd_.dbf‘
  CHARACTER SET AL32UTF8
contents of Memory Script:
{
    set newname for clone tempfile  1 to new;
    switch clone tempfile all;
    catalog clone datafilecopy  "/u01/oracle/oradata/MES/datafile/o1_mf_sysaux_0kpl4cif_.dbf", 
  "/u01/oracle/oradata/MES/datafile/o1_mf_undotbs1_0mpl4ckv_.dbf", 
  "/u01/oracle/oradata/MES/datafile/o1_mf_users_0npl4clf_.dbf", 
  "/u01/oracle/oradata/MES/datafile/o1_mf_example_0lpl4cjs_.dbf";
    switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/oracle/oradata/MES/datafile/o1_mf_temp_%u_.tmp in control file
cataloged datafile copy
datafile copy file name=/u01/oracle/oradata/MES/datafile/o1_mf_sysaux_0kpl4cif_.dbf RECID=1 STAMP=861024971
cataloged datafile copy
datafile copy file name=/u01/oracle/oradata/MES/datafile/o1_mf_undotbs1_0mpl4ckv_.dbf RECID=2 STAMP=861024971
cataloged datafile copy
datafile copy file name=/u01/oracle/oradata/MES/datafile/o1_mf_users_0npl4clf_.dbf RECID=3 STAMP=861024971
cataloged datafile copy
datafile copy file name=/u01/oracle/oradata/MES/datafile/o1_mf_example_0lpl4cjs_.dbf RECID=4 STAMP=861024971
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=861024971 file name=/u01/oracle/oradata/MES/datafile/o1_mf_sysaux_0kpl4cif_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=861024971 file name=/u01/oracle/oradata/MES/datafile/o1_mf_undotbs1_0mpl4ckv_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=861024971 file name=/u01/oracle/oradata/MES/datafile/o1_mf_users_0npl4clf_.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=861024971 file name=/u01/oracle/oradata/MES/datafile/o1_mf_example_0lpl4cjs_.dbf
contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 2014-10-15 13:36:38

源库mount状态也可以进行复制:

[[email protected] admin]$ rman target / auxiliary sys/[email protected]/MECBS
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Oct 20 17:53:59 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: PHUB (DBID=507861806, not open)
connected to auxiliary database: MECBS (not mounted)

RMAN> duplicate target database to MECBS from active database nofilenamecheck;
Starting Duplicate Db at 20-OCT-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=63 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     626327552 bytes
Fixed Size                     2255832 bytes
Variable Size                440402984 bytes
Database Buffers             176160768 bytes
Redo Buffers                   7507968 bytes
contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ‘‘PHUB‘‘ comment=
 ‘‘Modified by RMAN duplicate‘‘ scope=spfile";
   sql clone "alter system set  db_unique_name = 
 ‘‘MECBS‘‘ comment=
 ‘‘Modified by RMAN duplicate‘‘ scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   backup as copy current controlfile auxiliary format  ‘/u03/app/oracle/oradata/MECBS/control01.ctl‘;
   restore clone controlfile to  ‘/u03/app/oracle/fast_recovery_area/MECBS/control02.ctl‘ from 
 ‘/u03/app/oracle/oradata/MECBS/control01.ctl‘;
   alter clone database mount;
}
executing Memory Script
sql statement: alter system set  db_name =  ‘‘PHUB‘‘ comment= ‘‘Modified by RMAN duplicate‘‘ scope=spfile
sql statement: alter system set  db_unique_name =  ‘‘MECBS‘‘ comment= ‘‘Modified by RMAN duplicate‘‘ scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area     626327552 bytes
Fixed Size                     2255832 bytes
Variable Size                440402984 bytes
Database Buffers             176160768 bytes
Redo Buffers                   7507968 bytes
Starting backup at 20-OCT-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=63 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_PHUB.f tag=TAG20141020T175725 RECID=4 STAMP=861472646
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 20-OCT-14
Starting restore at 20-OCT-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=63 device type=DISK
channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 20-OCT-14
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
   ;
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting backup at 20-OCT-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/PHUB/system01.dbf
output file name=/u03/app/oracle/oradata/MECBS/datafile/o1_mf_system_0epli1si_.dbf tag=TAG20141020T175738
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:16
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/PHUB/sysaux01.dbf
output file name=/u03/app/oracle/oradata/MECBS/datafile/o1_mf_sysaux_0fpli20q_.dbf tag=TAG20141020T175738
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/PHUB/undotbs01.dbf
output file name=/u03/app/oracle/oradata/MECBS/datafile/o1_mf_undotbs1_0gpli23q_.dbf tag=TAG20141020T175738
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/PHUB/users01.dbf
output file name=/u03/app/oracle/oradata/MECBS/datafile/o1_mf_users_0hpli249_.dbf tag=TAG20141020T175738
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 20-OCT-14
contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=4 STAMP=861472909 file name=/u03/app/oracle/oradata/MECBS/datafile/o1_mf_system_0epli1si_.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=5 STAMP=861472909 file name=/u03/app/oracle/oradata/MECBS/datafile/o1_mf_sysaux_0fpli20q_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=6 STAMP=861472909 file name=/u03/app/oracle/oradata/MECBS/datafile/o1_mf_undotbs1_0gpli23q_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=7 STAMP=861472909 file name=/u03/app/oracle/oradata/MECBS/datafile/o1_mf_users_0hpli249_.dbf
contents of Memory Script:
{
   set until scn  990325;
   recover
   clone database
   noredo
    delete archivelog
   ;
}
executing Memory Script
executing command: SET until clause
Starting recover at 20-OCT-14
using channel ORA_AUX_DISK_1
Finished recover at 20-OCT-14
Oracle instance started
Total System Global Area     626327552 bytes
Fixed Size                     2255832 bytes
Variable Size                440402984 bytes
Database Buffers             176160768 bytes
Redo Buffers                   7507968 bytes
contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ‘‘MECBS‘‘ 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 =  ‘‘MECBS‘‘ 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     626327552 bytes
Fixed Size                     2255832 bytes
Variable Size                440402984 bytes
Database Buffers             176160768 bytes
Redo Buffers                   7507968 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "MECBS" 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
  ‘/u03/app/oracle/oradata/MECBS/datafile/o1_mf_system_0epli1si_.dbf‘
 CHARACTER SET AL32UTF8

contents of Memory Script:
{
   set newname for clone tempfile  1 to new;
   switch clone tempfile all;
   catalog clone datafilecopy  "/u03/app/oracle/oradata/MECBS/datafile/o1_mf_sysaux_0fpli20q_.dbf", 
 "/u03/app/oracle/oradata/MECBS/datafile/o1_mf_undotbs1_0gpli23q_.dbf", 
 "/u03/app/oracle/oradata/MECBS/datafile/o1_mf_users_0hpli249_.dbf";
   switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u03/app/oracle/oradata/MECBS/datafile/o1_mf_temp_%u_.tmp in control file
cataloged datafile copy
datafile copy file name=/u03/app/oracle/oradata/MECBS/datafile/o1_mf_sysaux_0fpli20q_.dbf RECID=1 STAMP=861472928
cataloged datafile copy
datafile copy file name=/u03/app/oracle/oradata/MECBS/datafile/o1_mf_undotbs1_0gpli23q_.dbf RECID=2 STAMP=861472928
cataloged datafile copy
datafile copy file name=/u03/app/oracle/oradata/MECBS/datafile/o1_mf_users_0hpli249_.dbf RECID=3 STAMP=861472928
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=861472928 file name=/u03/app/oracle/oradata/MECBS/datafile/o1_mf_sysaux_0fpli20q_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=861472928 file name=/u03/app/oracle/oradata/MECBS/datafile/o1_mf_undotbs1_0gpli23q_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=861472928 file name=/u03/app/oracle/oradata/MECBS/datafile/o1_mf_users_0hpli249_.dbf
contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 20-OCT-14

时间: 2024-10-06 03:20:58

使用RMAN工具克隆生产数据库的相关文章

基于RMAN的异机数据库克隆(rman duplicate)

对于基于生产环境下的数据库的版本升级或者测试新的应用程序的性能及其影响,备份恢复等等,我们可以采取从生产环境以克隆的方式将其克隆到本地而不影响生产数据库的正常使用.实现这个功能我们可以借助rman duplicate方式以及其简单的方式来完成.duplicate方式不同于OS级别的备份,它会为辅助数据库(克隆出来的数据库)生成一个新的dbid,而能够同时将目标数据库(原数据库)与辅助数据库注册到同一个恢复目录.本文描述了使用rman duplicate实现异机数据库克隆. 1.RMAN支持的du

使用RMAN工具复制数据库

一.概述 复制数据库即使用RMAN工具的DUPLICATE命令从源数据库拷贝所有或者一部分的数据到目标数据库.复制数据库技术在多种场景都是特别有用的,如创建standby数据库,创建用于不同目的地测试环境,数据库迁移等. 使用DUPLICATE命令复制数据库能自动配置与源数据库不同的DBID,确保目标数据库和源数据库能一起存放在相同的恢复目录数据库中. RMAN支持两种复制类型:活动数据库复制和基本备份的复制.RMAN能在源数据库和恢复目录数据库存在或者不存在的情况下执行基于备份的复制. 活动数

oracle备份 使用RMAN 工具

在日常维护中 备份是我们运维最常做的工作,并且非常重要 . 那九妹带你 使用RMAN 工具备份Orcle 三.使用RMAN工具 RMAN(recovery  manager)是oracle的一个重要工具,用于备份和恢复数据库文件.归档日志和控制文件.也可以用来执行完全或不完全的数据库恢复.RMAN有3种不同的用户接口:命令行方式,GUI方式(集成在OEM中的备份管理器).api方式(用于集成到第三方的备份软件中).它具有如下优点: 1)支持在线热备份 2)支持多级增量备份 3)支持并行备份.恢复

Oracle备份与还原——rman工具

RMAN的恢复与备份RMAN提供了如下好处:RMAN可进行增量备份.备份的大小不取决于数据库大小,而是取决于数据库内的活动程度,增量备份会跳过未改动的块.可联机修补文件的部分讹误数据块,不需要从备份复原文件.这称为块介质恢复.指令简单,不需要复杂的脚本.RMAN允许在备份中跳过未使用过的数据块备份,从而节省时间和储存空间.第一步:创建恢复表空间 第二步:创建RMAN用户并且授权. 第三步:使用RMAN工具链接数据库 第四步:创建恢复目录 第五步:使用register命令注册数据库 前置工作完成后

[解决办法]windows的非administrator账户无法通过plsql工具登录oracle数据库

环境:windows2008服务器.使用的非administrator账户,而是新建了一个windows2008账户.安装好了plsql工具. 问题:使用administrator账户可以用plsql工具连接成功oracle数据库:但是使用非administrator账户用plsql工具连接oracle数据库失败,如下图: 原因:经过反复排查,是因为plsql工具没有获取系统的权限,而且加入了administrators组也是无效,主要原因是windows在vista系统之后新增了一个UAC(用

使用Phalcon开发工具碰到的数据库问题"Table 'XXX' doesn't exist in database when dumping meta-data for XXX"

使用Phalcon开发工具,通过命令行生成程序框架 设置好config.php,在对数据库进行读取.保存数据的时候出现了问题“Table 'XXX' doesn't exist in database when dumping meta-data for XXX” 注意到上方还有一条语句“Array to string conversion”,找到对应services.php处的代码 1 $di->set('db', function () use ($config) { 2 return ne

通过MyEclipse工具直接操作数据库,执行sql语句,方便快捷

原文:通过MyEclipse工具直接操作数据库,执行sql语句,方便快捷 通过MyEclipse操作数据库,执行sql语句使我们不用切换多个工具,直接工作,方便快捷.效果如下: 步骤1:通过MyEclipse中的window->show View->other 调出.DB浏览器. 步骤2: 步骤3:输入db,然后选择DB Brower. 步骤4:单击空白处右键. 步骤5:选择相应的数据库类型. 步骤6: Driver name :填上自己需要的名字 Connection name :jdbc:

使用rman异机复制数据库

源端数据库:192.168.1.210 sid:orcl hostname:Nagiostest ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/product/11.2 目标数据库:192.168.1.211 sid:orcl hostname:OEL6 ORACLE_BASE=/u01/app/oracle ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 这里是相同实例名的复制,如果实例

Navicat工具进行Oracle数据库复制 or 备份、还原功能(由评教需要所谈)

GXPT是一个分布式系统,此系统暂时包含权限系统.基础系统.评教系统.考试系统,各个系统建有自己的oracle数据库.我们小组负责的是评教系统,而评教系统的正常需要借助于权限系统和基础系统,具体的业务这里就不多解释了.近期要进行评教活动了,基础系统在往基础库中录入真实数据,而评教系统还想进行一下功能及压力测试,当然就不同直接操作基础真实数据库的数据了,于是我们准备了一台装有oracle的备用服务器,作为测试使用. Oracle数据库不能像SqlServer那样直接进行备份还原.我首先建好了基础系