[FAQ]-使用rman备份做同机克隆和异机恢复

联系:QQ(5163721)

标题:[FAQ]-使用rman备份做同机克隆和异机恢复

作者:Lunar©版权所有[文章允许转载,但必须以链接方式注明源地址,否则追究法律责任.]

帮一个朋友整理的,顺便发到blog。
.
数据库克隆操作文档
一.前提说明:
1. 本测试是在同一台机器上完成,而在同一台机器中ORACLE_SID不可相同,所以涉及到克隆库修改ORACLE_SID问题
2. 为了使得本次操作能够更好的让客户了解其过程,使用了传统的rman备份来实现,而没有使用duplicate相关命令实现
3. 如果在不同机器上使用rman备份做异机恢复,就不用修改SID,保持跟以前一样就可以(步骤差不多,比同机克隆更简单)
.
二.整体思路:
1. 关闭lunar
2,使用pfile.lunar.bak(DB_NAME=lunar)nomount database
3,恢复控制文件
4,恢复数据文件(SET NEWNAME)
5,shutdown abort(lunar)
6,export ORACLE_SID=lunar
7,使用pfile.lunar.bak(DB_NAME=lunar)nomount database
8,重建控制文件(SET DATABASE “lunar”)
9,catalog start with
10,recover database
11,alter database open resetlogs
.
三.详细步骤
1,备份数据库lunar

rman target /
sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
run{
CONFIGURE DEVICE TYPE DISK PARALLELISM 12 BACKUP TYPE TO BACKUPSET;
BACKUP AS COMPRESSED BACKUPSET DATABASE FORMAT '/lunartest/databasefiles_%d_%U_%s' 
plus archivelog FORMAT '/lunartest/archivelogs_%d_%U_%s_%T' delete input;
BACKUP AS COMPRESSED BACKUPSET CURRENT CONTROLFILE FORMAT '/lunartest/controlfile_%d_%U_%s';
}

2,创建lunar的spfile

[oracle@gg lunartest]$ cat pfile.lunar.bak
*.aq_tm_processes=0
*.audit_file_dest='/home/oracle/product/admin/lunar/adump'
*.background_dump_dest='/home/oracle/product/admin/lunar/bdump'
*.compatible='11.2.0.2.0'
*.control_files='/home/oracle/product/oradata/lunar/controlfile/o1_mf_3sfb1t6n_.ctl'
*.core_dump_dest='/home/oracle/product/admin/lunar/cdump'
*.db_block_size=8192
*.db_create_file_dest='/home/oracle/product/oradata'
*.db_domain='oracle.com'
*.db_file_multiblock_read_count=8
*.db_name='lunar'
*.db_recovery_file_dest='/home/oracle/product/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.job_queue_processes=0
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=150
*.recyclebin='OFF'
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=167772160
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/home/oracle/product/admin/lunar/udump'
#db_name = "lunar"
#instance_name = lunar
#service_names = lunar

3,关闭lunar实例

[oracle@com lunartest]$ ps -ef|grep pmon
oracle    5070     1  0 13:14 ?        00:00:03 ora_pmon_lunar
oracle    5706  5656  0 22:18 pts/2    00:00:00 grep pmon
[oracle@com lunartest]$ export ORACLE_SID=lunar
[oracle@com lunartest]$
[oracle@com lunartest]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.2.0 - Production on Sun Sep 23 22:19:24 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options

4,使用pfiel.lunar.ora把lunar实例nomount

mkdir -p /home/oracle/oracle/product/admin/lunar/adump
mkdir -p /home/oracle/oracle/product/admin/lunar/bdump
mkdir -p /home/oracle/oracle/product/oradata/lunar/controlfile/o1_mf_3sfb1t6n_.ctl
mkdir -p /home/oracle/oracle/product/admin/lunar/cdump
mkdir -p /home/oracle/oracle/product/oradata
mkdir -p /home/oracle/oracle/product/flash_recovery_area
mkdir -p /home/oracle/oracle/product/admin/lunar/udump

nomount数据库:


[oracle@com lunartest]$ ss

SQL*Plus: Release 10.2.0.2.0 - Production on Sun Sep 23 22:36:22 2012

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount pfile=pfile.lunar.ora
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                  1218316 bytes
Variable Size              62916852 bytes
Database Buffers          100663296 bytes
Redo Buffers                2973696 bytes
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@com lunartest]$

5, 恢复控制文件

run{
allocate channel c1 type disk;
restore controlfile from '/lunartest/c-1172535738-20120921-01';
release channel c1;
}

6, 恢复数据文件

alter database mount;
run
{
allocate channel c1 type disk;
set newname for datafile 1 to '+DATA_DM01' ;
set newname for datafile 2 to '+DATA_DM01' ;
set newname for datafile 3 to '/home/oracle/product/oradata/lunar/datafile/sysaux01.dbf' ;
set newname for datafile 4 to '/home/oracle/product/oradata/lunar/datafile/users01.dbf' ;
set newname for datafile 5 to '/home/oracle/product/oradata/lunar/datafile/example01.dbf' ;
set newname for datafile 6 to '/home/oracle/product/oradata/lunar/datafile/inventory01.dbf' ;
set newname for datafile 7 to '/home/oracle/product/oradata/lunar/datafile/odi_default.dbf' ;
set newname for datafile 8 to '/home/oracle/product/oradata/lunar/datafile/test1-01.dbf' ;
set newname for datafile 9 to '/home/oracle/product/oradata/lunar/datafile/system1.dbf' ;
set newname for datafile 10 to '/home/oracle/product/oradata/lunar/datafile/rman01.dbf' ;
restore database;
switch datafile all;
release channel c1;
}

7, 修改pfile文件(这一步只有同机克隆采用,异机恢复不用)

[oracle@gg lunartest]$ cat pfile.lunar.bak
*.aq_tm_processes=0
*.audit_file_dest='/home/oracle/product/admin/lunar/adump'
*.background_dump_dest='/home/oracle/product/admin/lunar/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/home/oracle/product/oradata/lunar/controlfile/o1_mf_3sfb1t6n_.ctl'
*.core_dump_dest='/home/oracle/product/admin/lunar/cdump'
*.db_block_size=8192
*.db_create_file_dest='/home/oracle/product/oradata'
*.db_domain='oracle.com'
*.db_file_multiblock_read_count=8
*.db_name='lunar'
*.db_recovery_file_dest='/home/oracle/product/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.job_queue_processes=0
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=150
*.recyclebin='OFF'
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=167772160
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/home/oracle/product/admin/lunar/udump'
db_name = "lunar"
instance_name = lunar
service_names = lunar

8, 重建控制文件

CREATE CONTROLFILE SET DATABASE "lunar" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 (
    '/home/oracle/product/oradata/lunar/datafile/redo01.log'
  ) SIZE 50M,
  GROUP 2 (
   '/home/oracle/product/oradata/lunar/datafile/redo02.log'
  ) SIZE 50M,
  GROUP 3 (
  '/home/oracle/product/oradata/lunar/datafile/redo03.log'
  ) SIZE 50M
DATAFILE
  '/home/oracle/product/oradata/lunar/datafile/system01.dbf',
  '/home/oracle/product/oradata/lunar/datafile/undotbs01.dbf',
  '/home/oracle/product/oradata/lunar/datafile/sysaux01.dbf',
  '/home/oracle/product/oradata/lunar/datafile/users01.dbf',
  '/home/oracle/product/oradata/lunar/datafile/example01.dbf',
  '/home/oracle/product/oradata/lunar/datafile/inventory01.dbf',
  '/home/oracle/product/oradata/lunar/datafile/odi_default.dbf',
  '/home/oracle/product/oradata/lunar/datafile/test1-01.dbf',
  '/home/oracle/product/oradata/lunar/datafile/system1.dbf',
  '/home/oracle/product/oradata/lunar/datafile/rman01.dbf'
CHARACTER SET US7ASCII
;

9, 应用归档日志
catalog start with ‘/lunartest/’;
recover database;

10, 打开数据库
alter database open resetlogs;

11, 添加临时文件
alter tablespace temp add tempfile ‘/home/oracle/product/oradata/lunar/datafile/temp01.dbf’ size 10m autoextend on next 10m maxsize 10g;

此条目发表在 backup&recovery 分类目录,贴了 , 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注