Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1097842
  • 博文数量: 276
  • 博客积分: 10077
  • 博客等级: 上将
  • 技术积分: 2513
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-24 20:31
文章分类

全部博文(276)

文章存档

2020年(1)

2015年(5)

2012年(2)

2011年(6)

2010年(7)

2009年(224)

2008年(31)

我的朋友

分类: Oracle

2009-03-30 17:04:31

从Oracle9i开始,Oracle允许使用duplicate的方式进行Dataguard备用数据库的创建,非常简便。

当然首先需要在主库进行一个RMAN备份,然后需要将备份传送到备用数据库和主库相同的目录下。
在备用主机创建监听、必要的目录结构、参数文件,启动实例,然后就可以在主库连接从库进行恢复。

恢复的主要命令是: duplicate target database for standby;

 
+++++++++++++++++++++++++++++Primary++++++++++++++++++++++++++++++++++++++++++++++
C:\>%oracle_home%\bin\rman
Recovery Manager: Release 10.2.0.3.0 - Production on Mon Mar 30 16:48:18 2009
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
RMAN> connect target /
connected to target database: LGX (DBID=2379918214)
RMAN> run{
2> allocate channel ch0 type disk format 'p:\backup02\%U' maxpiecesize 100M;
3> backup database;
4> release channel ch0;
5> }
allocated channel: ch0
channel ch0: sid=154 devtype=DISK
Starting backup at 30-MAR-09
channel ch0: starting full datafile backupset
channel ch0: specifying datafile(s) in backupset
input datafile fno=00001 name=P:\LGXDB\SYSTEM01.DBF
input datafile fno=00003 name=P:\LGXDB\SYSAUX01.DBF
input datafile fno=00002 name=P:\LGXDB\UNDOTBS01.DBF
input datafile fno=00004 name=P:\LGXDB\USERS01.DBF
channel ch0: starting piece 1 at 30-MAR-09
channel ch0: finished piece 1 at 30-MAR-09
piece handle=P:\BACKUP02\0KKB7QP7_1_1 tag=TAG20090330T164943 comment=NONE
channel ch0: starting piece 2 at 30-MAR-09
channel ch0: finished piece 2 at 30-MAR-09
piece handle=P:\BACKUP02\0KKB7QP7_2_1 tag=TAG20090330T164943 comment=NONE
channel ch0: starting piece 3 at 30-MAR-09
channel ch0: finished piece 3 at 30-MAR-09
piece handle=P:\BACKUP02\0KKB7QP7_3_1 tag=TAG20090330T164943 comment=NONE
channel ch0: starting piece 4 at 30-MAR-09
channel ch0: finished piece 4 at 30-MAR-09
piece handle=P:\BACKUP02\0KKB7QP7_4_1 tag=TAG20090330T164943 comment=NONE
channel ch0: starting piece 5 at 30-MAR-09
channel ch0: finished piece 5 at 30-MAR-09
piece handle=P:\BACKUP02\0KKB7QP7_5_1 tag=TAG20090330T164943 comment=NONE
channel ch0: starting piece 6 at 30-MAR-09
channel ch0: finished piece 6 at 30-MAR-09
piece handle=P:\BACKUP02\0KKB7QP7_6_1 tag=TAG20090330T164943 comment=NONE
channel ch0: backup set complete, elapsed time: 00:00:16
channel ch0: starting full datafile backupset
channel ch0: specifying datafile(s) in backupset
including current control file in backupset
channel ch0: starting piece 1 at 30-MAR-09
channel ch0: finished piece 1 at 30-MAR-09
piece handle=P:\BACKUP02\0LKB7QPN_1_1 tag=TAG20090330T164943 comment=NONE
channel ch0: backup set complete, elapsed time: 00:00:02
Finished backup at 30-MAR-09
released channel: ch0
RMAN> run{
2> allocate channel ch0 type disk format 'p:\backup02\ctl_%U';
3> backup current controlfile for standby;
4>  release channel ch0;
5> }
allocated channel: ch0
channel ch0: sid=154 devtype=DISK
Starting backup at 30-MAR-09
channel ch0: starting full datafile backupset
channel ch0: specifying datafile(s) in backupset
including standby control file in backupset
channel ch0: starting piece 1 at 30-MAR-09
channel ch0: finished piece 1 at 30-MAR-09
piece handle=P:\BACKUP02\CTL_0MKB7QQM_1_1 tag=TAG20090330T165030 comment=NONE
channel ch0: backup set complete, elapsed time: 00:00:02
Finished backup at 30-MAR-09
released channel: ch0
 
#
#Copy 所有备份文件,参数文件,密码文件到standby机器上
#Startup nomount standby database
#
 
RMAN> connect auxiliary /
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: "newline, ;"
RMAN-01008: the bad identifier was: /
RMAN-01007: at line 1 column 35 file: standard input
RMAN> connect auxiliary
connected to auxiliary database: LGX (not mounted)
RMAN> duplicate target database for standby nofilenamecheck;
Starting Duplicate Db at 30-MAR-09
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=155 devtype=DISK
contents of Memory Script:
{
   restore clone standby controlfile;
   sql clone 'alter database mount standby database';
}
executing Memory Script
Starting restore at 30-MAR-09
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece P:\BACKUP02\CTL_0MKB7QQM_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=P:\BACKUP02\CTL_0MKB7QQM_1_1 tag=TAG20090330T165030
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output filename=P:\LGXDB\CONTROL01.CTL
output filename=P:\LGXDB\CONTROL02.CTL
output filename=P:\LGXDB\CONTROL03.CTL
Finished restore at 30-MAR-09
sql statement: alter database mount standby database
released channel: ORA_AUX_DISK_1
contents of Memory Script:
{
   set newname for tempfile  1 to
 "P:\LGXDB\TEMP01.DBF";
   switch clone tempfile all;
   set newname for datafile  1 to
 "P:\LGXDB\SYSTEM01.DBF";
   set newname for datafile  2 to
 "P:\LGXDB\UNDOTBS01.DBF";
   set newname for datafile  3 to
 "P:\LGXDB\SYSAUX01.DBF";
   set newname for datafile  4 to
 "P:\LGXDB\USERS01.DBF";
   restore
   check readonly
   clone database
   ;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to P:\LGXDB\TEMP01.DBF in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 30-MAR-09
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=157 devtype=DISK
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 P:\LGXDB\SYSTEM01.DBF
restoring datafile 00002 to P:\LGXDB\UNDOTBS01.DBF
restoring datafile 00003 to P:\LGXDB\SYSAUX01.DBF
restoring datafile 00004 to P:\LGXDB\USERS01.DBF
channel ORA_AUX_DISK_1: reading from backup piece P:\BACKUP02\0KKB7QP7_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=P:\BACKUP02\0KKB7QP7_1_1 tag=TAG20090330T164943
channel ORA_AUX_DISK_1: reading from backup piece P:\BACKUP02\0KKB7QP7_2_1
channel ORA_AUX_DISK_1: restored backup piece 2
piece handle=P:\BACKUP02\0KKB7QP7_2_1 tag=TAG20090330T164943
channel ORA_AUX_DISK_1: reading from backup piece P:\BACKUP02\0KKB7QP7_3_1
channel ORA_AUX_DISK_1: restored backup piece 3
piece handle=P:\BACKUP02\0KKB7QP7_3_1 tag=TAG20090330T164943
channel ORA_AUX_DISK_1: reading from backup piece P:\BACKUP02\0KKB7QP7_4_1
channel ORA_AUX_DISK_1: restored backup piece 4
piece handle=P:\BACKUP02\0KKB7QP7_4_1 tag=TAG20090330T164943
channel ORA_AUX_DISK_1: reading from backup piece P:\BACKUP02\0KKB7QP7_5_1
channel ORA_AUX_DISK_1: restored backup piece 5
piece handle=P:\BACKUP02\0KKB7QP7_5_1 tag=TAG20090330T164943
channel ORA_AUX_DISK_1: reading from backup piece P:\BACKUP02\0KKB7QP7_6_1
channel ORA_AUX_DISK_1: restored backup piece 6
piece handle=P:\BACKUP02\0KKB7QP7_6_1 tag=TAG20090330T164943
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:55
Finished restore at 30-MAR-09
contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy recid=6 stamp=682880024 filename=P:\LGXDB\SYSTEM01.DBF
datafile 2 switched to datafile copy
input datafile copy recid=7 stamp=682880024 filename=P:\LGXDB\UNDOTBS01.DBF
datafile 3 switched to datafile copy
input datafile copy recid=8 stamp=682880024 filename=P:\LGXDB\SYSAUX01.DBF
datafile 4 switched to datafile copy
input datafile copy recid=9 stamp=682880024 filename=P:\LGXDB\USERS01.DBF
Finished Duplicate Db at 30-MAR-09
RMAN>
+++++++++++++++++++++++++++++Primary++++++++++++++++++++++++++++++++++++++++++++++
 
 
+++++++++++++++++++++++++++++Standby++++++++++++++++++++++++++++++++++++++++++++++
SQL> alter database mount standby database;
alter database mount standby database
*
ERROR at line 1:
ORA-01100: database already mounted

SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL>
+++++++++++++++++++++++++++++Standby++++++++++++++++++++++++++++++++++++++++++++++
阅读(1789) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~