oracle-duplicat 本机不同目录复制

时间仓促还没来得及写注释和说明,之后补上

oracle :oracle11.2.0.4 
linux:Linux rhel6.6 3.8.13-44.1.1.el6uek.x86_64

source:infra
duplicat:leo

--1 infra backup

RUN { 
allocate channel c1 type disk;

BACKUP FORMAT '/u01/infra_%U_%T' skip inaccessible filesperset 5  DATABASE TAG infra_hot_db_bk; 
sql 'alter system archive log current';
BACKUP FORMAT '/u01/arch_%U_%T' skip inaccessible filesperset 5 ARCHIVELOG ALL DELETE INPUT; 
backup current controlfile tag='bak_ctlfile' format='/u01/ctl_file_%U_%T';
backup spfile tag='spfile' format='/u01/infra_spfile_%U_%T';

release channel c1;
}

--2 create leo dir

cd /u01/app/oracle/oradata/
mkdir leo

cd /u01/app/oracle/fast_recovery_area
mkdir -p LEO/archivelog/
mkdir leo

cd /u01/app/oracle/admin
mkdir leo

cd leo
mkdir pfile adump dpdump scripts

--3 create leo pfile

SQL> create pfile from spfile;

cd /u01/app/oracle/product/11.2.0/dbhome_1/dbs
cp initinfra.ora initleo.ora

[oracle@rhel6 dbs]$ vi initleo.ora 
infra.__db_cache_size=167772160
infra.__java_pool_size=4194304
infra.__large_pool_size=4194304
infra.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
infra.__pga_aggregate_target=184549376
infra.__sga_target=352321536
infra.__shared_io_pool_size=0
infra.__shared_pool_size=163577856
infra.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/leo/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/leo/control01.ctl','/u01/app/oracle/fast_recovery_area/leo/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='leo'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=8589934592
*.diagnostic_dest='/u01/app/oracle'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=536870912
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
db_file_name_convert = ('/u01/app/oracle/oradata/infra','/u01/app/oracle/oradata/leo')
log_file_name_convert = ('/u01/app/oracle/oradata/infra','/u01/app/oracle/oradata/leo')

--4、created leo orapwd

orapwd file=$ORACLE_HOME/dbs/orapwleo password=leo

--5、listner and tnsname

cat listener.ora 
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

infra=
   (DESCRIPTION=
     (ADDRESS_LIST=
       (ADDRESS=(PROTOCOL=tcp)(HOST=10.120.249.144)(PORT=1521))
    ))
    
SID_LIST_infra=
   (SID_LIST=
     (SID_DESC=
       (GLOBAL_DBNAME=infra)
       (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
       (SID_NAME=infra))
      )

leo=
   (DESCRIPTION=
     (ADDRESS_LIST=
       (ADDRESS=(PROTOCOL=tcp)(HOST=10.120.249.144)(PORT=1522))
    ))
    
SID_LIST_leo=
   (SID_LIST=
     (SID_DESC=
       (GLOBAL_DBNAME=leo)
       (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
       (SID_NAME=leo))
      )      
       
ADR_BASE_LISTENER = /u01/app/oracle

[oracle@rhel6 admin]$ cat tnsnames.ora 
infra=
  (DESCRIPTION=
   (ADDRESS_LIST=
    (ADDRESS=(PROTOCOL=tcp)(HOST=10.120.249.144)(PORT=1521)))
   (CONNECT_DATA=(SID=infra)
   (SERVER=DEDICATED)
   ))   
   
leo=
  (DESCRIPTION=
   (ADDRESS_LIST=
    (ADDRESS=(PROTOCOL=tcp)(HOST=10.120.249.144)(PORT=1522)))
   (CONNECT_DATA=(SID=leo)
   (SERVER=DEDICATED)
   ))  

--6、 leo startup nomount

export ORACLE_SID=leo
sqlplus "/as sysdba"
startup nomount pfile=?/dbs/initleo.ora

--7、do duplicate

export ORACLE_SID=leo

[oracle@rhel6 leo]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Thu Nov 27 16:48:28 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: INFRA (DBID=3958618701)

RMAN> connect auxiliary sys/leo@leo;

connected to auxiliary database: LEO (not mounted)

RMAN> duplicate target database to leo;

Starting Duplicate Db at 27-NOV-14
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=134 device type=DISK

contents of Memory Script:
{
   sql clone "create spfile from memory";
}
executing Memory Script

sql statement: create spfile from memory

contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     534462464 bytes

Fixed Size                     2254952 bytes
Variable Size                331351960 bytes
Database Buffers             192937984 bytes
Redo Buffers                   7917568 bytes


contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''INFRA'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name = 
 ''LEO'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone primary controlfile;
   alter clone database mount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''INFRA'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set  db_unique_name =  ''LEO'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area     534462464 bytes

Fixed Size                     2254952 bytes
Variable Size                331351960 bytes
Database Buffers             192937984 bytes
Redo Buffers                   7917568 bytes

Starting restore at 27-NOV-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=134 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/ctl_file_06pom3qo_1_1_20141127
channel ORA_AUX_DISK_1: piece handle=/u01/ctl_file_06pom3qo_1_1_20141127 tag=BAK_CTLFILE
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/leo/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/leo/control02.ctl
Finished restore at 27-NOV-14

database mounted

contents of Memory Script:
{
   set until scn  930052;
   set newname for datafile  1 to 
 "/u01/app/oracle/oradata/leo/system01.dbf";
   set newname for datafile  2 to 
 "/u01/app/oracle/oradata/leo/sysaux01.dbf";
   set newname for datafile  3 to 
 "/u01/app/oracle/oradata/leo/undotbs01.dbf";
   set newname for datafile  4 to 
 "/u01/app/oracle/oradata/leo/users01.dbf";
   restore
   clone database
   ;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 27-NOV-14
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/leo/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/leo/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/leo/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/leo/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/infra_01pom3ok_1_1_20141127
channel ORA_AUX_DISK_1: piece handle=/u01/infra_01pom3ok_1_1_20141127 tag=ORCL_HOT_DB_BK
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 27-NOV-14

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=864751826 file name=/u01/app/oracle/oradata/leo/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=864751826 file name=/u01/app/oracle/oradata/leo/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=864751826 file name=/u01/app/oracle/oradata/leo/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=864751826 file name=/u01/app/oracle/oradata/leo/users01.dbf

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

executing command: SET until clause

Starting recover at 27-NOV-14
using channel ORA_AUX_DISK_1

starting media recovery

channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=43
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=44
channel ORA_AUX_DISK_1: reading from backup piece /u01/arch_05pom3qg_1_1_20141127
channel ORA_AUX_DISK_1: piece handle=/u01/arch_05pom3qg_1_1_20141127 tag=TAG20141127T164329
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oracle/fast_recovery_area/LEO/archivelog/2014_11_27/o1_mf_1_43_b7fsgnly_.arc thread=1 sequence=43
channel clone_default: deleting archived log(s)
archived log file name=/u01/app/oracle/fast_recovery_area/LEO/archivelog/2014_11_27/o1_mf_1_43_b7fsgnly_.arc RECID=16 STAMP=864751828
archived log file name=/u01/app/oracle/fast_recovery_area/LEO/archivelog/2014_11_27/o1_mf_1_44_b7fsgnqs_.arc thread=1 sequence=44
channel clone_default: deleting archived log(s)
archived log file name=/u01/app/oracle/fast_recovery_area/LEO/archivelog/2014_11_27/o1_mf_1_44_b7fsgnqs_.arc RECID=17 STAMP=864751828
media recovery complete, elapsed time: 00:00:01
Finished recover at 27-NOV-14
Oracle instance started

Total System Global Area     534462464 bytes

Fixed Size                     2254952 bytes
Variable Size                331351960 bytes
Database Buffers             192937984 bytes
Redo Buffers                   7917568 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''LEO'' comment=
 ''Reset to original value by RMAN'' scope=spfile";
   sql clone "alter system reset  db_unique_name scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''LEO'' comment= ''Reset to original value by RMAN'' scope=spfile

sql statement: alter system reset  db_unique_name scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     534462464 bytes

Fixed Size                     2254952 bytes
Variable Size                331351960 bytes
Database Buffers             192937984 bytes
Redo Buffers                   7917568 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "LEO" RESETLOGS ARCHIVELOG 
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP   1 ( '/u01/app/oracle/oradata/leo/redo01.log' ) SIZE 50 M  REUSE,
  GROUP   2 ( '/u01/app/oracle/oradata/leo/redo02.log' ) SIZE 50 M  REUSE,
  GROUP   3 ( '/u01/app/oracle/oradata/leo/redo03.log' ) SIZE 50 M  REUSE
 DATAFILE
  '/u01/app/oracle/oradata/leo/system01.dbf'
 CHARACTER SET AL32UTF8

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

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/oradata/leo/temp01.dbf in control file

cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/leo/sysaux01.dbf RECID=1 STAMP=864751840
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/leo/undotbs01.dbf RECID=2 STAMP=864751840
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/leo/users01.dbf RECID=3 STAMP=864751840

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=864751840 file name=/u01/app/oracle/oradata/leo/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=864751840 file name=/u01/app/oracle/oradata/leo/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=864751840 file name=/u01/app/oracle/oradata/leo/users01.dbf

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

database opened
Finished Duplicate Db at 27-NOV-14

--8、leo create spfile

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  534462464 bytes
Fixed Size                  2254952 bytes
Variable Size             327157656 bytes
Database Buffers          197132288 bytes
Redo Buffers                7917568 bytes
Database mounted.
Database opened.
SQL> create spfile from pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initleo.ora';
File created.

SQL> select name from v$datafile; select name from v$tempfile;
infra
/u01/app/oracle/oradata/infra/system01.dbf /u01/app/oracle/oradata/infra/temp01.dbf
/u01/app/oracle/oradata/infra/sysaux01.dbf
/u01/app/oracle/oradata/infra/undotbs01.dbf
/u01/app/oracle/oradata/infra/users01.dbf
leo
/u01/app/oracle/oradata/leo/system01.dbf


/u01/app/oracle/oradata/leo/temp01.dbf
/u01/app/oracle/oradata/leo/sysaux01.dbf
/u01/app/oracle/oradata/leo/undotbs01.dbf
/u01/app/oracle/oradata/leo/users01.dbf

参考:http://blog.csdn.net/tianlesoftware/article/details/5747442

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22193071/viewspace-1349587/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/22193071/viewspace-1349587/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值