Вы находитесь на странице: 1из 11

1)Source Server

=================
-bash-3.2$ rman
Recovery Manager: Release 11.2.0.1.0 - Production on Sat Jul 20 08:07:54 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
RMAN> connect target /
connected to target database: PROD (DBID=233097709)
RMAN>

RMAN> backup database plus archivelog;


Starting backup at 20-JUL-13
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=4 RECID=1 STAMP=821261490
channel ORA_DISK_1: starting piece 1 at 20-JUL-13
channel ORA_DISK_1: finished piece 1 at 20-JUL-13
piece handle=/home/oracle/app/oracle/flash_recovery_area/PROD/backupset/2013_07_
20/o1_mf_annnn_TAG20130720T081130_8yob535t_.bkp tag=TAG20130720T081130 comment=N
ONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 20-JUL-13
Starting backup at 20-JUL-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/home/oracle/app/oracle/oradata/PROD/syste
m01.dbf
input datafile file number=00002 name=/home/oracle/app/oracle/oradata/PROD/sysau
x01.dbf
input datafile file number=00003 name=/home/oracle/app/oracle/oradata/PROD/undot
bs01.dbf
input datafile file number=00004 name=/home/oracle/app/oracle/oradata/PROD/users
01.dbf
channel ORA_DISK_1: starting piece 1 at 20-JUL-13
channel ORA_DISK_1: finished piece 1 at 20-JUL-13
piece handle=/home/oracle/app/oracle/flash_recovery_area/PROD/backupset/2013_07_
20/o1_mf_nnndf_TAG20130720T081132_8yob54l1_.bkp tag=TAG20130720T081132 comment=N
ONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 20-JUL-13
channel ORA_DISK_1: finished piece 1 at 20-JUL-13
piece handle=/home/oracle/app/oracle/flash_recovery_area/PROD/backupset/2013_07_

20/o1_mf_ncsnf_TAG20130720T081132_8yob7jtj_.bkp tag=TAG20130720T081132 comment=N


ONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 20-JUL-13
Starting backup at 20-JUL-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=5 RECID=2 STAMP=821261570
channel ORA_DISK_1: starting piece 1 at 20-JUL-13
channel ORA_DISK_1: finished piece 1 at 20-JUL-13
piece handle=/home/oracle/app/oracle/flash_recovery_area/PROD/backupset/2013_07_
20/o1_mf_annnn_TAG20130720T081250_8yob7l9v_.bkp tag=TAG20130720T081250 comment=N
ONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 20-JUL-13
RMAN>

RMAN> backup current controlfile;


Starting backup at 20-JUL-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 20-JUL-13
channel ORA_DISK_1: finished piece 1 at 20-JUL-13
piece handle=/home/oracle/app/oracle/flash_recovery_area/PROD/backupset/2013_07_
20/o1_mf_ncnnf_TAG20130720T081533_8yobdpgm_.bkp tag=TAG20130720T081533 comment=N
ONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 20-JUL-13
RMAN>
Now create DIR on target server /home/oracle/app/oracle/flash_recovery_area/PROD
/backupset/2013_07_20/
-bash-3.2$ scp * 192.168.171.129:/home/oracle/app/oracle/flash_recovery_area/PRO
D/backupset/2013_07_20/
The authenticity of host '192.168.171.129 (192.168.171.129)' can't be establishe
d.
RSA key fingerprint is 19:0c:1c:84:bb:63:eb:0d:46:29:e7:83:e4:8e:02:2b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.171.129' (RSA) to the list of known hosts.
oracle@192.168.171.129's password:
o1_mf_annnn_TAG20130720T081130_8yob535t_.bkp
100% 727KB 726.5KB/s 00:00
o1_mf_annnn_TAG20130720T081250_8yob7l9v_.bkp
100% 24KB 23.5KB/s 00:00
o1_mf_ncnnf_TAG20130720T081533_8yobdpgm_.bkp
100% 9568KB 9.3MB/s 00:00
o1_mf_ncsnf_TAG20130720T081132_8yob7jtj_.bkp

100% 9600KB 9.4MB/s 00:00


o1_mf_nnndf_TAG20130720T081132_8yob54l1_.bkp
100% 971MB 10.1MB/s 01:36
-bash-3.2$
Create pfile from spfile; and then transfer this pfile to target and make the re
quired changes
2)
Target Server
==============
ash-3.2$ . oraenv
ORACLE_SID = [CLONE] ? CLONE
ORACLE_HOME = [/home/oracle] ? /home/oracle/app/oracle/product/11.2.0/dbhome_1/
The Oracle base for ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1/
is /home/oracle/app/oracle
-bash-3.2$

-bash-3.2$ sqlplus "/as sysdba"


SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 20 09:12:48 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.

SQL> startup nomount


ORACLE instance started.
Total System Global Area 422670336 bytes
Fixed Size
1336960 bytes
Variable Size
281020800 bytes
Database Buffers
134217728 bytes
Redo Buffers
6094848 bytes
SQL>
SQL>

SQL> show parameter service


NAME
TYPE
VALUE
------------------------------------ ----------- -----------------------------service_names
string
CLONE
-bash-3.2$ tnsping PROD
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 20-JUL-2013 10:08
:54
Copyright (c) 1997, 2009, Oracle. All rights reserved.

Used parameter files:


/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 192.168.171.130)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = PROD)))
OK (0 msec)
-bash-3.2$ hostname
rohit.oracle.com
-bash-3.2$

-bash-3.2$ sqlplus sys/sys@PROD as sysdba


SQL*Plus: Release 11.2.0.1.0 Production on Sat Jul 20 10:10:14 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

RMAN> connect auxiliary /


connected to auxiliary database: CLONE (not mounted)

RMAN> connect target sys/sys@PROD


connected to target database: PROD (DBID=233097709)
RMAN>
RMAN> run
2> {
3> allocate auxiliary channel c1 device type disk;
4> allocate channel c2 device type disk;
5> duplicate target database to 'CLONE';
6> }

RMAN> run
2> {
3> allocate auxiliary channel c1 device type disk;
4> allocate channel c2 device type disk;
5> duplicate target database to 'CLONE';
6> }

using target database control file instead of recovery catalog


allocated channel: c1
channel c1: SID=19 device type=DISK
allocated channel: c2
channel c2: SID=37 device type=DISK
Starting Duplicate Db at 20-JUL-13
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

422670336 bytes

Fixed Size
1336960
Variable Size
285215104
Database Buffers
130023424
Redo Buffers
6094848
allocated channel: c1
channel c1: SID=19 device type=DISK

bytes
bytes
bytes
bytes

contents of Memory Script:


{
sql clone "alter system set db_name =
''PROD'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''CLONE'' 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 = ''PROD'' comment= ''Modified by RMAN
duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''CLONE'' comment= ''Modified
by RMAN duplicate'' scope=spfile

Oracle instance shut down


Oracle instance started
Total System Global Area

422670336 bytes

Fixed Size
1336960
Variable Size
285215104
Database Buffers
130023424
Redo Buffers
6094848
allocated channel: c1
channel c1: SID=18 device type=DISK

bytes
bytes
bytes
bytes

Starting restore at 20-JUL-13


channel c1: starting datafile backup set restore
channel c1: restoring control file
channel c1: reading from backup piece /home/oracle/app/oracle/flash_recovery_are
a/PROD/backupset/2013_07_20/o1_mf_ncnnf_TAG20130720T095228_8yoj2ff4_.bkp
channel c1: piece handle=/home/oracle/app/oracle/flash_recovery_area/PROD/backup
set/2013_07_20/o1_mf_ncnnf_TAG20130720T095228_8yoj2ff4_.bkp tag=TAG20130720T0952
28
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:01
output file name=/home/oracle/app/oracle/oradata/CLONE/control01.ctl
output file name=/home/oracle/app/oracle/flash_recovery_area/CLONE/control02.ctl
Finished restore at 20-JUL-13
database mounted
contents of Memory Script:
{
set until scn 816770;
set newname for datafile 1 to
"/home/oracle/app/oracle/oradata/CLONE/system01.dbf";
set newname for datafile 2 to
"/home/oracle/app/oracle/oradata/CLONE/sysaux01.dbf";
set newname for datafile 3 to
"/home/oracle/app/oracle/oradata/CLONE/undotbs01.dbf";
set newname for datafile 4 to
"/home/oracle/app/oracle/oradata/CLONE/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 20-JUL-13
channel c1: starting datafile backup set restore

channel c1: specifying datafile(s) to restore from backup set


channel c1: restoring datafile 00001 to /home/oracle/app/oracle/oradata/CLONE/sy
stem01.dbf
channel c1: restoring datafile 00002 to /home/oracle/app/oracle/oradata/CLONE/sy
saux01.dbf
channel c1: restoring datafile 00003 to /home/oracle/app/oracle/oradata/CLONE/un
dotbs01.dbf
channel c1: restoring datafile 00004 to /home/oracle/app/oracle/oradata/CLONE/us
ers01.dbf
channel c1: reading from backup piece /home/oracle/app/oracle/flash_recovery_are
a/PROD/backupset/2013_07_20/o1_mf_nnndf_TAG20130720T095046_8yohz7jc_.bkp
channel c1: piece handle=/home/oracle/app/oracle/flash_recovery_area/PROD/backup
set/2013_07_20/o1_mf_nnndf_TAG20130720T095046_8yohz7jc_.bkp tag=TAG20130720T0950
46
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:01:06
Finished restore at 20-JUL-13
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=821269029
adata/CLONE/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=821269029
adata/CLONE/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=821269029
adata/CLONE/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=821269029
adata/CLONE/users01.dbf

file name=/home/oracle/app/oracle/or
file name=/home/oracle/app/oracle/or
file name=/home/oracle/app/oracle/or
file name=/home/oracle/app/oracle/or

contents of Memory Script:


{
set until scn 816770;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 20-JUL-13
starting media recovery
channel c1: starting archived log restore to default destination
channel c1: restoring archived log
archived log thread=1 sequence=8
channel c1: reading from backup piece /home/oracle/app/oracle/flash_recovery_are
a/PROD/backupset/2013_07_20/o1_mf_annnn_TAG20130720T095216_8yoj20rk_.bkp
channel c1: piece handle=/home/oracle/app/oracle/flash_recovery_area/PROD/backup
set/2013_07_20/o1_mf_annnn_TAG20130720T095216_8yoj20rk_.bkp tag=TAG20130720T0952

16
channel c1: restored backup piece 1
channel c1: restore complete, elapsed time: 00:00:01
archived log file name=/home/oracle/app/oracle/flash_recovery_area/CLONE/archive
log/2013_07_20/o1_mf_1_8_8yokjr1n_.arc thread=1 sequence=8
channel clone_default: deleting archived log(s)
archived log file name=/home/oracle/app/oracle/flash_recovery_area/CLONE/archive
log/2013_07_20/o1_mf_1_8_8yokjr1n_.arc RECID=6 STAMP=821269032
media recovery complete, elapsed time: 00:00:02
Finished recover at 20-JUL-13
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set db_name =
''CLONE'' 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
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area

422670336 bytes

Fixed Size
1336960
Variable Size
285215104
Database Buffers
130023424
Redo Buffers
6094848
allocated channel: c1
channel c1: SID=18 device type=DISK

bytes
bytes
bytes
bytes

sql statement: alter system set db_name = ''CLONE'' comment= ''Reset to origin
al 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

422670336 bytes

Fixed Size
1336960 bytes
Variable Size
285215104 bytes
Database Buffers
130023424 bytes
Redo Buffers
6094848 bytes
allocated channel: c1
channel c1: SID=18 device type=DISK
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "CLONE" RESETLOGS ARCHIVELO
G
MAXLOGFILES
16

MAXLOGMEMBERS
3
MAXDATAFILES
100
MAXINSTANCES
8
MAXLOGHISTORY
292
LOGFILE
GROUP 1 ( '/home/oracle/app/oracle/oradata/CLONE/redo01.log' ) SIZE 50 M REU
SE,
GROUP 2 ( '/home/oracle/app/oracle/oradata/CLONE/redo02.log' ) SIZE 50 M REU
SE,
GROUP 3 ( '/home/oracle/app/oracle/oradata/CLONE/redo03.log' ) SIZE 50 M REU
SE
DATAFILE
'/home/oracle/app/oracle/oradata/CLONE/system01.dbf'
CHARACTER SET WE8MSWIN1252
contents of Memory Script:
{
set newname for tempfile 1 to
"/home/oracle/app/oracle/oradata/CLONE/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/home/oracle/app/oracle/oradata/CLONE/sysaux01.d
bf",
"/home/oracle/app/oracle/oradata/CLONE/undotbs01.dbf",
"/home/oracle/app/oracle/oradata/CLONE/users01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /home/oracle/app/oracle/oradata/CLONE/temp01.dbf in contro
l file
cataloged datafile copy
datafile copy file name=/home/oracle/app/oracle/oradata/CLONE/sysaux01.dbf RECID
=1 STAMP=821269061
cataloged datafile copy
datafile copy file name=/home/oracle/app/oracle/oradata/CLONE/undotbs01.dbf RECI
D=2 STAMP=821269061
cataloged datafile copy
datafile copy file name=/home/oracle/app/oracle/oradata/CLONE/users01.dbf RECID=
3 STAMP=821269061
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=821269061 file name=/home/oracle/app/oracle/or
adata/CLONE/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=821269061 file name=/home/oracle/app/oracle/or
adata/CLONE/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=821269061 file name=/home/oracle/app/oracle/or
adata/CLONE/users01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script

database
Finished
released
released

opened
Duplicate Db at 20-JUL-13
channel: c2
channel: c1

RMAN>
Clonnig Done
==============
SQL> select name from v$database;
NAME
--------PROD

NAME
-------------------------------------------------------------------------------/home/oracle/app/oracle/oradata/PROD/system01.dbf
/home/oracle/app/oracle/oradata/PROD/sysaux01.dbf
/home/oracle/app/oracle/oradata/PROD/undotbs01.dbf
/home/oracle/app/oracle/oradata/PROD/users01.dbf

SQL> select name from v$database;


NAME
--------CLONE
SQL> select name,open_mode from v$database;
NAME
OPEN_MODE
--------- -------------------CLONE
READ WRITE

NAME
-------------------------------------------------------------------------------/home/oracle/app/oracle/oradata/CLONE/system01.dbf
/home/oracle/app/oracle/oradata/CLONE/sysaux01.dbf
/home/oracle/app/oracle/oradata/CLONE/undotbs01.dbf
/home/oracle/app/oracle/oradata/CLONE/users01.dbf

CREATE CONTROLFILE REUSE SET DATABASE "CLONE" RESETLOGS ARCHIVELOG


MAXLOGFILES
16
MAXLOGMEMBERS
3
MAXDATAFILES
100
MAXINSTANCES
8
MAXLOGHISTORY
292

LOGFILE
GROUP 1 ( '/home/oracle/app/oracle/oradata/CLONE/redo01.log' ) SIZE 50 M REU
SE,
GROUP 2 ( '/home/oracle/app/oracle/oradata/CLONE/redo02.log' ) SIZE 50 M REU
SE,
GROUP 3 ( '/home/oracle/app/oracle/oradata/CLONE/redo03.log' ) SIZE 50 M REU
SE
DATAFILE
'/home/oracle/app/oracle/oradata/CLONE/system01.dbf'
CHARACTER SET WE8MSWIN1252

Вам также может понравиться