Oracle 11g RMAN新特性active database duplicate 数据库异构

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:1413

Oracle 11g RMAN新特性active database duplicate 数据库异构

主库:linux rh4+oracle 11.1.0.6
数据文件 /oradata/asm11g
复制到:windows 2003 server+oracle 11.1.0.6
数据文件 f:\asm11g 下
简称 主库和复制库
主库只需要复制密码文件 $ORACLE_HOME/dbs/orapwasm11g 到 windows $ORACLE_HOME/database/目录下
并且重命名为PWDasm11g.ora
现在我们做需要复制到windows 2003库的准备:
在windows 2003 server F盘上 新建asm11g 目录
oracle_base d:\app\administrator\admin 目录下新建asm11g 目录
d:\app\administrator\admin\asm11g\目录下 新建adump,dpdump,pfile 三个目录
在F盘上 新建个 init.ora 文件 里面输入db_name=asm11g
1,复制库启动到 nomount 下
C:\Documents and Settings\复制Administrator>set oracle_sid=asm11g
C:\Documents and Settings\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.1.0.6.0 - Production on Fri Aug 1 12:19:01 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile='f:\init.ora';
ORACLE instance started.
Total System Global Area 146472960 bytes
Fixed Size 1331740 bytes
Variable Size 92278244 bytes
Database Buffers 50331648 bytes
Redo Buffers 2531328 bytes
SQL> exit

主库开始运行以下命令开始复制:
[oracle@asm11g ~]$ rman target / auxiliary mailto:sys/abcdefg@asm11g_s]sys/abcdefg@asm11g_s
Recovery Manager: Release 11.1.0.6.0 - Production on Sun Jul 27 06:40:22 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: ASM11G (DBID=4214158610)
connected to auxiliary database: ASM11G (not mounted)

RMAN> duplicate target database to 'asm11g'
2> from active database
3> spfile set DB_UNIQUE_NAME 'asm11g'
4> set control_files 'f:\asm11g\control01.ctl';
Starting Duplicate Db at 27-JUL-08
using channel ORA_AUX_DISK_1
contents of Memory Script.:
{
backup as copy reuse
file '/u01/app/oracle/product/11.1.6/db_1/dbs/spfileasm11g.ora' auxiliary format
'D:\APP\ADMINISTRATOR\PRODUCT\11.1.0\DB_1\DATABASE\SPFILEASM11G.ORA' ;
sql clone "alter system set spfile= ''D:\APP\ADMINISTRATOR\PRODUCT\11.1.0\DB_1\DATABASE\SPFILEASM11G.ORA''";
}
executing Memory Script
Starting backup at 27-JUL-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=103 device type=DISK
Finished backup at 27-JUL-08
sql statement: alter system set spfile= ''D:\APP\ADMINISTRATOR\PRODUCT\11.1.0\DB_1\DATABASE\SPFILEASM11G.ORA''
contents of Memory Script.:
{
sql clone "alter system set db_name =
''ASM11G'' comment=
''duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''ASM11G'' comment=
''duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''asm11g'' comment=
'''' scope=spfile";
sql clone "alter system set control_files =
''f:\asm11g\control01.ctl'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount ;
}
executing Memory Script
sql statement: alter system set db_name = ''ASM11G'' comment= ''duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''ASM11G'' comment= ''duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''asm11g'' comment= '''' scope=spfile
sql statement: alter system set control_files = ''f:\asm11g\control01.ctl'' comment= '''' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 07/27/2008 06:41:37
RMAN-03015: error occurred in stored script. Memory Script
RMAN-04014: startup failed: ORA-48108: invalid value given for the diagnostic_dest init.ora parameter
ORA-48140: the specified ADR Base directory does not exist [d:\u01\app\oracle]
ORA-48187: specified directory does not exist
OSD-00002: additional error information
O/S-Error: (OS 3) The system cannot find the path specified.
这个错误是因为从主库拷贝spfileasm11g.ora 到复制库的 所以两边oracle_base 不一致 造成复制库启动不了
这个时候只需要修改相关参数为复制库的oracle_base 和修改文件转换路径参数
复制库修改参数文件如下:
C:\Documents and Settings\Administrator>set oracle_sid=asm11g
C:\Documents and Settings\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.1.0.6.0 - Production on Fri Aug 1 12:26:24 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to an idle instance.
SQL> create pfile from spfile;
File created.
首先创建出pfile 文件 用ue 编辑最后修改的参数文件如下:
asm11g.__db_cache_size=276824064
asm11g.__java_pool_size=4194304
asm11g.__large_pool_size=4194304
asm11g.__oracle_base='D:\app\Administrator'#ORACLE_BASE set from environment
asm11g.__pga_aggregate_target=138412032
asm11g.__sga_target=411041792
asm11g.__shared_io_pool_size=0
asm11g.__shared_pool_size=121634816
asm11g.__streams_pool_size=0
*.audit_file_dest='D:\app\Administrator\admin\asm11g\adump'
*.audit_trail='db'
*.compatible='11.1.0.0.0'
*.control_files='f:\asm11g\control01.ctl'
*.db_block_size=8192
*.db_create_file_dest='+data'
*.db_domain=''
*.db_file_name_convert='/oradata/asm11g','f:\asm11g' # 数据文件路径转换
*.db_name='ASM11G'#duplicate
*.db_recovery_file_dest='+DATA'
*.db_recovery_file_dest_size=2147483648
*.db_unique_name='asm11g'
*.diagnostic_dest='D:\app\Administrator' --ORACLE_BASE
*.log_archive_dest_1='location=f:\asm11g DB_UNIQUE_NAME=asm11g'
*.log_archive_dest_2='service=standby SYNC VALID_FOR=(ONLINE_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=30
*.log_archive_min_succeed_dest=2
*.log_file_name_convert='/oradata/asm11g','f:\asm11g' --日志文件路径转换
*.open_cursors=300
*.pga_aggregate_target=136314880
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sec_case_sensitive_logon=FALSE
*.sga_target=408944640
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'
修改保存后 生成spfile文件
SQL> create spfile from pfile;
File created.
复制库启动到nomount状态
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 414306304 bytes
Fixed Size 1333536 bytes
Variable Size 130025184 bytes
Database Buffers 276824064 bytes
Redo Buffers 6123520 bytes

主库再次运行复制命令:
[oracle@asm11g ~]$ rman target / auxiliary mailto:sys/abcdefg@asm11g_s]sys/abcdefg@asm11g_s
Recovery Manager: Release 11.1.0.6.0 - Production on Sun Jul 27 06:44:49 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: ASM11G (DBID=4214158610)
connected to auxiliary database: ASM11G (not mounted)
RMAN> duplicate target database to 'asm11g'
2> from active database
3> ;
Starting Duplicate Db at 27-JUL-08
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=152 device type=DISK
contents of Memory Script.:
{
set newname for datafile 1 to
"F:\ASM11G\SYSTEM01.DBF";
set newname for datafile 2 to
"F:\ASM11G\SYSAUX01.DBF";
set newname for datafile 3 to
"F:\ASM11G\UNDOTBS101.DBF";
set newname for datafile 4 to
"F:\ASM11G\USERS01.DBF";
set newname for datafile 5 to
"F:\ASM11G\TEST01_NEW.DBF";
backup as copy reuse
datafile 1 auxiliary format
"F:\ASM11G\SYSTEM01.DBF" datafile
2 auxiliary format
"F:\ASM11G\SYSAUX01.DBF" datafile
3 auxiliary format
"F:\ASM11G\UNDOTBS101.DBF" datafile
4 auxiliary format
"F:\ASM11G\USERS01.DBF" datafile
5 auxiliary format
"F:\ASM11G\TEST01_NEW.DBF" ;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting backup at 27-JUL-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=100 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/oradata/asm11g/system01.dbf
output file name=F:\ASM11G\SYSTEM01.DBF tag=TAG20080727T064459 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/oradata/asm11g/undotbs101.dbf
output file name=F:\ASM11G\UNDOTBS101.DBF tag=TAG20080727T064459 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:16
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/oradata/asm11g/sysaux01.dbf
output file name=F:\ASM11G\SYSAUX01.DBF tag=TAG20080727T064459 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/oradata/asm11g/test01_new.dbf
output file name=F:\ASM11G\TEST01_NEW.DBF tag=TAG20080727T064459 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/oradata/asm11g/users01.dbf
output file name=F:\ASM11G\USERS01.DBF tag=TAG20080727T064459 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 27-JUL-08
sql statement: alter system archive log current
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ASM11G" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 4 ( 'F:\ASM11G\REDO01.LOG' ) SIZE 50 M REUSE,
GROUP 5 ( 'F:\ASM11G\REDO02.LOG' ) SIZE 50 M REUSE,
GROUP 6 ( 'F:\ASM11G\REDO03.LOG' ) SIZE 50 M REUSE
DATAFILE
'F:\ASM11G\SYSTEM01.DBF'
CHARACTER SET WE8MSWIN1252

contents of Memory Script.:
{
backup as copy reuse
archivelog like "/u01/app/oracle/archivelog/1_163_660159058.arc" auxiliary format
"F:\ASM11G\1_163_660159058.ARC" ;
catalog clone archivelog "F:\ASM11G\1_163_660159058.ARC";
switch clone datafile all;
}
executing Memory Script
Starting backup at 27-JUL-08
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=163 RECID=220 STAMP=661157178
output file name=F:\ASM11G\1_163_660159058.ARC RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:03
Finished backup at 27-JUL-08
cataloged archived log
archived log file name=F:\ASM11G\1_163_660159058.ARC RECID=1 STAMP=661609914
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=661609914 file name=F:\ASM11G\SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=661609914 file name=F:\ASM11G\UNDOTBS101.DBF
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=661609914 file name=F:\ASM11G\USERS01.DBF
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=661609914 file name=F:\ASM11G\TEST01_NEW.DBF
contents of Memory Script.:
{
set until scn 615675;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 27-JUL-08
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 163 is already on disk as file F:\ASM11G\1_163_660159058.ARC
archived log file name=F:\ASM11G\1_163_660159058.ARC thread=1 sequence=163
media recovery complete, elapsed time: 00:00:00
Finished recover at 27-JUL-08
contents of Memory Script.:
{
shutdown clone immediate;
startup clone nomount ;
}
executing Memory Script
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 414306304 bytes
Fixed Size 1333536 bytes
Variable Size 130025184 bytes
Database Buffers 276824064 bytes
Redo Buffers 6123520 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ASM11G" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 4 ( 'F:\ASM11G\REDO01.LOG' ) SIZE 50 M REUSE,
GROUP 5 ( 'F:\ASM11G\REDO02.LOG' ) SIZE 50 M REUSE,
GROUP 6 ( 'F:\ASM11G\REDO03.LOG' ) SIZE 50 M REUSE
DATAFILE
'F:\ASM11G\SYSTEM01.DBF'
CHARACTER SET WE8MSWIN1252

contents of Memory Script.:
{
set newname for tempfile 2 to
"F:\ASM11G\TEMP01.DBF";
switch clone tempfile all;
catalog clone datafilecopy "F:\ASM11G\SYSAUX01.DBF";
catalog clone datafilecopy "F:\ASM11G\UNDOTBS101.DBF";
catalog clone datafilecopy "F:\ASM11G\USERS01.DBF";
catalog clone datafilecopy "F:\ASM11G\TEST01_NEW.DBF";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 2 to F:\ASM11G\TEMP01.DBF in control file
cataloged datafile copy
datafile copy file name=F:\ASM11G\SYSAUX01.DBF RECID=1 STAMP=661609931
cataloged datafile copy
datafile copy file name=F:\ASM11G\UNDOTBS101.DBF RECID=2 STAMP=661609931
cataloged datafile copy
datafile copy file name=F:\ASM11G\USERS01.DBF RECID=3 STAMP=661609931
cataloged datafile copy
datafile copy file name=F:\ASM11G\TEST01_NEW.DBF RECID=4 STAMP=661609931
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=661609931 file name=F:\ASM11G\SYSAUX01.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=661609931 file name=F:\ASM11G\UNDOTBS101.DBF
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=661609931 file name=F:\ASM11G\USERS01.DBF
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=661609931 file name=F:\ASM11G\TEST01_NEW.DBF
contents of Memory Script.:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 27-JUL-08
RMAN>
这时登录复制库进行查询,可以正常使用
C:\Documents and Settings\Administrator>set oracle_sid=asm11g
C:\Documents and Settings\Administrator>sqlplus / as sysdba
SQL*Plus: Release 11.1.0.6.0 - Production on Fri Aug 1 12:53:55 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select status,instance_name from v$instance;
STATUS INSTANCE_NAME
------------ ----------------
OPEN asm11g
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination f:\asm11g
Oldest online log sequence 1
Next log sequence to archive 2
Current log sequence 2
SQL>

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】