Home > DGCA > create DG via RMAN

create DG via RMAN

跟普通搭建DG方式相比,用RMAN来搞不见得会快。虽然rman 可以利用backupset的特性来减少整个DB的大小,但是他也额外需要经过backup 到本地,scp到远端,远端再restore的额外步骤,这样一来对磁盘空间的要求就比较高了,而且比传统多出的backup+restore过程的时间消耗也是不少。理想的情况是backup到nfs上,再直接从nfs restore。
简单整理了下搭建的几个步骤:
1.事前准备,包括主备参数文件配置,tns配置,listener配置,orapw文件,并且startup nomount备库
2.全备主库
RMAN> backup full database format ‘/data/full_%d_%T_%u.bak’;
用copy的方式也行

Starting backup at 22-FEB-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/data/oradata/johnnydb/SYSTEM01.DBF
input datafile fno=00003 name=/data/oradata/johnnydb/SYSAUX01.DBF
input datafile fno=00002 name=/data/oradata/johnnydb/UNDOTBS01.DBF
input datafile fno=00004 name=/data/oradata/johnnydb/USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 22-FEB-12
channel ORA_DISK_1: finished piece 1 at 22-FEB-12
piece handle=/data/full_JOHNNYDB_20120222_07n3vv81.bak tag=TAG20120222T202433 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:03:15
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 22-FEB-12
channel ORA_DISK_1: finished piece 1 at 22-FEB-12
piece handle=/data/full_JOHNNYDB_20120222_08n3vve5.bak tag=TAG20120222T202433 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:06
Finished backup at 22-FEB-12

3.创建standby controlfile
3.1 BACKUPSET的方式:RMAN> backup current controlfile for standby format ‘/data/std.ctl’;
3.2 COPY的方式:RMAN> copy current controlfile for standby to ‘/data/std2.ctl’;
3.3 如果之前用SQL> alter database create standby controlfile as ‘/data/std3.ctl’;的方式创建过,可以用RMAN> catalog controlfilecopy ‘/data/std3.ctl’;的方式注册进来

4.拷贝库全备以及standby controlfile 到备库
[oracle@localhost data]$ scp full_JOHNNYDB_20120222_07n3vv81.bak std.ctl 192.168.220.129:/data/
5.利用duplicate 创建备库
[oracle@localhost johnnydb]$ rman target / auxiliary sys/sys@johnnydb_dg

Recovery Manager: Release 10.2.0.1.0 – Production on Wed Feb 22 21:26:49 2012

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

connected to target database: JOHNNYDB (DBID=979561174)
connected to auxiliary database: JOHNNYDB (not mounted)

RMAN> duplicate target database for standby ;
如果主备的数据文件,LOG文件路径都一样的,需要带上NOFILENAMECHECK选项。
这个命令默认的操作是mount standby database,restore controlfile+datafile,如果想restore完自动recover的话,可以带上DORECOVER选项。
例如:RMAN> duplicate target database for standby [NOFILENAMECHECK] [DORECOVER];
对于数据文件,log文件路径不一样的情况,duplicate的时候也可以用set name来重定向文件路径。
例如:
RUN
{
# set new file names for the datafiles
SET NEWNAME FOR DATAFILE 1 TO ‘?/dbs/standby_data_01.f’;
SET NEWNAME FOR DATAFILE 2 TO ‘?/dbs/standby_data_02.f’;
.
.
.
# run the DUPLICATE command
DUPLICATE TARGET DATABASE FOR STANDBY;
}
不过以后的数据文件同步还是要用到*_file_name_convert参数,用set newname的方式更多的出现在移植DB的场景,而不是create standby,虽然这样也可以。
6.如果需要的话,重建standby redo log,或者直接从主库将stb redo拷贝过来也行。
7.recover
SQL> recover managed standby database [using current logfile] disconnect;

Categories: DGCA Tags:
  1. No comments yet.
  1. No trackbacks yet.