ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 使用RMAN备份集复制数据库到本机(使用了db_unique_name 不然两个DB_name一样)

使用RMAN备份集复制数据库到本机(使用了db_unique_name 不然两个DB_name一样)

原创 Linux操作系统 作者:xpj0515 时间:2011-04-08 20:44:03 0 删除 编辑

注意点,
1.DB_NAME相同,本机创建可以使用DB_UNIQUE_NAME代替
2,恢复控制文件时需要指定DBID,这样可以标识数据文件的吧
3,恢复备份控制后需要重新指定数据文件和联机日志路径
4,数据文件使用SET   NEWNAME  RESTORE   SWITCH  不然的话会导致不同数据库对应同一数据文件 异机的话完全不会存在这样的问题  那就注意文件路径和备份集能读取就好
 5,联机日志重定向可以创建新日志组  切换  复制暂时保存后删除  再重建即可  这个地方有点乱以后解释并测试
 6,需求总结  本机复制数据库  文件采用OMF管理  不采用Duplicate的辅佐实例  采用备份集降低主库负载  不重建手工控制文 件
 7,不得不说需求的确有些变态  纯粹当作测试训练吧   
 8,千万不要忘记指定ORACLE_SID变量  ALTER DATABASE CREATE STANDBY CONTROLFILE AS创建的控制文件到底有何特点  与恢复的备份控制文件区别
 9 测试备用数据库  创建复制  参数修改自动应用  角色转换角色切换需要配置主库的 standby 日志
 备库的联机日志  FAL CONVERT参数 文件自动管理  主要过程可以理解如下今天终于配置好物理备用数据库
 主要问题出在网络服务名和监听器的设置上,没有理解listener.ora tnsnames.ora两个文件各个字段的含义,
以前配置好完全是意外成功,这个问题是非常尴尬的,还有就是配置的高级特性,逻辑备用数据库,
不光应用 主库修改,本身也可以修改,这个可以理解为一个可以保持同步又能自身发展的系统,物理自身也可以修改,
不过需要配置闪回后恢复,使用OMF管理数据库配合 使用DATA GUARD ASM RAC效果还是相当不错的


SYS@orcl/2011-04-05 17:30:51>create pfile='$ORACLE_BASE/pfile/orcl_2.ora' from spfile;

File created.

Elapsed: 00:00:00.05



*.audit_file_dest='/boot/u01/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.db_block_size=8192
*.db_create_file_dest='/boot/u02/oradata'
*.db_create_online_log_dest_1='/boot/u02/oradata'
*.db_create_online_log_dest_2='/boot/u03/oradata'
*.db_create_online_log_dest_3='/boot/u04/oradata'
*.db_create_online_log_dest_4='/boot/u05/oradata'

*.db_domain=''
*.db_name='orcl'
*.db_unique_name='orcl_1'
*.db_recovery_file_dest='/boot/u03/recovery_area'
*.db_recovery_file_dest_size=8589934592
*.diagnostic_dest='/boot/u01/app/oracle'
*.log_archive_dest_1='LOCATION=/boot/u02/oradata'
*.log_archive_dest_2='LOCATION=/boot/u03/oradata'
*.log_archive_dest_3='LOCATION=/boot/u04/oradata'
*.log_archive_dest_4='LOCATION=/boot/u05/oradata'

*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=377487360
*.nls_language='SIMPLIFIED CHINESE'
*.nls_territory='CHINA'
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'


SYS@orcl_1/05-APR-11>create spfile from pfile='$ORACLE_BASE/pfile/orcl_2.ora';

File created.


RMAN> backup current controlfile;

Starting backup at 05-APR-11
using channel ORA_DISK_1
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 05-APR-11
channel ORA_DISK_1: finished piece 1 at 05-APR-11
piece handle=/boot/u03/recovery_area/ORCL/backupset/2011_04_05/o1_mf_ncnnf_TAG20110405T173501_6sorl75x_.bkp tag=TAG20110405T173501 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 05-APR-11

[oracle@localhost ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Apr 5 18:06:59 2011

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

connected to target database: ORCL (not mounted)

RMAN>  set dbid=1275488545

executing command: SET DBID

RMAN> restore controlfile from '/boot/u03/recovery_area/ORCL/backupset/2011_04_05/o1_mf_ncnnf_TAG20110405T173501_6sorl75x_.bkp';

Starting restore at 05-APR-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/boot/u02/oradata/ORCL_1/controlfile/o1_mf_6sot5rdl_.ctl
output file name=/boot/u03/oradata/ORCL_1/controlfile/o1_mf_6sot5rlk_.ctl
output file name=/boot/u04/oradata/ORCL_1/controlfile/o1_mf_6sot5rrh_.ctl
output file name=/boot/u05/oradata/ORCL_1/controlfile/o1_mf_6sot5s15_.ctl

Finished restore at 05-APR-11

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1



run{set newname for datafile 1 to '/boot/u02/oradata/ORCL_1/datafile/system01.dbf';
set newname for datafile 2 to '/boot/u02/oradata/ORCL_1/datafile/sysaux01.dbf';
set newname for datafile 3 to '/boot/u02/oradata/ORCL_1/datafile/undotbs01.dbf';
set newname for datafile 4 to '/boot/u02/oradata/ORCL_1/datafile/users01.dbf';
restore database;
switch datafile 1;
switch datafile 2;
switch datafile 3;
switch datafile 4;
10> }


executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 05-APR-11
using channel ORA_DISK_1

channel ORA_DISK_1: restoring datafile 00001
input datafile copy RECID=1 STAMP=747684514 file name=/boot/u02/oradata/ORCL/datafile/o1_mf_system_6spk9dtz_.dbf
destination for restore of datafile 00001: /boot/u02/oradata/ORCL_1/datafile/system01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00001
output file name=/boot/u02/oradata/ORCL_1/datafile/system01.dbf RECID=5 STAMP=747684733
channel ORA_DISK_1: restoring datafile 00002
input datafile copy RECID=2 STAMP=747684514 file name=/boot/u02/oradata/ORCL/datafile/o1_mf_sysaux_6spk9z3m_.dbf
destination for restore of datafile 00002: /boot/u02/oradata/ORCL_1/datafile/sysaux01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00002
output file name=/boot/u02/oradata/ORCL_1/datafile/sysaux01.dbf RECID=6 STAMP=747684771
channel ORA_DISK_1: restoring datafile 00003
input datafile copy RECID=3 STAMP=747684514 file name=/boot/u02/oradata/ORCL/datafile/o1_mf_undotbs1_6spkbgrp_.dbf
destination for restore of datafile 00003: /boot/u02/oradata/ORCL_1/datafile/undotbs01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00003
output file name=/boot/u02/oradata/ORCL_1/datafile/undotbs01.dbf RECID=7 STAMP=747684793
channel ORA_DISK_1: restoring datafile 00004
input datafile copy RECID=4 STAMP=747684514 file name=/boot/u02/oradata/ORCL/datafile/o1_mf_users_6spkc74b_.dbf
destination for restore of datafile 00004: /boot/u02/oradata/ORCL_1/datafile/users01.dbf
channel ORA_DISK_1: copied datafile copy of datafile 00004
output file name=/boot/u02/oradata/ORCL_1/datafile/users01.dbf RECID=8 STAMP=747684801
Finished restore at 05-APR-11

datafile 1 switched to datafile copy
input datafile copy RECID=9 STAMP=747684804 file name=/boot/u02/oradata/ORCL_1/datafile/system01.dbf

datafile 2 switched to datafile copy
input datafile copy RECID=10 STAMP=747684805 file name=/boot/u02/oradata/ORCL_1/datafile/sysaux01.dbf

datafile 3 switched to datafile copy
input datafile copy RECID=11 STAMP=747684806 file name=/boot/u02/oradata/ORCL_1/datafile/undotbs01.dbf

datafile 4 switched to datafile copy
input datafile copy RECID=12 STAMP=747684806 file name=/boot/u02/oradata/ORCL_1/datafile/users01.dbf

RMAN> recover database;

Starting recover at 05-APR-11
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 32 is already on disk as file /boot/u02/oradata/ORCL/onlinelog/o1_mf_2_6spk957d_.log
archived log file name=/boot/u02/oradata/ORCL/onlinelog/o1_mf_2_6spk957d_.log thread=1 sequence=32
media recovery complete, elapsed time: 00:00:01
Finished recover at 05-APR-11

RMAN> alter database open resetlogs;

database opened

RMAN>

这样两个数据库会对应相同的联机日志  可以采用先移动到别处,然后复制库删除日志组 再重建日志组 在将日志组移回原处  则主库就可以再正常使用联机日志了(貌似需求有点变态)主要还是OMF参数的原因  还有就是没有重建数据库  手工重建控制文件其实更简单  不用考虑那么多问题

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24890594/viewspace-691982/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-11-08

  • 博文量
    32
  • 访问量
    52384