ITPub博客

利用rman生成备用数据库操作文档

原创 Linux操作系统 作者:paulyibinyi 时间:2007-12-24 16:03:23 0 删除 编辑

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 sys/abcdefg@copy 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 sys/abcdefg@copy

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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
oracle 10g ocm oracle 10g/11g/12c ocp aix 6.1 administrator,ogg expert,ITSS 技术交流群 201703254 微信公众号 paulyibin 探讨技术,开心工作 电话 13719354869 ,深入研究数据库和开始研究big data

注册时间:2007-12-11

  • 博文量
    905
  • 访问量
    6484202