11g新加的在线数据库复制功能

上一篇 / 下一篇  2008-08-25 09:58:38

11g在使用RMAN进行复制数据库的操作中,不再需要我们对源数据库进行备份了。
可以直接在没有备份的情况下,将运行中的数据库复制一份出来。
下面的实验在源数据库所在的主机上复制一个数据库出来。
源数据库SID:orcl
目标数据库SID:dbtest
[oracle@edbjr3p0 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jul 31 16:06:212008

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>connect sys/oracle@orcl as sysdba
Connected.
SQL>archive log list;#验证启用了归档
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 113
Next log sequence to archive 115
Current log sequence 115
SQL> exit

随便配置一个pfile,只要下面两个初始化参数就可以了
[oracle@edbjr3p0 dbs]$ cat initdbtest.ora
db_name=dbtest
remote_login_passwordfile=exclusive

将dbtest启动到nomount阶段
[oracle@edbjr3p0 dbs]$export ORACLE_SID=dbtest
[oracle@edbjr3p0 dbs]$sqlplus /nolog

SQL*Plus: Release 11.1.0.6.0 - Production on Thu Jul 31 15:46:16 2008

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

SQL>connect / as sysdba
Connected to an idle instance.
SQL>startup nomount;
ORACLE instance started.

Total System Global Area 146472960 bytes
Fixed Size 1298472 bytes
Variable Size 92278744 bytes
Database Buffers 50331648 bytes
Redo Buffers 2564096 bytes
SQL> exit

进入RMAN进行复制。
[oracle@edbjr3p0 dbs]$rman

Recovery Manager: Release 11.1.0.6.0 - Production on Thu Jul 31 15:46:31 2008

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

RMAN>connect target sys/oracle@orcl

connected to target database: ORCL (DBID=1189042550)

RMAN>connect auxiliary sys/oracle@dbtest

connected to auxiliary database: DBTEST (not mounted)

RMAN>run{
duplicate target database to dbtest from active database spfile #这里的spfile表示将源库的spfile拷贝到复制库
parameter_value_convert='/u01/app/oracle/oradata/orcl','/u02/app/oracle/oradata/dbtest' #这里的参数用来设置源库的控制文件等文件到复制库以后所在的路径
set sga_max_size='200M'
set sga_target='120M'
set log_file_name_convert='/u01/app/oracle/oradata/orcl','/u02/app/oracle/oradat a/dbtest'
set db_file_name_convert='/u01/app/oracle/oradata/orcl','/u02/app/oracle/oradata /dbtest';
}
2> 3> 4> 5> 6> 7> 8>
Starting Duplicate Db at 31-JUL-08
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=98 device type=DISK
allocated channel: ORA_AUX_DISK_2
channel ORA_AUX_DISK_2: SID=97 device type=DISK
allocated channel: ORA_AUX_DISK_3
channel ORA_AUX_DISK_3: SID=96 device type=DISK

contents of Memory Script.:
{
backup as copy reuse
file '/u01/app/oracle/product/11.1.0/db_1/dbs/spfileorcl.ora' auxiliary form. at
'/u01/app/oracle/product/11.1.0/db_1/dbs/spfiledbtest.ora' ;
sqlclone "alter system set spfile= ''/u01/app/oracle/product/11.1.0/db_1/dbs /spfiledbtest.ora''";
}
executing Memory Script

Starting backup at 31-JUL-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=126 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=124 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=123 device type=DISK
Finished backup at 31-JUL-08

sql statement: alter system set spfile= ''/u01/app/oracle/product/11.1.0/db_1/db s/spfiledbtest.ora''

contents of Memory Script.:
{
sql clone "alter system set db_name =
''DBTEST'' comment=
''duplicate'' scope=spfile";
sql clone "alter system set control_files =
''/u02/app/oracle/oradata/dbtest/control01.ctl'', ''/u02/app/oracle/oradata/dbt est/control02.ctl'', ''/u02/app/oracle/oradata/dbtest/control03.ctl'' comment=
'''' scope=spfile";
sql clone "alter system set sga_max_size =
200M comment=
'''' scope=spfile";
sql clone "alter system set sga_target =
120M comment=
'''' scope=spfile";
sql clone "alter system set log_file_name_convert =
''/u01/app/oracle/oradata/orcl'', ''/u02/app/oracle/oradata/dbtest'' comment=
'''' scope=spfile";
sql clone "alter system set db_file_name_convert =
''/u01/app/oracle/oradata/orcl'', ''/u02/app/oracle/oradata/dbtest'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount ;
}
executing Memory Script

sql statement: alter system set db_name = ''DBTEST'' comment= ''duplicate'' sc pe=spfile

sql statement: alter system set control_files = ''/u02/app/oracle/oradata/dbte st/control01.ctl'', ''/u02/app/oracle/oradata/dbtest/control02.ctl'', ''/u02/app /oracle/oradata/dbtest/control03.ctl'' comment= '''' scope=spfile

sql statement: alter system set sga_max_size = 200M comment= '''' scope=spfile

sql statement: alter system set sga_target = 120M comment= '''' scope=spfile

sql statement: alter system set log_file_name_convert = ''/u01/app/oracle/orad ata/orcl'', ''/u02/app/oracle/oradata/dbtest'' comment= '''' scope=spfile

sql statement: alter system set db_file_name_convert = ''/u01/app/oracle/orada ta/orcl'', ''/u02/app/oracle/oradata/dbtest'' comment= '''' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area 209235968 bytes

Fixed Size 1298920 bytes
Variable Size 155192856 bytes
Database Buffers 50331648 bytes
Redo Buffers 2412544 bytes

contents of Memory Script.:
{
set newname for datafile 1 to
"/u02/app/oracle/oradata/dbtest/system01.dbf";
set newname for datafile 2 to
"/u02/app/oracle/oradata/dbtest/sysaux01.dbf";
set newname for datafile 3 to
"/u02/app/oracle/oradata/dbtest/undotbs01.dbf";
set newname for datafile 4 to
"/u02/app/oracle/oradata/dbtest/users01.dbf";
set newname for datafile 5 to
"/u02/app/oracle/oradata/dbtest/example01.dbf";
backup as copy reuse
datafile 1 auxiliary format
"/u02/app/oracle/oradata/dbtest/system01.dbf" datafile
2 auxiliary format
"/u02/app/oracle/oradata/dbtest/sysaux01.dbf" datafile
3 auxiliary format
"/u02/app/oracle/oradata/dbtest/undotbs01.dbf" datafile
4 auxiliary format
"/u02/app/oracle/oradata/dbtest/users01.dbf" datafile
5 auxiliary format
"/u02/app/oracle/oradata/dbtest/example01.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 31-JUL-08
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_2: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_3: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
output file name=/u02/app/oracle/oradata/dbtest/undotbs01.dbf tag=TAG20080731T155553 RECID=0 STAMP=0
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:04:38
channel ORA_DISK_3: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
output file name=/u02/app/oracle/oradata/dbtest/sysaux01.dbf tag=TAG20080731T155553 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:05:28
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
output file name=/u02/app/oracle/oradata/dbtest/system01.dbf tag=TAG20080731T155553 RECID=0 STAMP=0
channel ORA_DISK_2: datafile copy complete, elapsed time: 00:05:26
output file name=/u02/app/oracle/oradata/dbtest/example01.dbf tag=TAG20080731T155553 RECID=0 STAMP=0
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
output file name=/u02/app/oracle/oradata/dbtest/users01.dbf tag=TAG20080731T155553 RECID=0 STAMP=0
channel ORA_DISK_3: datafile copy complete, elapsed time: 00:00:48
Finished backup at 31-JUL-08

sql statement: alter system archive log current
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DBTEST" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u02/app/oracle/oradata/dbtest/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/u02/app/oracle/oradata/dbtest/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/u02/app/oracle/oradata/dbtest/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/u02/app/oracle/oradata/dbtest/system01.dbf'
CHARACTER SET AL32UTF8


contents of Memory Script.:
{
backup as copy reuse
archivelog like "/u01/app/oracle/product/11.1.0/db_1/dbs/arch1_115_661261816.dbf" auxiliary format
"/u01/app/oracle/flash_recovery_area/DBTEST/archivelog/2008_07_31/o1_mf_1_115_%u_.arc" archivelog like
"/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2008_07_31/o1_mf_1_115_492wdc34_.arc" auxiliary format
"/u01/app/oracle/flash_recovery_area/DBTEST/archivelog/2008_07_31/o1_mf_1_115_%u_.arc" ;
catalog clone recovery area;
switch clone datafile all;
}
executing Memory Script

Starting backup at 31-JUL-08
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=115 RECID=15 STAMP=661536142
channel ORA_DISK_2: starting archived log copy
input archived log thread=1 sequence=115 RECID=16 STAMP=661536142
output file name=/u01/app/oracle/flash_recovery_area/DBTEST/archivelog/2008_07_31/o1_mf_1_115_13jmsfci_.arc RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:10
output file name=/u01/app/oracle/flash_recovery_area/DBTEST/archivelog/2008_07_31/o1_mf_1_115_14jmsfcr_.arc RECID=0 STAMP=0
channel ORA_DISK_2: archived log copy complete, elapsed time: 00:00:03
Finished backup at 31-JUL-08

searching for all files in the recovery area

List of Files Unknown to the Database
=====================================
File Name: /u01/app/oracle/flash_recovery_area/DBTEST/archivelog/2008_07_31/o1_mf_1_115_14jmsfcr_.arc
File Name: /u01/app/oracle/flash_recovery_area/DBTEST/archivelog/2008_07_31/o1_mf_1_115_13jmsfci_.arc
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/flash_recovery_area/DBTEST/archivelog/2008_07_31/o1_mf_1_115_14jmsfcr_.arc
File Name: /u01/app/oracle/flash_recovery_area/DBTEST/archivelog/2008_07_31/o1_mf_1_115_13jmsfci_.arc

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=661536169 file name=/u02/app/oracle/oradata/dbtest/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=661536170 file name=/u02/app/oracle/oradata/dbtest/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=661536170 file name=/u02/app/oracle/oradata/dbtest/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=661536170 file name=/u02/app/oracle/oradata/dbtest/example01.dbf

contents of Memory Script.:
{
set until scn 2866907;
recover
clone database
delete archivelog
;
}
executing Memory Script

executing command: SET until clause

Starting recover at 31-JUL-08
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=153 device type=DISK
allocated channel: ORA_AUX_DISK_2
channel ORA_AUX_DISK_2: SID=152 device type=DISK
allocated channel: ORA_AUX_DISK_3
channel ORA_AUX_DISK_3: SID=151 device type=DISK

starting media recovery

archived log for thread 1 with sequence 115 is already on disk as file /u01/app/oracle/flash_recovery_area/DBTEST/archivelog/2008_07_31/o1_mf_1_115_14jmsfcr_.arc
archived log file name=/u01/app/oracle/flash_recovery_area/DBTEST/archivelog/2008_07_31/o1_mf_1_115_14jmsfcr_.arc thread=1 sequence=115
media recovery complete, elapsed time: 00:00:20
Finished recover at 31-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 209235968 bytes

Fixed Size 1298920 bytes
Variable Size 155192856 bytes
Database Buffers 50331648 bytes
Redo Buffers 2412544 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DBTEST" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u02/app/oracle/oradata/dbtest/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/u02/app/oracle/oradata/dbtest/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/u02/app/oracle/oradata/dbtest/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/u02/app/oracle/oradata/dbtest/system01.dbf'
CHARACTER SET AL32UTF8


contents of Memory Script.:
{
set newname for tempfile 1 to
"/u02/app/oracle/oradata/dbtest/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u02/app/oracle/oradata/dbtest/sysaux01.dbf";
catalog clone datafilecopy "/u02/app/oracle/oradata/dbtest/undotbs01.dbf";
catalog clone datafilecopy "/u02/app/oracle/oradata/dbtest/users01.dbf";
catalog clone datafilecopy "/u02/app/oracle/oradata/dbtest/example01.dbf";
switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u02/app/oracle/oradata/dbtest/temp01.dbf in control file

cataloged datafile copy
datafile copy file name=/u02/app/oracle/oradata/dbtest/sysaux01.dbf RECID=1 STAMP=661536213

cataloged datafile copy
datafile copy file name=/u02/app/oracle/oradata/dbtest/undotbs01.dbf RECID=2 STAMP=661536213

cataloged datafile copy
datafile copy file name=/u02/app/oracle/oradata/dbtest/users01.dbf RECID=3 STAMP=661536213

cataloged datafile copy
datafile copy file name=/u02/app/oracle/oradata/dbtest/example01.dbf RECID=4 STAMP=661536213

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=661536213 file name=/u02/app/oracle/oradata/dbtest/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=661536213 file name=/u02/app/oracle/oradata/dbtest/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=661536213 file name=/u02/app/oracle/oradata/dbtest/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=661536213 file name=/u02/app/oracle/oradata/dbtest/example01.dbf

contents of Memory Script.:
{
Alter clone database open resetlogs;
}
executing Memory Script

database opened

TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-11-22  
      1
2345678
9101112131415
16171819202122
23242526272829
30      

我的存档

数据统计

  • 访问量: 66
  • 日志数: 4
  • 建立时间: 2008-08-25
  • 更新时间: 2008-08-25

RSS订阅

Open Toolbar