Clone An Instance

概要

操作系统感染病毒导致瘫痪,不得已重新安装了WindowsXP。原有系统中安装有Oracle10g,为了
恢复原有的数据库,在新的操作系统中进行了如下的操作。

Step 1:安装Oracle10g软件

备考: 安装路径中包含原来Oracle10g的安装文件,所以Oracle10g的重新安装在1分钟之内就结束了。

Step 2: 建立一个ORACLE_SID是ZQ03的空闲例程

    oradim -new -sid ZQ03 -pfile F:\oracle\product\10.2.0\db_1\database\initZQ03.ora

备考: 利用了原有的initZQ03.ora作为pfile参数文件。
空闲例程建立后,在管理工具的服务中确认空闲例程已经启动。

Step 3:建立数据库密码文件

    orapwd file=F:\oracle\product\10.2.0\db_1\database\PWDZQ03.ora password=oracle 
entries=5

备考: 原有的PWDZQ03.ora文件已经存在,因此省略了这步操作。

Step 4:启动Oracle监听服务

    lsnrctl start

备考: 在管理工具的服务中确认监听服务已经启动。
source

Step 5:设置ORACLE_SID环境变量

    set ORACLE_SID=ZQ03

Step 6:启动ZQ03instance

    sqlplus "/ as sysdba"
    startup pfile=F:\oracle\product\10.2.0\db_1\database\initZQ03.ora nomount
    alter database mount;
    alter database open;

至此,原有的ZQ03例程重新启动成功,接下来利用ZQ03克隆一个SID为ZQ04的新历程。
利用rman克隆数据库之前,先取得一份ZQ03的全备份

    rman target system/manager@ZQ03 nocatalog
    backup full database;
    sql 'alter system archive log current';
    backup archivelog all delete input;
    backup current controlfile;
    exit;

Step 1: 建立一个ORACLE_SID是ZQ04的空闲例程

    oradim -new -sid ZQ04

Step 2:建立数据库密码文件

    orapwd file=F:\oracle\product\10.2.0\db_1\database\PWDZQ04.ora password=oracle entries=5

Step 3:设置ORACLE_SID环境变量

    set ORACLE_SID=ZQ04

Step 4:装载ZQ04空闲例程

    sqlplus "/ as sysdba"
    startup pfile=F:\oracle\product\10.2.0\db_1\database\initZQ04.ora nomount

++Step 5:克隆ZQ03到ZQ04
    rman target system/manager@zq03 auxiliary system/manager@zq04 nocatalog
RUN
{
set newname for datafile 3 to 'F:\oracle\product\10.2.0\oradata\ZQ04\SYSAUX01.DBF';
set newname for datafile 1 to 'F:\oracle\product\10.2.0\oradata\ZQ04\SYSTEM01.DBF';
set newname for datafile 2 to 'F:\oracle\product\10.2.0\oradata\ZQ04\UNDOTBS01.DBF';
set newname for datafile 4 to 'F:\oracle\product\10.2.0\oradata\ZQ04\USERS01.DBF';
set newname for tempfile 1 to 'F:\oracle\product\10.2.0\oradata\ZQ04\TEMP01.DBF';
DUPLICATE TARGET DATABASE TO ZQ04
LOGFILE
GROUP 1
(
'F:\oracle\product\10.2.0\oradata\ZQ04\REDO01_A.LOG',
'F:\oracle\product\10.2.0\oradata\ZQ04\REDO01_B.LOG'
) SIZE 50M,
GROUP 2
(
'F:\oracle\product\10.2.0\oradata\ZQ04\REDO02_A.LOG',
'F:\oracle\product\10.2.0\oradata\ZQ04\REDO02_B.LOG'
) SIZE 50M,
GROUP 3
(
'F:\oracle\product\10.2.0\oradata\ZQ04\REDO03_A.LOG',
'F:\oracle\product\10.2.0\oradata\ZQ04\REDO03_B.LOG'
) SIZE 50M;
}

备考: 上面的脚本中需要通过set newname命令修改数据文件的路径,对应文件名称不要出错。
用set newname for tempfile命令修改临时表领域文件的路径。
克隆数据库时候通过LOGFILE字句重建ZQ04的在线REDO日志文件
下面是rman脚本执行后的输出结果
RMAN> RUN
2> {
3> set newname for datafile 3 to 'F:\oracle\product\10.2.0\oradata\ZQ04\SYSAUX01
.DBF';
4> set newname for datafile 1 to 'F:\oracle\product\10.2.0\oradata\ZQ04\SYSTEM01
.DBF';
5> set newname for datafile 2 to 'F:\oracle\product\10.2.0\oradata\ZQ04\UNDOTBS0
1.DBF';
6> set newname for datafile 4 to 'F:\oracle\product\10.2.0\oradata\ZQ04\USERS01.
DBF';
7> set newname for tempfile 1 to 'F:\oracle\product\10.2.0\oradata\ZQ04\TEMP01.D
BF';
8> DUPLICATE TARGET DATABASE TO ZQ04
9> LOGFILE
10> GROUP 1
11> (
12> 'F:\oracle\product\10.2.0\oradata\ZQ04\REDO01_A.LOG',
13> 'F:\oracle\product\10.2.0\oradata\ZQ04\REDO01_B.LOG'
14> ) SIZE 50M,
15> GROUP 2
16> (
17> 'F:\oracle\product\10.2.0\oradata\ZQ04\REDO02_A.LOG',
18> 'F:\oracle\product\10.2.0\oradata\ZQ04\REDO02_B.LOG'
19> ) SIZE 50M,
20> GROUP 3
21> (
22> 'F:\oracle\product\10.2.0\oradata\ZQ04\REDO03_A.LOG',
23> 'F:\oracle\product\10.2.0\oradata\ZQ04\REDO03_B.LOG'
24> ) SIZE 50M;
25> }
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
Starting Duplicate Db at 20-MAR-07
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=157 devtype=DISK
 
contents of Memory Script:
{
   set until scn  3266629;
   set newname for datafile  1 to
 "F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\SYSTEM01.DBF";
   set newname for datafile  2 to
 "F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\UNDOTBS01.DBF";
   set newname for datafile  3 to
 "F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\SYSAUX01.DBF";
   set newname for datafile  4 to
 "F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\USERS01.DBF";
   restore
   check readonly
   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-07
using channel ORA_AUX_DISK_1
 
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\SYSTEM01.DBF
restoring datafile 00002 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\UNDOTBS01.DBF
restoring datafile 00003 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\SYSAUX01.DBF
restoring datafile 00004 to F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\USERS01.DBF
channel ORA_AUX_DISK_1: reading from backup piece F:\RMAN\ZQ03\BK_S93_P1_T645062
409
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=F:\RMAN\ZQ03\BK_S93_P1_T645062409 tag=FULL_DB_LEVEL_0
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:06
Finished restore at 20-MAR-07
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ZQ04" RESETLOGS ARCHIVELOG
 
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( 'F:\oracle\product\10.2.0\oradata\ZQ04\REDO01_A.LOG', 'F:\oracle\pr
oduct\10.2.0\oradata\ZQ04\REDO01_B.LOG' ) SIZE 50 M ,
  GROUP  2 ( 'F:\oracle\product\10.2.0\oradata\ZQ04\REDO02_A.LOG', 'F:\oracle\pr
oduct\10.2.0\oradata\ZQ04\REDO02_B.LOG' ) SIZE 50 M ,
  GROUP  3 ( 'F:\oracle\product\10.2.0\oradata\ZQ04\REDO03_A.LOG', 'F:\oracle\pr
oduct\10.2.0\oradata\ZQ04\REDO03_B.LOG' ) SIZE 50 M
 DATAFILE
  'F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\SYSTEM01.DBF'
 CHARACTER SET ZHS16GBK
 
contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script
 
released channel: ORA_AUX_DISK_1
datafile 3 switched to datafile copy
input datafile copy recid=1 stamp=617740565 filename=F:\ORACLE\PRODUCT\10.2.0\OR
ADATA\ZQ04\SYSAUX01.DBF
datafile 2 switched to datafile copy
input datafile copy recid=2 stamp=617740565 filename=F:\ORACLE\PRODUCT\10.2.0\OR
ADATA\ZQ04\UNDOTBS01.DBF
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=617740565 filename=F:\ORACLE\PRODUCT\10.2.0\OR
ADATA\ZQ04\USERS01.DBF
 
contents of Memory Script:
{
   set until scn  3266629;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script
 
executing command: SET until clause
 
Starting recover at 20-MAR-07
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=159 devtype=DISK
channel ORA_AUX_DISK_1: starting incremental datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04
\SYSTEM01.DBF
destination for restore of datafile 00002: F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04
\UNDOTBS01.DBF
destination for restore of datafile 00003: F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04
\SYSAUX01.DBF
destination for restore of datafile 00004: F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04
\USERS01.DBF
channel ORA_AUX_DISK_1: reading from backup piece F:\RMAN\ZQ03\BK_S97_P1_T645148
804
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=F:\RMAN\ZQ03\BK_S97_P1_T645148804 tag=DB_LEVEL_1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:08
channel ORA_AUX_DISK_1: starting incremental datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04
\SYSTEM01.DBF
destination for restore of datafile 00002: F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04
\UNDOTBS01.DBF
destination for restore of datafile 00003: F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04
\SYSAUX01.DBF
destination for restore of datafile 00004: F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04
\USERS01.DBF
channel ORA_AUX_DISK_1: reading from backup piece F:\RMAN\ZQ03\BK_S101_P1_T64558
0803
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=F:\RMAN\ZQ03\BK_S101_P1_T645580803 tag=DB_LEVEL_1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:16
 
starting media recovery
 
archive log thread 1 sequence 94 is already on disk as file F:\ARCHIVELOG\ZQ03\A
RC00094_0641557115.001
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=93
channel ORA_AUX_DISK_1: reading from backup piece F:\RMAN\ZQ03\BK_S102_P1_T64558
0844
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=F:\RMAN\ZQ03\BK_S102_P1_T645580844 tag=AL_LEVEL_1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:16
archive log filename=F:\ARCHIVELOG\ZQ04ARC00093_0641557115.001 thread=1 sequence
=93
channel clone_default: deleting archive log(s)
archive log filename=F:\ARCHIVELOG\ZQ04ARC00093_0641557115.001 recid=1 stamp=617
740606
archive log filename=F:\ARCHIVELOG\ZQ03\ARC00094_0641557115.001 thread=1 sequenc
e=94
media recovery complete, elapsed time: 00:00:07
Finished recover at 20-MAR-07
 
contents of Memory Script:
{
   shutdown clone;
   startup clone nomount ;
}
executing Memory Script
 
database dismounted
Oracle instance shut down
 
connected to auxiliary database (not started)
Oracle instance started
 
Total System Global Area     209715200 bytes
 
Fixed Size                     1248116 bytes
Variable Size                 79692940 bytes
Database Buffers             121634816 bytes
Redo Buffers                   7139328 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ZQ04" RESETLOGS ARCHIVELOG
 
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( 'F:\oracle\product\10.2.0\oradata\ZQ04\REDO01_A.LOG', 'F:\oracle\pr
oduct\10.2.0\oradata\ZQ04\REDO01_B.LOG' ) SIZE 50 M ,
  GROUP  2 ( 'F:\oracle\product\10.2.0\oradata\ZQ04\REDO02_A.LOG', 'F:\oracle\pr
oduct\10.2.0\oradata\ZQ04\REDO02_B.LOG' ) SIZE 50 M ,
  GROUP  3 ( 'F:\oracle\product\10.2.0\oradata\ZQ04\REDO03_A.LOG', 'F:\oracle\pr
oduct\10.2.0\oradata\ZQ04\REDO03_B.LOG' ) SIZE 50 M
 DATAFILE
  'F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\SYSTEM01.DBF'
 CHARACTER SET ZHS16GBK
 
contents of Memory Script:
{
   set newname for tempfile  1 to
 "F:\oracle\product\10.2.0\oradata\ZQ04\TEMP01.DBF";
   switch clone tempfile all;
   catalog clone datafilecopy  "F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\UNDOTBS01.
DBF";
   catalog clone datafilecopy  "F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\SYSAUX01.D
BF";
   catalog clone datafilecopy  "F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\USERS01.DB
F";
   switch clone datafile all;
}
executing Memory Script
 
executing command: SET NEWNAME
 
renamed temporary file 1 to F:\oracle\product\10.2.0\oradata\ZQ04\TEMP01.DBF in
control file
 
cataloged datafile copy
datafile copy filename=F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\UNDOTBS01.DBF recid
=1 stamp=617740624
 
cataloged datafile copy
datafile copy filename=F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\SYSAUX01.DBF recid=
2 stamp=617740625
 
cataloged datafile copy
datafile copy filename=F:\ORACLE\PRODUCT\10.2.0\ORADATA\ZQ04\USERS01.DBF recid=3
 stamp=617740625
 
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=617740625 filename=F:\ORACLE\PRODUCT\10.2.0\OR
ADATA\ZQ04\SYSAUX01.DBF
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=617740624 filename=F:\ORACLE\PRODUCT\10.2.0\OR
ADATA\ZQ04\UNDOTBS01.DBF
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=617740625 filename=F:\ORACLE\PRODUCT\10.2.0\OR
ADATA\ZQ04\USERS01.DBF
 
contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script
 
database opened
Finished Duplicate Db at 20-MAR-07
 
RMAN>exit

到此数据库的恢复和克隆操作成功完成。