利用rman生成備用資料庫操作文件

paulyibinyi發表於2007-12-24

1.準備好相應的目錄結構
D:\oracle\admin\copy\bdump
D:\oracle\admin\copy\udump
D:\oracle\admin\copy\cdump

D:\oracle\oradata\copy

2.建立好引數檔案  initcopy.ora 檔案,參照主庫檔案進行修改.新增和修改以下引數檔案
db_name=copy
instance_name=copy
background_dump_dest=d:\oracle\admin\copy\bdump
core_dump_dest=d:\oracle\admin\copy\cdump
user_dump_dest=d:\oracle\admin\copy\udump
control_files='D:\oracle\oradata\copy\control01.ctl','d:\oracle\oradata\copy\control02.ctl','d:\oracle\oradata\copy\control03.ctl'
DB_FILE_NAME_CONVERT=('d:\oracle\oradata\paul','E:\oracle\oradata\copy')
LOG_FILE_NAME_CONVERT=('d:\oracle\oradata\paul','E:\oracle\oradata\copy')

3.
使用oradim建立新的instance
c:\>oradim -new -sid copy
例程已建立。

4.使用orapwd建立password檔案

C:\Documents and Settings\Paul Yi>orapwd file=d:\oracle\ora92\database\pwdcopy.o
ra password=abcdefg entries=10

5.配置好監聽和tnsnames,然後使用sqlplus測試連線
listener.ora檔案中
增加以下內容
 (SID_DESC =
      (GLOBAL_DBNAME = copy)
      (ORACLE_HOME = D:\oracle\ora92)
      (SID_NAME = copy)
   )
tnsnames.ora檔案中增加
copy =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.163)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = copy)
    )
  )

6.重新停止監聽並且重啟
Service "test" has 1 instance(s).
  Instance "test", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

7.使用rman備份原庫
C:\Documents and Settings\Paul Yi>rman target / catalog paultest/paultest@dev89.
avocado.local

Recovery Manager: Release 9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: PAUL (DBID=1605165889)
connected to recovery catalog database

RMAN> backup full database tag 'fullbk';

Starting backup at 24-DEC-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=13 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=D:\ORACLE\ORADATA\PAUL\SYSTEM01.DBF
input datafile fno=00002 name=D:\ORACLE\ORADATA\PAUL\UNDOTBS01.DBF
input datafile fno=00003 name=D:\ORACLE\ORADATA\PAUL\INDX01.DBF
input datafile fno=00005 name=D:\ORACLE\ORADATA\PAUL\USERS01.DBF
input datafile fno=00004 name=D:\ORACLE\ORADATA\PAUL\TOOLS01.DBF
channel ORA_DISK_1: starting piece 1 at 24-DEC-07
channel ORA_DISK_1: finished piece 1 at 24-DEC-07
piece handle=D:\BACKUP\3TJ4DISC_1_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 24-DEC-07

Starting Control File and SPFILE Autobackup at 24-DEC-07
piece handle=D:\BACKUP\C-1605165889-20071224-00 comment=NONE
Finished Control File and SPFILE Autobackup at 24-DEC-07

8.啟動備用資料庫到nomount狀態
C:\Documents and Settings\Paul Yi>sqlplus /nolog

SQL*Plus: Release 9.2.0.4.0 - Production on Mon Dec 24 13:42:40 2007

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

SQL> conn as sysdba
Connected to an idle instance.
SQL>startup pfile='D:\oracle\ora92\database\initcopy.ora';

File created.

SQL> startup nomount;


9.使用rman複製資料庫
C:\Documents and Settings\Paul Yi>rman target / auxiliary

Recovery Manager: Release 9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: PAUL (DBID=1605165889)
connected to auxiliary database: copy (not mounted)

RMAN> duplicate target database to 'copy';

Starting Duplicate Db at 24-DEC-07
using target database controlfile instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=3 devtype=DISK

printing stored script. Memory Script
{
   set until scn  979183;
   set newname for datafile  1 to
 "D:\ORACLE\ORADATA\COPY\SYSTEM01.DBF";
   set newname for datafile  2 to
 "D:\ORACLE\ORADATA\COPY\UNDOTBS01.DBF";
   set newname for datafile  3 to
 "D:\ORACLE\ORADATA\COPY\INDX01.DBF";
   set newname for datafile  4 to
 "D:\ORACLE\ORADATA\COPY\TOOLS01.DBF";
   set newname for datafile  5 to
 "D:\ORACLE\ORADATA\COPY\USERS01.DBF";
   restore
   check readonly
   clone database
   ;
}
executing script. Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 24-DEC-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 D:\ORACLE\ORADATA\COPY\SYSTEM01.DBF
restoring datafile 00002 to D:\ORACLE\ORADATA\COPY\UNDOTBS01.DBF
restoring datafile 00003 to D:\ORACLE\ORADATA\COPY\INDX01.DBF
restoring datafile 00004 to D:\ORACLE\ORADATA\COPY\TOOLS01.DBF
restoring datafile 00005 to D:\ORACLE\ORADATA\COPY\USERS01.DBF
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=D:\BACKUP\3MJ454NL_1_1 tag=TAG20071221T084645 params=NULL
channel ORA_AUX_DISK_1: restore complete
Finished restore at 24-DEC-07
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "copy" RESETLOGS ARCHIVELOG

  MAXLOGFILES      5
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     1
  MAXLOGHISTORY      226
 LOGFILE
  GROUP  1 ( 'D:\ORACLE\ORADATA\COPY\REDO01.LOG' ) SIZE  104857600  REUSE,
  GROUP  2 ( 'D:\ORACLE\ORADATA\COPY\REDO02.LOG' ) SIZE  104857600  REUSE,
  GROUP  3 ( 'D:\ORACLE\ORADATA\COPY\REDO03.LOG' ) SIZE  104857600  REUSE
 DATAFILE
  'D:\ORACLE\ORADATA\COPY\SYSTEM01.DBF'
 CHARACTER SET ZHS16GBK


printing stored script. Memory Script
{
   switch clone datafile all;
}
executing script. Memory Script

datafile 2 switched to datafile copy
input datafilecopy recid=1 stamp=642179779 filename=D:\ORACLE\ORADATA\COPY\UNDOT
BS01.DBF
datafile 3 switched to datafile copy
input datafilecopy recid=2 stamp=642179779 filename=D:\ORACLE\ORADATA\COPY\INDX0
1.DBF
datafile 4 switched to datafile copy
input datafilecopy recid=3 stamp=642179779 filename=D:\ORACLE\ORADATA\COPY\TOOLS
01.DBF
datafile 5 switched to datafile copy
input datafilecopy recid=4 stamp=642179779 filename=D:\ORACLE\ORADATA\COPY\USERS
01.DBF

printing stored script. Memory Script
{
   set until scn  979183;
   recover
   clone database
    delete archivelog
   ;
}
executing script. Memory Script

executing command: SET until clause

Starting recover at 24-DEC-07
using channel ORA_AUX_DISK_1

starting media recovery

archive log thread 1 sequence 182 is already on disk as file D:\BACKUP\1_182.DBF

archive log thread 1 sequence 183 is already on disk as file D:\ARCHPAUL\1_183.D
BF
archive log thread 1 sequence 184 is already on disk as file D:\ARCHPAUL\1_184.D
BF
archive log thread 1 sequence 185 is already on disk as file D:\ARCHPAUL\1_185.D
BF
archive log thread 1 sequence 186 is already on disk as file D:\ARCHPAUL\1_186.D
BF
archive log filename=D:\BACKUP\1_182.DBF thread=1 sequence=182
archive log filename=D:\ARCHPAUL\1_183.DBF thread=1 sequence=183
archive log filename=D:\ARCHPAUL\1_184.DBF thread=1 sequence=184
archive log filename=D:\ARCHPAUL\1_185.DBF thread=1 sequence=185
archive log filename=D:\ARCHPAUL\1_186.DBF thread=1 sequence=186
media recovery complete
Finished recover at 24-DEC-07

printing stored script. Memory Script
{
   shutdown clone;
   startup clone nomount ;
}
executing script. Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     101785252 bytes

Fixed Size                      454308 bytes
Variable Size                 75497472 bytes
Database Buffers              25165824 bytes
Redo Buffers                    667648 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "copy" RESETLOGS ARCHIVELOG

  MAXLOGFILES      5
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     1
  MAXLOGHISTORY      226
 LOGFILE
  GROUP  1 ( 'D:\ORACLE\ORADATA\COPY\REDO01.LOG' ) SIZE  104857600  REUSE,
  GROUP  2 ( 'D:\ORACLE\ORADATA\COPY\REDO02.LOG' ) SIZE  104857600  REUSE,
  GROUP  3 ( 'D:\ORACLE\ORADATA\COPY\REDO03.LOG' ) SIZE  104857600  REUSE
 DATAFILE
  'D:\ORACLE\ORADATA\COPY\SYSTEM01.DBF'
 CHARACTER SET ZHS16GBK


printing stored script. Memory Script
{
   catalog clone datafilecopy  "D:\ORACLE\ORADATA\COPY\UNDOTBS01.DBF";
   catalog clone datafilecopy  "D:\ORACLE\ORADATA\COPY\INDX01.DBF";
   catalog clone datafilecopy  "D:\ORACLE\ORADATA\COPY\TOOLS01.DBF";
   catalog clone datafilecopy  "D:\ORACLE\ORADATA\COPY\USERS01.DBF";
   switch clone datafile all;
}
executing script. Memory Script

cataloged datafile copy
datafile copy filename=D:\ORACLE\ORADATA\COPY\UNDOTBS01.DBF recid=1 stamp=642180
927

cataloged datafile copy
datafile copy filename=D:\ORACLE\ORADATA\COPY\INDX01.DBF recid=2 stamp=642180927


cataloged datafile copy
datafile copy filename=D:\ORACLE\ORADATA\COPY\TOOLS01.DBF recid=3 stamp=64218092
7

cataloged datafile copy
datafile copy filename=D:\ORACLE\ORADATA\COPY\USERS01.DBF recid=4 stamp=64218092
8

datafile 2 switched to datafile copy
input datafilecopy recid=1 stamp=642180927 filename=D:\ORACLE\ORADATA\COPY\UNDOT
BS01.DBF
datafile 3 switched to datafile copy
input datafilecopy recid=2 stamp=642180927 filename=D:\ORACLE\ORADATA\COPY\INDX0
1.DBF
datafile 4 switched to datafile copy
input datafilecopy recid=3 stamp=642180927 filename=D:\ORACLE\ORADATA\COPY\TOOLS
01.DBF
datafile 5 switched to datafile copy
input datafilecopy recid=4 stamp=642180928 filename=D:\ORACLE\ORADATA\COPY\USERS
01.DBF

printing stored script. Memory Script
{
   Alter clone database open resetlogs;
}
executing script. Memory Script

database opened
Finished Duplicate Db at 24-DEC-07

RMAN>

10.檢查複製庫的狀態
SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------------------
copy             OPEN

11.然後去掉initcopy.ora的DB_FILE_NAME_CONVERT和LOG_FILE_NAME_CONVERT引數,再使用該檔案生成spfile

SQL> create spfile from pfile='D:\oracle\ora92\database\initcopy.ora';

檔案已建立。
sql>startup
over

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7199859/viewspace-1261/,如需轉載,請註明出處,否則將追究法律責任。

相關文章